Skip to content

Release the image picker's previews a minute after it closes - #15201

Merged
dhh merged 2 commits into
quattrofrom
image-picker-release-previews
Oct 13, 2026
Merged

dhh merged 2 commits into
quattrofrom
image-picker-release-previews

Conversation

@dhh

@dhh dhh commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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 PreviewHold component decides when they are held: it is active while the picker is open, and preloadRows() warms it the same way. When the hold ends, neighborImagesEnabled resets, 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 is keepLoaded, 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 a held bound to timer.running blinked off. The previews then unloaded and reloaded, and that happened on every close. held is 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.

after opening everything late
#15199 only 492 483
#15199 + this 487 415
#15199 + this + #15200 (clipboard) 438 365

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.sh runs qmltestrunner on PreviewHold. 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 toggles held (counted with a SignalSpy). Mutation-checked: holding forever, or the previous timer-bound version, fails it.
  • ./test/shell: only the 6 known baseline failures. image-picker-test.sh passes.
  • Visual: the theme picker before and after, and reopened after the previews were released. The reopened picker is pixel-identical to the first open, revealed complete with no pop-in. No new warnings in the shell log.

For a human to check

  • Open the theme picker (Style › Theme), close it, wait over a minute, and reopen. It should appear within a frame or two of a first open, with every card already drawn.

🤖 Generated with Claude Code

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]>
@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test concern addressed.

Summary

The picker keeps decoded previews while open and for one minute after closing, then releases them.

  • The image picker releases decoded previews one minute after it closes.

Reviews (2) · Last reviewed commit: "Check that a preload extends the picker'..." · Reviewed by Greptile

@dhh
dhh merged commit c9a4af2 into quattro Oct 13, 2026
1 check passed
@dhh
dhh deleted the image-picker-release-previews branch October 13, 2026 12:22
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
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