[native][metal] Handle null CAMetalLayer.nextDrawable

According to the documentation, nextDrawable returns null after 1s
without an available drawable. Explicitly handle this as a Timeout
error.

Change-Id: I226f497e6952b79a3ae9ac4d9079f5d8af1c0810
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/302118
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/dawn/native/metal/SwapChainMTL.mm b/src/dawn/native/metal/SwapChainMTL.mm
index 3a3a8cf..88c9850 100644
--- a/src/dawn/native/metal/SwapChainMTL.mm
+++ b/src/dawn/native/metal/SwapChainMTL.mm
@@ -111,6 +111,13 @@
         DAWN_ASSERT(mCurrentDrawable == nullptr);
         mCurrentDrawable = [*mLayer nextDrawable];
 
+        if (mCurrentDrawable == nullptr) {
+            SwapChainTextureInfo info;
+            info.texture = nullptr;
+            info.status = wgpu::SurfaceGetCurrentTextureStatus::Timeout;
+            return info;
+        }
+
         TextureDescriptor textureDesc = GetSwapChainBaseTextureDescriptor(this);
 
         mTexture = Texture::CreateWrapping(ToBackend(GetDevice()), Unpack(&textureDesc),