From cda3f21652eea34524cd7e7e8b4265b72830e01a Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Sun, 13 Aug 2023 22:06:22 +0800 Subject: [PATCH] Fix `capture` example panic in the browser (#4043) --- examples/capture/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/capture/src/main.rs b/examples/capture/src/main.rs index 5990f76587..09a0ed0d85 100644 --- a/examples/capture/src/main.rs +++ b/examples/capture/src/main.rs @@ -148,13 +148,13 @@ async fn create_png( // // We pass our submission index so we don't need to wait for any other possible submissions. device.poll(wgpu::Maintain::WaitForSubmissionIndex(submission_index)); - // If a file system is available, write the buffer as a PNG - let has_file_system_available = cfg!(not(target_arch = "wasm32")); - if !has_file_system_available { - return; - } if let Some(Ok(())) = receiver.receive().await { + // If a file system is available, write the buffer as a PNG + let has_file_system_available = cfg!(not(target_arch = "wasm32")); + if !has_file_system_available { + return; + } let padded_buffer = buffer_slice.get_mapped_range(); let mut png_encoder = png::Encoder::new(