Skip to content

Commit f002733

Browse files
Merge pull request #2890 from yashranaway/fix/camera-blur-gpu-fallback
fix(desktop-gpui): keep camera preview alive when blur GPU setup fails
2 parents fa6488e + 310c03d commit f002733

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/desktop-gpui/src/camera_blur_portable.rs‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ impl PortableCameraBlur {
8282
.await
8383
.map_err(|error| anyhow!("camera blur device: {error}"))
8484
})?;
85-
let mut processor =
86-
cap_camera_effects::BlurProcessor::new(&device, wgpu::TextureFormat::Rgba8Unorm)
87-
.context("camera blur processor")?;
85+
device.push_error_scope(wgpu::ErrorFilter::Validation);
86+
let processor =
87+
cap_camera_effects::BlurProcessor::new(&device, wgpu::TextureFormat::Rgba8Unorm);
88+
if let Some(error) = runtime.block_on(device.pop_error_scope()) {
89+
anyhow::bail!("camera blur GPU validation: {error}");
90+
}
91+
let mut processor = processor.context("camera blur processor")?;
8892
processor.set_inference_interval(INFERENCE_INTERVAL);
8993

9094
Ok(Self {
@@ -294,6 +298,19 @@ mod tests {
294298
);
295299
}
296300

301+
#[test]
302+
fn unsupported_gpu_returns_an_error_without_panicking() {
303+
if std::env::var_os("CAP_GPUI_TEST_UNSUPPORTED_BLUR_GPU").is_none() {
304+
return;
305+
}
306+
307+
cap_camera_effects::initialize_onnx_runtime().expect("ONNX Runtime available");
308+
let error = PortableCameraBlur::new()
309+
.err()
310+
.expect("unsupported GPU rejected");
311+
assert!(error.to_string().contains("camera blur GPU validation"));
312+
}
313+
297314
#[test]
298315
fn portable_blur_processes_bgra_frames_without_changing_dimensions() {
299316
#[cfg(not(target_os = "macos"))]

0 commit comments

Comments
 (0)