Repository navigation
Release the image picker's previews a minute after it closes - #15201
Merged
Merged
Conversation
The picker stays loaded between opens and kept every decoded card preview, about 7 MB each and a dozen at a time, for the life of the shell. Hold them while open and for a minute after closing, so a quick reopen still shows at once, then let them go. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What
The image/theme picker keeps its decoded card previews while it is open and for one minute after it closes. After that it releases them. A small
PreviewHoldcomponent decides when they are held: it is active while the picker is open, andpreloadRows()warms it the same way. When the hold ends,neighborImagesEnabledresets, so the next open decodes the selected card first again, like a first open.Why
A heap profile after opening the theme picker once showed 77 MB in eleven 7 MB
QImages. Each card's preview is decoded at the expanded card size (768x475 logical at the screen's DPR) so navigating never reloads it. The picker iskeepLoaded, though, so those bitmaps stayed for the life of the shell, even though the picker sits closed nearly all the time.The grace minute keeps a quick reopen as instant as it is now. Holding the previews forever is what costs the memory, so a reopen later than that decodes again. That is about a dozen ~100 KB JPEG thumbnails, the same work a first open already does.
Codex caught an issue in review:
Timer.restart()stops a running timer before restarting it, so aheldbound totimer.runningblinked off. The previews then unloaded and reloaded, and that happened on every close.heldis now a separate flag that the timer only clears, and a test asserts it never toggles while the grace period is extended.Measurements
Same machine and steps as #15199. RSS in MB, with the allocator settings from #15199 plus omacom/omarchy-pkgs#1004 (huge pages off, one arena, background purge). "Late" is 65 s after the last panel closed.
Without #15199's background purge thread the freed pages mostly stay resident, because jemalloc only purges while the program allocates. That is one reason #15199 turns the thread on.
Tests
test/shell.d/image-picker-preview-hold-test.shrunsqmltestrunneronPreviewHold. It covers: nothing held before the first open; held while open; released after the grace period; a reopen within the grace period keeps the previews; a preload holds them; and extending the grace period never togglesheld(counted with aSignalSpy). Mutation-checked: holding forever, or the previous timer-bound version, fails it../test/shell: only the 6 known baseline failures.image-picker-test.shpasses.For a human to check
🤖 Generated with Claude Code