Skip to content

Conversation

@MartinKavik
Copy link
Contributor

Add WeakWindow and Window::downgrade to help compositors fix and prevent issues like Closing windows causes VRAM memory leak (#1562)

More details in issue linked above and in pop-os/cosmic-comp#2084

tl;dr:
WeakWindow holds a weak reference to the underlying window resources, avoiding the strong Arc reference that keeps GPU buffers alive after a window is closed. Call upgrade() to get back an Option<Window>.

Wayland protocol objects (e.g. ZcosmicToplevelHandleV1) can outlive
the surfaces they reference. When ToplevelHandleState holds a strong
Window reference, the entire chain (WindowInner → WlSurface →
SurfaceData → data_map → GPU textures) stays alive, leaking VRAM.

Add Window::downgrade() → WeakWindow so consumers can store weak
references that do not prevent resource cleanup.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

Thanks

@Drakulix Drakulix merged commit 599857c into Smithay:master Feb 12, 2026
13 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.

2 participants