From 7885306c025f58e8f4e694892e19a73b93cd17e0 Mon Sep 17 00:00:00 2001 From: "nico.burns" Date: Tue, 4 Aug 2026 22:25:03 +0000 Subject: [PATCH] Release renderer surface before window drop to fix segfault on close (Wayland) --- packages/blitz-shell/src/window.rs | 11 +++++++++++ packages/dioxus-native/src/lib.rs | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/blitz-shell/src/window.rs b/packages/blitz-shell/src/window.rs index 519f7f8105..f12c019175 100644 --- a/packages/blitz-shell/src/window.rs +++ b/packages/blitz-shell/src/window.rs @@ -120,6 +120,17 @@ pub struct View { pub ios_request_redraw: std::cell::Cell, } +impl Drop for View { + fn drop(&mut self) { + // Release the renderer's window surface before the window is dropped. + // The renderer may be shared (e.g. provided as a context to user code), + // in which case it can outlive the `View`. A GPU surface must not + // outlive the window/display it is attached to: dropping it after the + // event loop has shut down segfaults on Wayland. + self.renderer.suspend(); + } +} + impl View { pub fn init( config: WindowConfig, diff --git a/packages/dioxus-native/src/lib.rs b/packages/dioxus-native/src/lib.rs index ad1ea75fad..eb8d0b7ff5 100644 --- a/packages/dioxus-native/src/lib.rs +++ b/packages/dioxus-native/src/lib.rs @@ -233,11 +233,8 @@ pub fn launch_cfg_with_props( base_color: config.base_color, alpha_mode: config.alpha_mode, }); - let config = WindowConfig::with_attributes( - Box::new(doc) as _, - renderer.clone(), - config.window_attributes, - ); + let config = + WindowConfig::with_attributes(Box::new(doc) as _, renderer, config.window_attributes); // Create application let application = DioxusNativeApplication::new(proxy, event_queue, config);