Skip to content

gpui_wgpu: Release surface resources during destroy#51561

Merged
Veykril merged 1 commit intozed-industries:mainfrom
AxXxB:fix-x11-settings-hang-on-window-destroy
Mar 19, 2026
Merged

gpui_wgpu: Release surface resources during destroy#51561
Veykril merged 1 commit intozed-industries:mainfrom
AxXxB:fix-x11-settings-hang-on-window-destroy

Conversation

@AxXxB
Copy link
Copy Markdown
Contributor

@AxXxB AxXxB commented Mar 14, 2026

Summary

Implements the fix proposed by @israelrios in #50269 (comment).

The issue comment narrowed the hang down to X11 window teardown:

  • when the Settings window is closed on X11, the UI thread can stall while WgpuRenderer is dropped during final X11WindowState teardown
  • at that point, the X11 window has already been destroyed
  • the proposed fix is to make WgpuRenderer::destroy() release surface-bound GPU resources eagerly so the native window is destroyed only after the wgpu::Surface and related resources are gone

This PR applies that change in crates/gpui_wgpu/src/wgpu_renderer.rs by calling self.resources.take() inside destroy().

Validation

I confirmed this fix locally on Linux Mint 21.3 Cinnamon by applying it to the v0.227.1 build:

  • opening and closing Settings no longer causes the main window to hang

References

Release Notes:

  • Fixed a Linux/X11 issue where closing the Settings window could cause Zed to hang.

Release surface-bound GPU resources eagerly so X11 window teardown does not stall later during final renderer drop.

Suggested-by: israelrios <220787+israelrios@users.noreply.github.com>
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 14, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @AxXxB on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 14, 2026
@AxXxB
Copy link
Copy Markdown
Contributor Author

AxXxB commented Mar 14, 2026

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 14, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 14, 2026

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title gpui_wgpu: release surface resources during destroy gpui_wgpu: Release surface resources during destroy Mar 14, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

zed-industries-bot commented Mar 14, 2026

Messages
📖

This PR includes links to the following GitHub Issues: #50269
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 804308b

@AxXxB
Copy link
Copy Markdown
Contributor Author

AxXxB commented Mar 15, 2026

I've added Release Notes, but I'm not sure this PR fully resolves the referenced issue, since users seem to be reporting multiple similar problems there.

Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril enabled auto-merge (squash) March 19, 2026 08:14
@Veykril Veykril merged commit 22f3d06 into zed-industries:main Mar 19, 2026
42 checks passed
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
…1561)

## Summary

Implements the fix proposed by @israelrios in
zed-industries#50269 (comment).

The issue comment narrowed the hang down to X11 window teardown:

- when the Settings window is closed on X11, the UI thread can stall
while `WgpuRenderer` is dropped during final `X11WindowState` teardown
- at that point, the X11 window has already been destroyed
- the proposed fix is to make `WgpuRenderer::destroy()` release
surface-bound GPU resources eagerly so the native window is destroyed
only after the `wgpu::Surface` and related resources are gone

This PR applies that change in `crates/gpui_wgpu/src/wgpu_renderer.rs`
by calling `self.resources.take()` inside `destroy()`.

## Validation

I confirmed this fix locally on Linux Mint 21.3 Cinnamon by applying it
to the `v0.227.1` build:

- opening and closing Settings no longer causes the main window to hang

## References

- Refs zed-industries#50269
- Original analysis and fix proposal by @israelrios:
zed-industries#50269 (comment)

Release Notes:

- Fixed a Linux/X11 issue where closing the Settings window could cause
Zed to hang.
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
…1561)

## Summary

Implements the fix proposed by @israelrios in
zed-industries#50269 (comment).

The issue comment narrowed the hang down to X11 window teardown:

- when the Settings window is closed on X11, the UI thread can stall
while `WgpuRenderer` is dropped during final `X11WindowState` teardown
- at that point, the X11 window has already been destroyed
- the proposed fix is to make `WgpuRenderer::destroy()` release
surface-bound GPU resources eagerly so the native window is destroyed
only after the `wgpu::Surface` and related resources are gone

This PR applies that change in `crates/gpui_wgpu/src/wgpu_renderer.rs`
by calling `self.resources.take()` inside `destroy()`.

## Validation

I confirmed this fix locally on Linux Mint 21.3 Cinnamon by applying it
to the `v0.227.1` build:

- opening and closing Settings no longer causes the main window to hang

## References

- Refs zed-industries#50269
- Original analysis and fix proposal by @israelrios:
zed-industries#50269 (comment)

Release Notes:

- Fixed a Linux/X11 issue where closing the Settings window could cause
Zed to hang.
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
…1561)

## Summary

Implements the fix proposed by @israelrios in
zed-industries#50269 (comment).

The issue comment narrowed the hang down to X11 window teardown:

- when the Settings window is closed on X11, the UI thread can stall
while `WgpuRenderer` is dropped during final `X11WindowState` teardown
- at that point, the X11 window has already been destroyed
- the proposed fix is to make `WgpuRenderer::destroy()` release
surface-bound GPU resources eagerly so the native window is destroyed
only after the `wgpu::Surface` and related resources are gone

This PR applies that change in `crates/gpui_wgpu/src/wgpu_renderer.rs`
by calling `self.resources.take()` inside `destroy()`.

## Validation

I confirmed this fix locally on Linux Mint 21.3 Cinnamon by applying it
to the `v0.227.1` build:

- opening and closing Settings no longer causes the main window to hang

## References

- Refs zed-industries#50269
- Original analysis and fix proposal by @israelrios:
zed-industries#50269 (comment)

Release Notes:

- Fixed a Linux/X11 issue where closing the Settings window could cause
Zed to hang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants