Description
What happens
A hidden window keeps the view it built last. Its elements hold clones of each Pixels they showed. A hidden window builds no new view (runtime/drop_tests.rs#L120: "While covered, the window builds nothing"; runtime/api.rs#L73-L76). So when the app drops its own Pixels while the window is hidden, Rune still holds them until the window shows again.
These held images also keep their image atlas pages on the CPU side (#163), so the cost is about two times the image size.
Measured
macOS 26.6 VM (paravirtual Metal GPU), our screenshot app (a menu-bar app with a main window that shows a grid of 24 thumbnails), Rune dev dacf5d89 with no patches. The app drops all its thumbnail Pixels 2 s after the main window hides. Malloc stack logging 8 s after the hide, regions with 0.25 MB or more resident:
| owner | MB | regions |
|---|---|---|
Pixels the app made for its thumbnails (the app freed its copies at 2 s) |
13.9 | 24 |
ImageAtlas page buffers (ImagePage::allocate, ImagePage::new) |
10.5 | 4 |
| Rune runtime (motion, layout, text) | about 3.5 | 6 |
| all untagged (VM_ALLOCATE) | 28.4 |
The same app on GPUI, same steps: 1.4 MB untagged in all. GPUI gives the thumbnails back when the app drops them.
Ask
When the app state of a hidden window changes, drop the element clones that hold Pixels. For example, build the view once without drawing it after the change, or drop the last view at hide and build it again before the next show. Then a hidden window holds no image that the app let go, and its atlas pages can go too.
Done when: an app that drops a Pixels while its window is hidden sees that memory freed without showing the window.
Related: #163 (atlas page CPU copies), #161 (hidden window drawables).
Posted via Claude
Activity
Hona commentedon Nov 28, 2026
Fixed in #2686 (
7205f2d44cc14f56c068b4777ea6ffc3cbcdcb9d).Design decision: Instead of rebuilding views while hidden, Rune now releases all retained
Pixels/Imagereferences and CPUImageAtlaspages viaRuntimeCore::drop_images()whenever a window, overlay, or web tab hides or rests unseen—and also when state changes (update/poll) while hidden.drop_images()clearsEl::pixels,El::image_menu, text pill/inline images,InputSpec::pill_image, spare nodes, image-holding memos (tracked viaBuilt::has_pixels), and virtual list offscreen elements/pins, then marks the view dirty so the next visible frame rebuilds and re-uploads only what is still shown. Visible idle rest keeps displayed images resident, and windows with no images leave memos anddirtyuntouched.Verified locally (Windows, DX12 headless GPU + CPU tests):
crates/rune/src/runtime/rest_tests.rsprovingWeak::upgrade()drops toNoneimmediately when the app drops itsPixels/Imagehandles after hidden rest, hiddenupdate, or hiddenpoll(without rebuilding the view while hidden), and proving kept images rebuild cleanly on show.overlay::rest_testsand ranruntime::rest::tests,overlay::rest_tests,overlay::state_walk_tests::wayland_hide_drops_pixels,overlay::tests::overlay_pixels_wake_only_while_shown_and_catch_up_on_show,overlay::retire::tests::drop_hidden_images,render::upload::tests::give_back,runtime::drop_tests,runtime::hidden_wake_tests,runtime::live_only_tests, andwindow::state::covered_tests(all passed), pluscargo check -p rune --target wasm32-unknown-unknown.Not run locally: real macOS/Metal VM malloc-stack profiling, Linux X11/Wayland native windows, or live browser tabs. Please reopen if a hidden window still pins
Pixelsor atlas pages on macOS or elsewhere.