Repository navigation
Description
What happens
On Wayland (layer-shell or the XWayland fallback), hiding an overlay drops its surface but keeps its renderer, its image atlas pages and its last committed view. An image the overlay showed stays in memory until the overlay shows again, even after the app has dropped its own Pixels. For a screenshot overlay that is one or two copies of a full-screen frame (23.8 MB each at 3024x1964 RGBA).
Where
At dev d03349e2:
- overlay.rs#L713: on hide,
Backing::LayerandBacking::Xwaylanddoself.live.take().self.renderer,self.gpuand the runtime's scene stay. - overlay.rs#L888-L889:
park, whichrelease_gpu_when_hiddencalls, returns at once unless the backing isBacking::Window. On Waylandliveis alreadyNonethere, so the renderer and device are never parked. This is from reading the code; we did not setrelease_gpu_when_hiddenourselves. - pixels.rs#L295-L316:
ImageAtlas::end_framefrees a page that showed nothing only at the end of a drawn frame. A hidden overlay draws no frame, so the page from its last shown frame keeps itsdataand its texture.
Measured
Our app: a region overlay that shows a frozen 3024x1964 frame, then hides. Ubuntu 26.04, GNOME 50 Wayland (XWayland overlay), VM with no GPU (lavapipe), 5 alternating runs per side, process PSS, median. Two app-side changes, each measured as its own before/after batch:
| app change | metric | before | after |
|---|---|---|---|
empty the shared Pixels on end (frame.set(0, 0, Vec::new())), after the app already dropped its handle |
after 10 captures | 335.2 MB | 315.2 MB |
| same | idle, hidden | 332.3 MB | 312.3 MB |
| draw one more frame without the image, then hide | after 10 captures | 310.9 MB | 289.2 MB |
| same | idle, hidden | 308.0 MB | 286.3 MB |
Each row has p = 0.008 (rank-sum). The first change frees the frame that the overlay's last committed view still referenced. The second lets end_frame free the atlas page. The extra frame delays the hide by up to 150 ms and needs extra state in the app.
Repro
- An overlay whose view shows
El::pixels(&p), withpset to a 3000x2000 RGBA image. - Show it, let it draw, hide it. Then drop the app's
p. - Check the process RSS, or in a headless test the overlay renderer's
ImageAtlas::pages. The image's bytes are still held.
The numbers above are from our app. We have not run this minimal repro.
Expected
When a Wayland overlay hides (its surface is gone anyway), Rune drops what only that surface's frames needed: the atlas pages and textures for images, and the references to Pixels in the last committed view. Or release_gpu_when_hidden parks the renderer on Wayland too, as on X11. The next show uploads again.
Done when: on Wayland, an overlay that showed a large Pixels and was hidden holds no copy of those pixels (CPU or GPU) once the app drops its Pixels, with no extra frame drawn by the app, and release_gpu_when_hidden parks the renderer on Wayland.
Posted via Claude
Activity
godismyjudge95 commentedon Nov 6, 2026
Related context:
Pixelsreferences.Posted via Claude
purian23 commentedon Nov 12, 2026
The
release_gpu_when_hiddenhalf has a small fix. Hiding a layer overlay destroys its surface, sopark()finds no surface and returns early, and the renderer and device hold are kept.park()should release those two even when the surface is already gone. In our case a hidden 1,000-row launcher went from 55.4 to 47.2 MB of GPU memory.A second gap on the same path: a shared device isn't polled on hide, so its finished frames aren't retired until some other surface draws. Polling it in
park()fixes it.Hona commentedon Nov 23, 2026
When an overlay hid on Wayland, its surface was destroyed first, so the GPU release returned early and the renderer, image pages and the last frame's Pixels stayed alive. Fixed on dev in #1465 (50c194f): a Wayland hide now drops those images, and release_gpu_when_hidden parks the renderer and device there too.