Skip to content

fix(webgpu): Address the review of the native-host overhead work - #26698

Open
ramezgerges wants to merge 6 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-atlas-upload-followups
Open

ramezgerges wants to merge 6 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-atlas-upload-followups

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: related to #26564

PR Type:

🐞 Bugfix

What changed? 🚀

Follow-up to #26565, addressing the points of its review, one commit each (2 to 4 share one).

  1. Keyless masks no longer count against the mask cache's pages. A shared page now holds keyless masks or keyed entries, never both. The cache's 8-page ceiling only counts its own pages, so a clip-heavy UI can no longer leave glyphs and fills with no room, and short-lived masks no longer use shelf space on pages long-lived glyphs keep from emptying.
  2. Writes that bypass the batch stay in order. A write of 1 MiB or more, or one that isn't a multiple of 4, first submits the copies pending ahead of it, so an earlier batched write to the same range can't land after it.
  3. Flush and submit are atomic. The per-queue lock is held from the flush through the native submit.
  4. Queue references are counted. Through wgpuDeviceGetQueue, wgpuQueueReference and wgpuQueueRelease: batching ends with the last reference, and its pending writes are submitted rather than dropped.
  5. Pooled buffers use quarter-octave size classes above 64 KB. A recording's 520 KB arena now holds 640 KB instead of 1 MB; over-allocation is at most about a quarter. I didn't take a before/after memory figure.
  6. The partial-repaint cull has tests. Unit tests for CullOccluded (made internal, with InternalsVisibleTo for Uno.UI.UnitTests, as Uno.UI.Composition does): a background under another and an op outside the damage are culled, an op reaching into the damage by a fraction is kept, and a full repaint culls only what is fully covered.
  7. DrawOp's summary is back on DrawOp.
  8. A page that can't be created skips its mask instead of throwing mid-frame. A fill takes no route, a cached clip mask falls back to the per-frame one, a shadow keeps drawing from its shared sheet, and a clip with no mask hides what it clips rather than drawing it unclipped.

The note about a failing write now failing the whole upload command buffer is in the header of SilkCompat.Uploads.cs.

The Skia screenshot differences on #26565 (446 Linux, 501 Windows) were higher than the 203–303 of other PRs at the time. Its branch was a week behind master, which is the likely cause, since those runs use the Skia renderer. This PR's run will show whether that holds.

Validation

  • Compile: Uno.UI.Composition.WebGpu and Uno.UI.Composition.WebGpu.Init build with analyzers on.
  • Unit tests: the 5 new Given_WebGpuOcclusionCull tests pass. With the bounded-pass cull from perf(webgpu): Cut per-frame CPU work on native hosts #26565 turned off, the 4 partial-repaint ones fail and the full-repaint one still passes.
  • Runtime, Skia desktop with the WebGPU renderer on llvmpipe (Vulkan): a rendering subset (composition conformance, effects, clips, sprite shapes, container and border visuals, Given_Path*, Given_Ellipse, Given_Border, Given_TextBlock, Given_AcrylicBrush, Given_UIElement): 776 tests, 775 passed, 0 failed, 1 inconclusive.
  • Not exercised at runtime: the paths for a texture that can't be created (point 8) and a direct write landing on a queue with copies pending (point 2). Neither occurs in a normal run.

PR Checklist ✅

🤖 Generated with Claude Code

ramezgerges and others added 6 commits November 24, 2026 12:52
A shared page now holds keyless masks or keyed entries, never both. The cache's 8-page ceiling counted the pages keyless masks opened too, so a clip-heavy UI could leave glyphs and fills with no room and evicting every frame; and short-lived masks used shelf space on pages that long-lived glyphs keep from ever emptying.

Addresses review point 1 of unoplatform#26565.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A write that bypasses the arena (1 MiB or more, or not a multiple of 4) first submits the copies pending ahead of it, so an earlier batched write to the same range cannot land after it.
- The per-queue lock is held from the flush through the native submit, so another thread's submit cannot run ahead of the copies carrying its data.
- Queue references are counted through wgpuDeviceGetQueue, wgpuQueueReference and wgpuQueueRelease: batching ends with the last reference, and its pending writes are submitted rather than dropped.
- The file header notes that a failing write now fails the whole upload command buffer.

Addresses review points 2 to 4 of unoplatform#26565.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Above 64 KB the buffer pool now uses four size classes per doubling instead of powers of two. A recording holds its vertex buffers for its lifetime, so a 520 KB arena held 1 MB; it now holds 640 KB. Classes still recur, so a returned buffer still serves the next request of its class.

Addresses review point 5 of unoplatform#26565.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
StandalonePage returned a page or threw mid-frame. It now returns null when no texture can be created (out of GPU memory, or a lost device), and each caller skips the mask: a fill takes no route, a cached clip mask falls back to the per-frame one, a shadow keeps drawing from its shared sheet, and a clip with no mask hides what it clips rather than drawing it unclipped.

Addresses review point 8 of unoplatform#26565.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Unit tests for CullOccluded, made internal: a background under another and an op outside the damage are culled, an op reaching into the damage by a fraction is kept, and a full repaint culls only what is fully covered. The four partial-repaint tests fail without the bounded-pass cull.

Addresses review point 6 of unoplatform#26565.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Addresses review point 7 of unoplatform#26565.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Nov 24, 2026
@mergify

mergify Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248899 found UI Test snapshots differences: skia-linux-screenshots: 218, skia-windows-screenshots: 274

Details
  • skia-linux-screenshots: 218 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Accessibility_Showcase.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • Buttons.png-dark
    • Buttons.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark
    • Basics.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • Accessibility_Showcase.png-dark
  • skia-windows-screenshots: 274 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • Accessibility_Showcase.png-dark
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Basics.png-dark
    • Basics.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants