Repository navigation
fix(desktop-gpui): release preview textures the GPU atlas keeps after dialogs close - #2801
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Found 1 test failure on Blacksmith runners: Failure
|
Member
Author
|
@greptileai review |
richiemcilroy
marked this pull request as ready for review
October 22, 2026 06:21
Member
Author
|
@greptileai review |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
What
gpui's sprite atlas is per window and keyed by image id. Dropping the last
Arc<RenderImage>does not free its tile or texture; onlyWindow::drop_imagedoes, and otherwise the texture stays until the window closes. These images were replaced or discarded without it, inside long-lived editor windows:screenshot_crop.rs): the original PNG is decoded at full resolution for every open (5120x2880 is 59 MB) and dropped on Save/Cancel/Escape/backdrop without evictioneditor_crop.rs): same shape, the full-resolution display frame decoded per open, dropped on Save/Cancel without eviction; a late decode landing on a reopened crop also replaced a frame without evictioneditor_sidebar.rs): a new noise texture per grain-scale step during a slider drag, each old one left in the atlaseditor_sidebar.rsensure_preview): replaced on every new selection and cleared on tab switch without evictionscreenshot_editor.rsensure_background_image): sameFix
Mirrors the existing
window.drop_image(previous)pattern (frame_arrived,MainWindow::set_recents,ThumbnailCache):ScreenshotCropDialog::release_image,CropState::release_frame), and the video crop evicts a frame a late decode replacesspawn_in(window)so the completion has a&mut WindowNoiseCache) queues replaced textures, andEditorWindow::renderreleases them on the next frame throughSidebarState::release_retired_images, since the sidebar panel is built without a&mut WindowNo behaviour change otherwise: the same images are shown, cached and re-decoded exactly as before; only atlas eviction is added. Images still on screen are never evicted (replace drops the previous one only after the new one is installed, and the grain queue drains one frame after the swap).
Other
RenderImageproducers checked and left alone: camera, editor preview, screenshot frames, recents/target thumbnails, settings avatars, export thumbnail (all already evict), clip thumbnails, wallpaper tiles, cursor and color preset tiles (bounded caches that are never replaced).Tests
a_new_grain_step_retires_the_old_texture_for_atlas_eviction: every replaced grain texture is handed back for eviction exactly once, the current one never isMeasurements
Scratch probe on Blacksmith macOS 15 (run 39538128953): debug build of this branch, a generated 5120x2880 screenshot bundle, a scratch hook that opens the crop dialog, waits 4 s for decode and paint, cancels, and repeats 10 times.
CAP_PROBE_NO_RELEASE=1skips only the newdrop_imagecall, so both rows come from the same binary. Numbers fromCOMET_GPU_STATSandfootprintafter the 10 cycles, two rounds each:Without the release every open leaves about 56 MB in the atlas (one 5K BGRA texture), so footprint climbs by about 50 MB per open. With it, the atlas is back to its pre-dialog size after every close (the 61.2 MB left is the editor's own 5K preview frame).
The video editor crop, grain and background preview paths are the same
drop_imagecall and were not probed separately. The grain path is covered by the unit test.

Confidence Score: 5/5
This PR appears safe to merge; no actionable issues were found.Summary
This PR releases preview images from the window’s GPU atlas when they are no longer needed.
No actionable issues were found. Build checks and runtime tests were not run.
Reviews (1) · Last reviewed commit: "fix(desktop-gpui): release preview textu..." · Reviewed by Greptile