From ecbed8b57410aec212216665a35554d5b858058d Mon Sep 17 00:00:00 2001 From: Rob <136381220+robertpakalns@users.noreply.github.com> Date: Wed, 13 May 2026 03:44:43 +0300 Subject: [PATCH] fix: provide default display handle for web canvas surface targets (#9476) --- wgpu/src/api/instance.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wgpu/src/api/instance.rs b/wgpu/src/api/instance.rs index 673f017952..d192959e81 100644 --- a/wgpu/src/api/instance.rs +++ b/wgpu/src/api/instance.rs @@ -221,12 +221,13 @@ impl Instance { let value: &wasm_bindgen::JsValue = &canvas; let obj = core::ptr::NonNull::from(value).cast(); let raw_window_handle = raw_window_handle::WebCanvasWindowHandle::new(obj).into(); + let raw_display_handle = raw_window_handle::WebDisplayHandle::new().into(); // Note that we need to call this while we still have `value` around. // This is safe without storing canvas to `handle_origin` since the surface will create a copy internally. unsafe { self.create_surface_unsafe(SurfaceTargetUnsafe::RawHandle { - raw_display_handle: None, + raw_display_handle: Some(raw_display_handle), raw_window_handle, }) }? @@ -239,12 +240,13 @@ impl Instance { let obj = core::ptr::NonNull::from(value).cast(); let raw_window_handle = raw_window_handle::WebOffscreenCanvasWindowHandle::new(obj).into(); + let raw_display_handle = raw_window_handle::WebDisplayHandle::new().into(); // Note that we need to call this while we still have `value` around. // This is safe without storing canvas to `handle_origin` since the surface will create a copy internally. unsafe { self.create_surface_unsafe(SurfaceTargetUnsafe::RawHandle { - raw_display_handle: None, + raw_display_handle: Some(raw_display_handle), raw_window_handle, }) }?