Repository navigation
fix(web): draw replayed canvases pixel for pixel in nested scroll zoom - #631
Merged
Merged
Conversation
Chrome filters a canvas through nested scale transforms even when they add up to one pixel per pixel, so a bitmap replayed at the exact screen scale still showed grey edges in TestNestedZoomedCanvasIsSharp once CI's browser ran at a real device scale factor of 2 (--force-device-scale-factor). The bitmap itself was right: 1800 × 1800 pixels for 900 CSS pixels at a ratio of 2. A canvas inside zoomed contents now uses image-rendering: pixelated while its bitmap matches the screen exactly, and returns to smooth sampling as soon as a zoom changes, until the next replay.
Collaborator
Author
|
Reviewed. CI is green apart from apple-simulator, which fails in TestSimulatorProcessResults on the simulator boot timeout every PR hits right now; #634 raises that limit. The |
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main's Test job has failed since fd6adf5, and every PR rebased onto it fails the same way:
Cause
#607 (sharp canvases under scroll zoom) and #610 (gallery and CI) each passed CI alone. #610's b1e0e82 starts the test browser with
--force-device-scale-factor=2, so the browser now really composes at a device scale of 2 instead of only emulating it. Bisected on the Linux build host: b1c710a passes, b1e0e82 fails.The replayed bitmap is right: in the zoom-3 case the canvas is 1800 × 1800 pixels for 900 CSS pixels at a ratio of 2, with no fractional offsets anywhere up the tree. The grey comes from Chrome filtering the canvas through the nested
scale()transforms even when they add up to one pixel per pixel. Withimage-rendering: pixelatedthe same capture is sharp.Fix
A canvas inside zoomed scroll contents is drawn with
image-rendering: pixelatedwhile its replayed bitmap is exactly as large as the screen shows it. A zoom puts those canvases back to smooth sampling right away, so CSS scaling during a pinch or animation still looks smooth, until the 120 ms replay sets them again. A canvas whose zoom is past the raster cap, or whose size at that scale is fractional, keeps smooth sampling. Canvases outside zoomed scroll views are not touched.docs/architecture/canvas.mdsays so.Verification
On the Linux build host (headless Chrome, as in CI):
go test -run TestWebCanvasScrollZoom ./cmd/nsgo: fails on main with the error above, passes with this change (pixels 4/4, lifecycle 4/4).go tool nsgo test -target web ./internal/platform/web: 17 passed, 1 skipped.GOOS=js GOARCH=wasm go vet ./internal/platform/webpasses.Not checked on a real high-DPI browser outside headless Chrome.