Repository navigation
fix(skia): Scope the native-element clip cache to its composition target - #24123
Conversation
|
Claude finished @MartinZikmund's task in 1m 49s —— View job Review:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a Skia multi-window correctness/concurrency issue by scoping the native-element clip path cache to each CompositionTarget (i.e. per window) instead of sharing it process-wide via static fields.
Changes:
- Convert
_lastNativeClipPathand_lastScaledNativeClipPathfromstaticto instance fields. - Expand the in-code comment to document why the cache must be per-target (cross-window corruption + potential data race on multi-threaded hosts).
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
The build 228599 found UI Test snapshots differences: Details
|
62f15a3 to
ac5d6ae
Compare
|
Claude finished @MartinZikmund's task in 2m 7s —— View job Review:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
|
The build 228903 found UI Test snapshots differences: Details
|
|
Claude finished @MartinZikmund's task in 1m 22s —— View job Review:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
|
The build 229011 found UI Test snapshots differences: Details
|
df2ea40 to
5279ba3
Compare
|
Claude finished @MartinZikmund's task in 1m 6s —— View job Review:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
5279ba3 to
7431e66
Compare
|
Claude finished @MartinZikmund's task in 3m 0s —— View job Review:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
|
|
|
The build 229480 found UI Test snapshots differences: Details
|
7431e66 to
de46291
Compare
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
|
The build 231000 found UI Test snapshots differences: Details
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
|
The build 231684 found UI Test snapshots differences: Details
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Code review assessment: both path caches are keyed/invalidated by per-composition-target size, scale, and frame state, so instance ownership is the correct fix for cross-window interference and concurrent access. The two existing size/scale fields were already instance fields. No blocking issue found; repeated comment-wording nits do not invalidate the ownership correction. This is an Uno/Skia cache implementation detail, not a literal WinUI SKPath port.
_lastNativeClipPath and _lastScaledNativeClipPath are static, but everything
about them is per-composition-target — i.e. per window:
- they are invalidated by a per-target event (a canvas recreation at
CompositionTarget.Rendering.skia.cs:304 nulls the scaled path),
- they are keyed on this target's own frame
(_lastNativeClipPath != lastRenderedFrame.nativeElementClipPath at :348),
- and their immediate neighbours, _lastCanvasSize and _lastRasterizationScale,
are already instance fields under the same comment.
So with more than one window open the two targets discard and overwrite each
other's cache every frame, and the scaled path handed to the native layer can
belong to the wrong window. On the hosts that render each window on its own
thread it is also a plain data race on the SKPath: one thread can be at
`_lastScaledNativeClipPath = new()` (:350) while another transforms into it
(:354) or returns it (:359).
Making them instance fields is a no-op for a single window — one target means one
cache either way — which is why this has gone unnoticed.
Build 228903 was green on 17 of 18 runtime-test jobs, including macOS and
Linux framebuffer. The single failure was
Given_InputInjector.When_MouseMove_PointerEventsAreRaised on WinAppSDK
("PointerMoved should have been raised", 3ms) — a mouse-injection test running
against native WinUI, which cannot be reached by a change to a *.skia.cs file.
Re-running to clear it.
de46291 to
a1500aa
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
|
Claude finished @MartinZikmund's task in 1m 47s —— View job Review:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24123/wasm-skia-net9/index.html |
|
The build 237219 found UI Test snapshots differences: Details
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Claude finished @MartinZikmund's task in 18s —— View job Review:
|
Addressed PR comments up to this pointAll 6 open bot threads were the same comment nit ("All four cache ..."). Reworded in 00ae09e (comment-only, no code change); threads resolved. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245154 found UI Test snapshots differences: Details
|

GitHub Issue: closes #24122
PR Type:
🐞 Bugfix
What changed? 🚀
_lastNativeClipPathand_lastScaledNativeClipPathinCompositionTarget.Rendering.skia.csarestatic, but everything about them is per-composition-target — i.e. per window::304);_lastNativeClipPath != lastRenderedFrame.nativeElementClipPath(:348);_lastCanvasSizeand_lastRasterizationScale, are already instance fields.So with more than one window open the two targets discard and overwrite each other's cache every frame, and the scaled path handed to the native clipping layer at
:359can belong to the wrong window. On the hosts that render each window on its own thread (Win32, X11, and macOS once #23594 lands) it is additionally a plain data race on theSKPath: one thread can be at_lastScaledNativeClipPath = new()(:350) while another transforms into it (:354) or returns it (:359).This change makes both fields instance fields. Three lines, plus a comment recording why they must not be static.
PR Checklist ✅
Screenshots Compare Test Runresults. — pending CI.Testing
Why there is no automated test. The defect is only observable with two windows each hosting native elements with different clip geometry, and the corrupted value is a private
SKPathconsumed by platform-native clipping (uno_window_clip_svgon macOS). There is no managed surface to assert against, and the race is timing-dependent. A test here would be an expensive approximation that does not actually pin the invariant; the field scope itself is the invariant.What was verified. Local A/B on the same machine, same 480-test slice (
UITEST_RUNTIME_TEST_GROUP=0,COUNT=20), macOS Skia:static)Identical outcomes; the difference is run-to-run noise. That is the expected result and is itself the safety argument: with a single window there is one composition target, so instance and
staticare behaviourally identical. The change can only differ where the bug is — two or more windows.The single failure (
Given_ResourceLoader.When_MissingLocalizedResource_FallbackOnDefault) is pre-existing and present on both sides.Compiles clean for Skia desktop (
SamplesApp.Skia.Generic, net10.0).🤖 Generated with Claude Code
https://claude.ai/code/session_01K297hJpRGEufnFFqS7pZh9