Repository navigation
Sample the transparent bar's text colour from the wallpaper the shell already decoded - #14220
dt-lindberg wants to merge 7 commits into
Conversation
[Medium impact] No new blocking issue was established in the reviewed changes. SummaryThe PR adds a faster path for choosing transparent-bar text colors.
No new actionable issue was established. dt-lindberg acknowledged that refreshes can still be dropped while the color command runs and deferred that separate fix to #14148. Reviews (4) · Last reviewed commit: "Answer the bar for an undecodable wallpa..." · Reviewed by Greptile |
chessing234
left a comment
There was a problem hiding this comment.
Requesting changes on cb9dd1c.
[P2] Keep the canvas image and callback associated with the same sample request (shell/plugins/background/BarStripSampler.qml:32-47,54-55). sample() replaces pendingCallback and stripRect, but leaves the previous grabUrl active. If A's grab has returned and its canvas image is still loading, B can start before A finishes loading. A's image-loaded/paint event then calls average() with A's URL and B's callback. B receives A's color, and finish() clears B before its own grab completes. The bar's outer request counter accepts this result because it is delivered through B's current callback.
I executed the actual sample, average, and finish functions in a Node harness with controlled grab/image-load events: A returns old-white-grab, B starts, then A loads before B's grab returns. B's callback receives #ffffff sampled from old-white-grab.
Please invalidate/unload the old URL when replacing a request and carry a generation/token through both image loading and painting so only that generation can finish. Add a behavioral overlap test for this order of events. This independently confirms the existing overlapping-grabs thread. The harness verifies the state transition; I have not run a live Qt/Wayland rendering test.
|
@chessing234 thanks for the harness, the fix has been added in a2017a0.
The other thread (previous wallpaper sampled during a second transition) is fixed in the same commit. |
… already decoded The bar ran omarchy-bar-text-color, which decoded the wallpaper again in ImageMagick: 0.3-1.2s on large stock wallpapers, so the text kept the old colour for up to a second after a wallpaper or theme change. The background plugin has already decoded the same image at screen size, so it now grabs the strip under the bar from it on the GPU and averages it (about 30ms), and the command only makes the choice (--sample). Videos, the software renderer and anything without a decoded still fall back to the old path. On all 92 stock wallpapers x 4 screen sizes x 4 positions the choices match the ImageMagick path except 6 near-ties (contrast margins 1.03-1.05).
ImageMagick flattens a transparent wallpaper over white before the file path averages it. The shell's sampler averaged colour without alpha, so fully transparent areas read as black and the two paths chose differently on transparent wallpapers. Weigh each pixel by its alpha over white too.
Two races could give the bar a strip colour from the wrong pixels: - The sampler kept one grab url for all requests. When a newer request started while an older grab's image was still loading, that image's paint answered the newer request with the older pixels. Each request now carries its own callback, strip and grab url, a replaced request's grab is unloaded, and only the current request can finish. - transitionBackground() moves currentBackground before incomingBackground, and a waiting strip request sampled in between, taking the previous transition's incoming frame for the new wallpaper. It now samples once both have moved. A new test runs the sampler's own functions with grabs and image loads landing in the overlapping order; it fails on the old sampler.
…rsion to it. Authored by Claude Opus 5.5 and DTL
a2017a0 to
1c735c8
Compare
…lback omacom#14281 bounded the helper's ImageMagick run; that block now lives in sample_background, which only runs without a --sample. quattro removed background-test.sh and the bar test's source checks (omacom#16334), so the source checks this branch added there go with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…allpaper The sampler now lives beside the images it reads in Background.qml: a ShaderEffectSource copies the strip and a Canvas reads it back, because Context2D.drawImage on an Image item reloads its source URL at full size rather than reusing the decoded texture. The image is a transition's incoming frame, or else the still, so the colour flips as the reveal starts. The bar no longer queues a request in the background plugin. It waits for settledBackground, which names the current wallpaper once the first screen has decoded it (or at once for a video), and samples then; a hidden panel or a video answers "" and the helper decodes the file as before. That removes the request queue, the 3 s timeout, the url matching and the callLater ordering: the bar re-reads the state when its 120 ms debounce fires, so a transient binding value can cost an extra sample but not a wrong one. A grab issued while the output is asleep simply waits for the next frame. The strip is a plain average. Alpha weighting only mattered for transparent wallpapers, where a plain average is closer to what the screen shows anyway; and the software-renderer check guarded a backend the live shell does not use. The source-text checks go, as quattro removed them elsewhere, and so do the --sample cases that pass without the flag. A live check samples a real still through the plugin instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…weight the strip by alpha A still that fails to decode never produced an image, and recovery keeps the same path when it still exists, so settledBackground stayed empty and the bar waited for ever without turning transparent. A failed image now settles at once and answers without a sample, so the helper falls back to the text colour as before. A grab issued just before a theme intro suspends the background can be lost with the hidden window, and nothing asked again. The bar now refreshes when the background's suspension changes. A plain RGB average gave nearly transparent pixels full weight, reading a wallpaper that shows dark as light. Weighting by alpha averages what the screen shows over the dark behind the background layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: muse-spark-1.3-contributor via pi, thinking high <noreply@pi.dev>
|
Thanks @dt-lindberg — the core idea here is right: the shell has already decoded the wallpaper, so the bar should read its strip from that copy rather than decoding the file again. The maintainer asked for this to be made ready and as simple as it can be, so I merged What changed and why
Net diff against What was checked, on a worker built from the Omarchy ISO
Second opinion: Codex Medium and muse-spark-1.3 (via pi, thinking high), over two rounds. Round 1 found three real problems, all fixed above: a corrupt wallpaper left the bar waiting for ever, a grab lost to a theme intro was never retried, and the plain average gave near-transparent pixels full weight. One claim was dismissed after checking the Qt source: a visible sliver from the off-screen sampler at fractional scale. Round 2 found nothing further; independence from this review isn't guaranteed. Still open: a refresh that arrives while the helper is running is still dropped, which #14148 fixes separately. Multi-monitor samples the first screen, as before. I also updated the description to match the code as it now stands. Waiting on the maintainer. |
|
Thanks @dt-lindberg — sampling the image the shell has already decoded is a neat idea, and this branch taught us something real about the transparent bar. We're closing it anyway, because measured on a stock install it doesn't buy enough to carry the extra machinery. On an Omarchy ISO worker, the time from Measured by Claude Opus 5.5 on a worker; the simplified branch was reviewed by Codex Medium and muse-spark (high), and the decision to close is the maintainer's. |
Addresses #14167. With a transparent bar, every wallpaper or theme change ran
omarchy-bar-text-color, which decoded the whole wallpaper again in ImageMagick just to average the strip under the bar. The shell has already decoded that image to display it, so this reads the strip back from the shell's copy instead, and ImageMagick is left for the cases where the shell has nothing to read.How it works
Background.qmlexposessampleBarStrip(position, barSize, callback)andsettledBackground. The image sampled is whichever decoded image shows the current wallpaper on the first screen: a transition's incoming frame, else the still, so the colour flips as the reveal starts. AShaderEffectSourcecopies just the strip and aCanvasreads its pixels, becauseContext2D.drawImageon anImageitem reloads its URL at full size rather than reusing the decoded texture. The average is weighted by alpha, which is what a transparent wallpaper shows over the dark behind the background layer. It answers""behind a video, for an image that failed to decode, and while a theme intro hides the background.Bar.qmlsamples whensettledBackgroundnames the wallpaper (it is empty while the image is still decoding) and passes the result as--sample. On"", or without the built-in background plugin (or a clone of it from before this change), it runs the command as before. It samples again whensettledBackgroundor the background's suspension changes.omarchy-bar-text-color --sample #rrggbbskips ImageMagick and only makes the contrast choice, so the decision rule stays in one place. The bounded ImageMagick path from Bound wallpaper resource use when sampling bar colors #14281 is unchanged insidesample_background.Measured
On a worker built from the Omarchy ISO (1280×800 virtio), from
omarchy-theme-bg-setto the bar's answer across five stock Tokyo Night wallpapers: 263–509 ms with one--samplecall each, against 214–785 ms onquattro, which spends a full ImageMagick decode every time. Most of what remains is the decode the shell does anyway, plus the bar's existing 120 ms debounce.Known limits
Original work by @dt-lindberg; simplified and merged with
quattroby omarchybot.