Handle promise texture image fulfill returning nullptr.

Bug: chromium:948249
Change-Id: Id5d9b732a0d9612b7ed562041fa3544fd7c39f71
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206076
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 3d53e8d..8b18edf 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -463,6 +463,10 @@
             // Fulfill once. So return our cached result.
             if (fTexture) {
                 return {sk_ref_sp(fTexture), kKeySyncMode};
+            } else if (fConfig == kUnknown_GrPixelConfig) {
+                // We've already called fulfill and it failed. Our contract says that we should only
+                // call each callback once.
+                return {};
             }
             SkASSERT(fDoneCallback);
             PromiseImageTextureContext textureContext = fDoneCallback->context();
@@ -471,6 +475,8 @@
             // the return from fulfill was invalid or we fail for some other reason.
             auto releaseCallback = sk_make_sp<GrRefCntedCallback>(fReleaseProc, textureContext);
             if (!promiseTexture) {
+                // This records that we have failed.
+                fConfig = kUnknown_GrPixelConfig;
                 return {};
             }