Skip to content

Show a cached picture while the original preview loads - #140

Merged
dhh merged 1 commit into
omacom:mainfrom
claytonfaria:perf/cached-preview-first
Nov 18, 2026
Merged

dhh merged 1 commit into
omacom:mainfrom
claytonfaria:perf/cached-preview-first

Conversation

@claytonfaria

@claytonfaria claytonfaria commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Space preview shows a cached thumbnail while Qt decodes the original. It reuses the details pane’s thumb provider and builds on the shared-decode fix from #139.

The preview checks existing thumbnail buckets without writing to the cache. It reads the original’s upright dimensions from its header to size the placeholder, so a small picture stays at its actual size. Qt delivers both requests on the same image reader, so the thumbnail gets up to 50 ms to arrive before the original starts.

The tests cover a read-only cache miss, a hit in a larger bucket, the size of a small picture through the handoff, and sharing the original’s in-flight decode across a reload. The handoff passed offscreen at 1× and 2×, and the full local suite passed.

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The preview now shows a cached thumbnail while the original picture loads.

  • Space previews show cached thumbnails while pictures load.

No new actionable issues found. The two earlier findings are addressed.

Reviews (6) · Last reviewed commit: "Show the existing thumbnail while a prev..." · Reviewed by Greptile

@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks, Clayton. A blank Space preview while a big picture decodes is worth fixing. Since this was opened, the details column got the same treatment in #155: it shows the 128px thumbnail from the existing thumb provider at once, and then a sharp picture read at the size shown and kept in ~/.cache/folio/sharp. The preview window should work the same way, with the same pieces, instead of adding a second, memory-only provider, a PreviewThumbnail shared between threads, and a cache lookup in Previewer.

To make it mergeable, please redo it on top of #139 once that lands, rebased on main. Put an Image with Format.thumb(path, mime, …, modified) under still, sized to its geometry and hidden once still is Ready or fails. Have natural fall back to that thumbnail's aspect until the original is in. Most of that should be QML. If it needs "only from the cache, never generate", #120 adds Thumbnails::cached(), which it could build on. Keep the tests to the one or two that fail without the change. 535 lines is a lot for this, and that size is the main thing holding it back.

@claytonfaria
claytonfaria force-pushed the perf/cached-preview-first branch from 0607aec to 961faab Compare November 18, 2026 15:49
Comment thread src/PreviewWindow.qml Resolved
Comment thread src/PreviewWindow.qml Resolved
@claytonfaria
claytonfaria force-pushed the perf/cached-preview-first branch 2 times, most recently from 0adb031 to 23f0f6f Compare November 18, 2026 16:00
@claytonfaria

Copy link
Copy Markdown
Contributor Author

Thanks, David. I rebased #140 onto main after #139 landed and switched Space preview to the existing thumb provider. The preview looks across the cache buckets without generating a thumbnail on a miss, and uses the original’s upright dimensions so small pictures stay the same size through the handoff.

I extended the shared-decode regression to cover the thumbnail handoff. It passed at 1× and 2×, and the full local suite passed. Ready for another look.

@dhh
dhh force-pushed the perf/cached-preview-first branch from 23f0f6f to cb39e20 Compare November 18, 2026 16:27
@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Before/after of the preview window on today's main (this branch merged locally onto it), captured while the original is still decoding: a made-up 4800×3200 Sunset.png whose decode is held open by a gated image provider (as previewSharesAnInFlightDecodeAcrossReloads does), with its 256px thumbnail already in the cache. Main shows an empty window until the decode finishes; this branch shows the cached thumbnail, scaled to the picture's place, in the meantime.

Before and after while a big picture decodes: blank on main, the cached thumbnail with this branch

@dhh
dhh merged commit 905999e into omacom:main Nov 18, 2026
2 checks passed
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