From 4f677c8b67f07d4c13618b9978c0ba7ee4e237bf Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 12 Sep 2021 10:41:42 -0400 Subject: [PATCH] hal/mtl: check for next_drawable() result --- wgpu-hal/src/metal/surface.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index 0ccd2a21f..b0a9ad998 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -265,10 +265,14 @@ impl crate::Surface for super::Surface { _timeout_ms: u32, //TODO ) -> Result>, crate::SurfaceError> { let render_layer = self.render_layer.lock(); - let (drawable, texture) = autoreleasepool(|| { - let drawable = render_layer.next_drawable().unwrap(); - (drawable.to_owned(), drawable.texture().to_owned()) - }); + let (drawable, texture) = match autoreleasepool(|| { + render_layer + .next_drawable() + .map(|drawable| (drawable.to_owned(), drawable.texture().to_owned())) + }) { + Some(pair) => pair, + None => return Ok(None), + }; let suf_texture = super::SurfaceTexture { texture: super::Texture {