Repository navigation
perf(wasm): Cheaper record phase for WebGPU and Skia - #26053
Conversation
Recording spent ~44% of its time in Concat: every visual's offset went through a full Matrix4x4 product, scalar under the WASM interpreter. A 2D translation now only updates the translation row. The save stack is also pooled per thread instead of regrowing on every recording. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu2pLwNk6UenehZFfNA
Visual culling transforms a rect per visual per frame, mostly by plain offsets. A translation now shifts the rect directly, with the same float rounding as the four-corner path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu2pLwNk6UenehZFfNA
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNu2pLwNk6UenehZFfNA
|
Claude finished @MartinZikmund's task in 28s —— View job Review of #26053: cheaper record phase for WebGPU and SkiaVerdict: ship. I found no blocking issues. 0 high, 0 medium and 2 nits. This was a review by inspection only. I did not build or run the tests. What I checked
Nits
Cross-cutting
|
There was a problem hiding this comment.
🟡 Changes recommended
The stack pool is bypassed by per-visual and shadow recordings because sessions finish before disposal, causing continued allocations and requiring lifecycle fixes and pooling test coverage.
1 open issue
What changed in this PR
This PR addresses #26047 by reducing matrix-processing and allocation costs during Uno’s WebAssembly recording phase, targeting WebGPU recording and rectangle transforms used across rendering backends.
Changes:
- Adds translation fast paths for WebGPU matrix composition and rectangle transforms.
- Introduces lazy, thread-local pooling of WebGPU save stacks.
- Adds matrix-equivalence and recorder-lifecycle tests.
| File | Description |
|---|---|
src/Uno.WinRT/Extensions/Matrix3x2Extensions.cs |
Adds a rectangle translation fast path that preserves float rounding. |
src/Uno.UI.UnitTests/Uno.UI.UnitTests.csproj |
References WebGPU composition for recorder tests. |
src/Uno.UI.UnitTests/Extensions/Given_Matrix3x2Extensions.cs |
Tests exact equivalence with corner-based rectangle transforms. |
src/Uno.UI.UnitTests/CompositionTests/Given_WebGpuCommandRecorder.cs |
Tests matrix composition and pooled-stack lifecycle behavior. |
src/Uno.UI.Composition.WebGpu/WebGpuCommandRecorder.cs |
Optimizes translations and introduces save-stack pooling. |
Review effort: Balanced
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243709 found UI Test snapshots differences: Details
|
The paint and shadow recordings finished with their save still open, so the WebGPU recorder never returned their stacks to the pool. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNty3tQcrabJckBifzTY
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNty3tQcrabJckBifzTY
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TXMNty3tQcrabJckBifzTY
|
Claude finished @MartinZikmund's task in 21s —— View job Review of #26053 (after the latest push)Verdict: ship. 0 high, 0 medium, 0 low. I reviewed by inspection only. I did not build or run the tests. Copilot's pooling comment is resolved.
The save stack is therefore empty by the time Float-equality alerts from github-code-quality. I would dismiss these. The exact Cross-cutting
|
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243897 found UI Test snapshots differences: Details
|

GitHub Issue: closes #26047
PR Type:
✨ Feature (performance)
What changed? 🚀
The WASM record phase was dominated by matrix work that is mostly plain 2D translations:
WebGpuCommandRecorder.Concatdid a fullMatrix4x4multiply for every visual, ~44% of WebGPU recording. A 2D translation now only updates the translation row, with the same result. The save stack is rented from a per-thread pool. It's rented lazily and returned only when empty, becauseWebGpuPresentSessioncallsFinish()mid-session and keeps drawing. Before, a fresh stack regrew on every recording.Matrix3x2Extensions.Transform(Rect)(visual culling, every visual, every frame, all backends) now shifts the rect directly for a translation, instead of transforming four corners and taking their bounds. It applies only to rects with non-negative size, and the float rounding matches the corner walk bit for bit.Measured on SamplesApp
RealWorld_SpotlightMenu, interpreter build,mastervs this branch:Validation:
Uno.UI.UnitTests. The newGiven_WebGpuCommandRecorder(5) andGiven_Matrix3x2Extensionstests pass. The full suite has 12 failures, all in theWhen_Gregorian_FixedDate*calendar tests, which depend on time zone and locale and are unrelated. The SamplesApp was run on the WebGPU and WebGL backends, on desktop Chrome and on a Pixel Tablet.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_01TXMNu2pLwNk6UenehZFfNA