Repository navigation
Keep preview decoding shared through late display-scale changes - #139
Conversation
[Medium impact] The PR appears safe to merge. SummaryThe preview keeps a hidden image attached to the same window while a still image loads, so scale changes can reuse work already underway.
No actionable issues found. Tests were not run during this review. Reviews (3) · Last reviewed commit: "Keep only the test that proves a reload ..." · Reviewed by Greptile |
|
Thanks for tracing this, Clayton. The double decode is real, but on a stock Omarchy install this branch still decodes the picture twice, so it can't go in as the fix yet. What was checked. On a disposable Omarchy worker (Hyprland 0.57.2, Qt 6.12.0, qt6-wayland 6.12.0),
Each decode reads the whole ~67 MB file on the pixmap reader thread and takes ~0.85 s, so the picture is ready ~1.6 s after the window opens instead of ~0.9 s. The full suite ( Why the deferral doesn't hold here. A copy of this branch logging the window's own What else was checked, and holds. The deferred call can't set a stale source: it only flips The test checks that One approach that held on the worker. Since the reload only re-requests the same image, keeping a second reference to the decode lets the reload join it instead of starting again. On main, inside // Outside the window, so it never reloads when the window learns its scale:
// the still image reloading then joins this decode instead of starting another.
property Image keeper: Image { asynchronous: true; autoTransform: true; source: still.source }That gave one decode at 1.0, 1.6 and 2.0, the picture ready ~0.9 s after opening, the same memory as main (both share one cache entry; VmRSS ~603 MB either way on this file), and the suite green. It depends on the two Images having the same pixmap cache key: without Second opinion. Codex Medium and muse-wonder (via pi, thinking high) reviewed the diff and these measurements. Both agreed the deferral loses the race on this worker and that the test checks the mechanism rather than the outcome; that agreement is not guaranteed independent. muse-wonder added the Waiting on: you, for a change that keeps the second decode from happening on a stock install. #140 is stacked on this branch, so whatever replaces this commit, #140 will need rebasing onto it. |
The fix is nine lines in the preview window; the tests around it had grown to two hundred, with a stand-in previewer class and provider at file scope and a second test of the preview's geometry, zoom and navigation that doesn't touch the fix. Keep the one test that counts the provider's reads across a reload while the first decode is held: two without the keeper, one with it. Its provider and stand-in previewer now live inside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e64d800 to
b72e54c
Compare
|
Thanks, Clayton. The keeper is a nice small fix, and it's the right one. I rebased it onto main and trimmed the tests to the one that proves it, so the change stays proportional to its nine lines: |
Large still images can lose their only in-flight pixmap reference when the preview window learns its final display scale. Qt finishes the abandoned decode, then reads the same file again for the replacement request.
The initial
Qt.callLaterdeferral was insufficient: the compositor can settle the window's DPR after the first frame, as demonstrated in the review. This revision removes that deferral.Keep a second reference while the visible image is Loading, using an invisible Image child with the same window, source and
autoTransformoptions. Sequential scale reloads can join the shared in-flight request instead of cancelling its last reference. The keeper clears its source at Ready/Error; full resolution, geometry and navigation remain unchanged.The keeper is a visual child rather than a windowless Image: on mixed-scale displays, a windowless image can resolve a different
@Nxsibling or SVG rasterization. Sharing the window avoids that mismatch without sibling-file probes or private Qt APIs.Validation:
The offscreen reload test checks shared-request lifetime, not the compositor's scale-negotiation timeline; native tracing provides the startup check. No latency claims from the superseded deferral prototype are relied upon here.
Simplify and independent code-review passes completed before this update. No new dependencies or global settings changes.