Skip to content

Drop renderer surface before window to fix segfault on close (Wayland) - #611

Merged
nicoburns merged 1 commit into
mainfrom
devin/1785882303-fix-wayland-close-segfault
Aug 4, 2026
Merged

Drop renderer surface before window to fix segfault on close (Wayland)#611
nicoburns merged 1 commit into
mainfrom
devin/1785882303-fix-wayland-close-segfault

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #355 (segfault when closing the window on Linux/Wayland).

The GPU surface was outliving the window/display it was attached to. dioxus_native::launch_cfg_with_props kept an extra DioxusNativeWindowRenderer clone alive as a local:

let renderer = DioxusNativeWindowRenderer::with_options(...);
let config = WindowConfig::with_attributes(doc, renderer.clone(), attrs); // extra Rc clone
// ...
event_loop.run_app(application).unwrap();
// EventLoop (Wayland display connection) dropped here...
// ...then `renderer` (wgpu Surface referencing the dead wl_display/wl_surface) → SIGSEGV

Because the renderer is Rc-shared (and also provided as a vdom context), dropping the View on CloseRequested did not drop the inner renderer, so the wgpu Surface was only destroyed after run_app returned and the event loop / Wayland connection had been torn down — the driver then dereferences freed display memory.

Two changes:

  • blitz-shell: impl Drop for View now calls self.renderer.suspend(), which releases the surface (RenderState::Suspended) while the window and event loop are still alive — robust regardless of outstanding renderer clones.
  • dioxus-native: pass renderer into WindowConfig by value instead of keeping a stray clone alive past run_app.

Not reproduced locally (headless VM, no Wayland/NVIDIA); verified with cargo check, cargo clippy, and cargo test --workspace (all green).

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/0caa615da22344ffb73a7ff21bcfca0f
Requested by: @nicoburns

WPT results

No changes in test results compared to main.

Generated by the WPT workflow.

@nicoburns nicoburns self-assigned this Aug 4, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@nicoburns
nicoburns merged commit 7dcf159 into main Aug 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant