Skip to content

Keep the image picker responsive with large theme collections - #14117

Merged
bjarneo merged 3 commits into
omacom:quattrofrom
keylimesoda:fix/image-picker-large-collections
Oct 3, 2026
Merged

bjarneo merged 3 commits into
omacom:quattrofrom
keylimesoda:fix/image-picker-large-collections

Conversation

@keylimesoda

@keylimesoda keylimesoda commented Oct 3, 2026 •

Copy link
Copy Markdown

With hundreds of installed themes, the image picker creates a masked, layered delegate for every row, decodes nearby images synchronously, and keeps every visited source alive. On a cold thumbnail cache, lazy preparation also launches one converter per image. These costs grow with the collection and can starve the shell or exceed its IPC deadline.

This change bounds the expensive work while preserving the existing carousel:

  • Render only the display's visible slices plus one prefetch slice per side, with a hard ceiling of 33 delegates. Compute matching indices once per filter change and reconcile the window so overlapping delegates and images survive navigation.
  • Decode asynchronously at card size, prioritize the selected preview, and release departed images. Show a solid placeholder immediately, fade previews in, and use 90 ms navigation transitions without delaying keyboard focus.
  • Queue lazy thumbnail preparation in one shared pool per image list, with one worker on single/dual-core machines and at most two on larger machines. Use lower CPU priority and idle I/O priority. A shared pending queue retains jobs from contended refreshes. The pool drains each batch through an open descriptor after unlinking it, and releases ownership under the publication lock when empty so newly arriving jobs always have a worker.

Validation:

  • test/shell.d/image-picker-test.sh: passed, including 200, 530, and 10,000 rows, filtering, window bounds, delegate retention, and filtered row refresh when the selected theme disappears.
  • test/shell.d/menu-images-test.sh: passed, including blocked converters, repeated refreshes, added/changed images during lock contention, queue completion after parent exit, worker limits for 1/2/8 cores, CPU/I/O priority, and fixture cleanup on both successful and failing exits.
  • test/shell.d/runtime-smoke-test.sh: passed against the live compositor.
  • Bash syntax and git diff --check: passed.
  • Live keyboard checks: wraparound, filtering, no matches, Escape, and selection-file round trip passed. Reviewed screenshots and a short recording of loading and navigation.

For a resource-constrained live run, an isolated full shell was pinned to one CPU core, limited to 50% CPU and 512 MiB through a user systemd service, and given held rows for actual installed previews:

Preview rows Live cards on the test display Shell RSS after navigation Initialized UI keyboard-ready time
200 17 243–246 MiB 31–50 ms
529 17 245–247 MiB 33–60 ms

The first presentation, including initial rendering setup, was about 335 ms. All nearby previews took about 1.5 s on that first presentation and continued loading while input was available; later runs finished them in roughly 0.6–0.7 s. The service stayed within its 512 MiB limit. These are measurements from a constrained laptop, not a claim about every low-end GPU or slow disk; the timing probe measures the held-row UI path rather than filesystem discovery.

Two broader checks fail identically in an untouched worktree at the base commit: test/cli at “vscode generated theme references current theme file”, and video-background-test.sh with an unbound PREPARED_BACKGROUND_SNAPSHOT. All video thumbnail assertions preceding that unrelated transition failure passed.

Related: #12792 and #12819. This takes a bounded delegate-window approach and also limits the lazy converter pool.

Review follow-up: filtered refresh now chooses a matching selection; contended refreshes retain their thumbnail jobs; test cleanup releases fixture gates, waits for tracked worker groups, and removes temporary directories on either exit path. The filtered-removal scenario was also exercised and visually inspected in the local desktop picker.

Aggregate follow-up validation: ./test/all completed; the CLI suite still fails its VSCode theme-reference assertion, and 12 of 294 shell test files failed (one other file had skipped checks). This setup lacks the companion omarchy-pkgs checkout and omasnap. The Elsewhen migration, kernel-header migration, browser-launcher, captive-portal, passwordless-grant lifecycle, and screenshot prerequisite failures were reproduced in the untouched base worktree. The video transition failure above is unchanged. Runtime smoke passed all assertions during the aggregate run but its temporary-directory cleanup raced; a standalone rerun completed successfully. The two focused picker suites pass, including the new review regressions.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refactors image picker carousel rendering and thumbnail generation.

The PR appears safe to merge; the remaining portrait-preview sharpness concern is non-blocking.

Findings

  1. P2 Portrait previews lose sharpness ▶

Summary

The PR bounds carousel delegates and image decoding, and moves lazy thumbnail preparation into a small, shared background pool.

  • The follow-up selects a matching row when filtered results refresh and retains thumbnail jobs published during lock contention.
  • It also adds regression coverage and cleans up gated test workers on exit.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Image-list refresh] --> B[Publish missing thumbnails under queue lock]
  B --> C{Pool already owns list?}
  C -->|Yes| D[Existing pool drains next batch]
  C -->|No| E[Start bounded pool]
  E --> F[Unlink and drain batch]
  D --> F
  F --> G[Release ownership when queue is empty]
Loading

Reviews (3) · Last reviewed commit: "Retain lazy thumbnail jobs across concur..."

Comment thread bin/omarchy-menu-images Resolved
// Queue the selected preview first; neighbors must not delay
// the image the user opened the picker to see.
source: (item.selected || root.neighborImagesEnabled) && item.thumbnailPath ? Util.fileUrl(item.thumbnailPath) : ""
sourceSize: Qt.size(root.expandedWidth, root.expandedHeight)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Portrait previews lose sharpness The image is decoded within a fixed 768×475 size and then cropped to fill a wide card. Portrait images can therefore be enlarged after decoding, making their selected previews noticeably softer. Sizing the decode for the crop as well as the card would preserve detail.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be a false positive. Qt documents that when both sourceSize dimensions are set, PreserveAspectCrop uses the optimal decode size for cropping rather than always fitting within that rectangle first: https://doc.qt.io/qt-6.10/qml-qtquick-image.html#sourceSize-prop . This Image already uses PreserveAspectCrop. I have kept the existing size request rather than increasing decode work based on the fit-then-enlarge assumption.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right — this was a false positive. With fillMode: Image.PreserveAspectCrop and both sourceSize dimensions specified, Qt chooses a source size appropriate for the crop rather than simply decoding to fit within the requested rectangle and then enlarging portrait images. The existing sourceSize: Qt.size(root.expandedWidth, root.expandedHeight) is therefore reasonable, and increasing it would add decode cost without the presumed sharpness benefit. No change is needed.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@keylimesoda
keylimesoda marked this pull request as draft October 3, 2026 05:59
@keylimesoda
keylimesoda marked this pull request as ready for review October 3, 2026 06:26
Comment thread test/shell.d/menu-images-test.sh Resolved
@keylimesoda

Copy link
Copy Markdown
Author

I blame @bjarneo for me having to make this ;)

@bjarneo

bjarneo commented Oct 3, 2026

Copy link
Copy Markdown
Member

I blame @bjarneo for me having to make this ;)

Sorry, not sorry. I was considering doing this myself.

@bjarneo

bjarneo commented Oct 3, 2026

Copy link
Copy Markdown
Member

Tested on my machine. Works like a charm.

@bjarneo
bjarneo merged commit dccd88b into omacom:quattro Oct 3, 2026
1 check passed
buger added a commit to probelabs/omarchy that referenced this pull request Oct 4, 2026
Upstream now queues lazy stills for one background worker pool per rows
cache instead of starting a generator per image. The proof-layer tests
still expected in-process generation and failed under MC/DC measurement,
where the xargs children could not reach the trace recorder.

- menu-images-test: under a measurement, BASH_ENV hands the instrumented
  menu's recorder to the xargs children, so they convert and record as
  the menu does. Assertions and comments now describe the pool. New
  scenarios: an unopenable queue lock, and a video converter that refuses
  (marker) or stops with 124/137 (no marker, retried). A wait_for_pools
  helper waits for detached pools before the cache is cleared.
- omarchy-menu-images (comments only): dispositions for the pool rows the
  engine cannot pair (assignment idioms, diverging tails, constant loop,
  unstageable lock failures); the generator ignores that relied on the
  children being unobservable are removed; tail reasons now match how
  the engine records break, continue, return and exit.
- THMB describes eager and lazy generation and the pool; hazard texts
  and worst case updated. MH9B and 43HQ cite constructs, not stale lines.
  Reviews REVIEW-261004-XRKV, -KNQ7, -2L3H.
- KI-MENU-IMAGES-VIPS-NO-TIMEOUT: text follows the pool; the PoC gains a
  lazy-pool arm (a later still waits behind a stalled one; at 393a43d
  it converts). Status unchanged; evidence is left for the central
  refresh.
@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.

3 participants