Skip to content

perf(composition): Thread damage clip as bounds, not paths (6.8) - #24788

Merged
agneszitte merged 3 commits into
servicing/6.8from
dev/mazi/68-scroll-damage-rects
Oct 2, 2026
Merged

agneszitte merged 3 commits into
servicing/6.8from
dev/mazi/68-scroll-damage-rects

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #23984

PR Type:

🐞 Bugfix (performance regression)

What changed? 🚀

#24612 backported part of #23986 to 6.8. Scroll frames still ran path booleans for every visual, because the clip was threaded through the render walk as an SKPath:

  • Visual.Render intersected each visual's accumulated clip with SKPath.Op.
  • Under a rounded ancestor clip (every Fluent Button), the clip isn't a rect. Each moved visual's damage then went through a stroke outset, a path intersect and a DamageRegion.Union path boolean.

Damage only uses clip bounds, so this threads a root-space SKRect through the walk and has TryGetPaintDamageRegion contribute rects only. It ports the intent of master's 74afcfc and dbb62a5 to the SKPath-based compositor on this branch. The rect is always a superset of the exact region, so damage can only widen, never miss.

The old exact branch also stored each visual's content path; that field is dropped. Clip caching from #24230 was measured too and is under 3% of the frame here, so it isn't part of this fix. The mergify backports of #24230 (#24697/#24698) were closed.

Measurements 📊

ItemsRepeater + UniformGridLayout, 2,837 Fluent Button tiles, ChangeView in 60 steps of 40 px, repeated 12 times. Skia Win32 at 250%. dotnet-trace dotnet-sampled-thread-time on the UI thread:

UI-thread render UI-thread total
6.5.237 (reference) 157 ms 839 ms
6.8 head, before 2374 ms 3913 ms
6.8 head, this PR 338 ms 1756 ms

Managed allocation is unchanged (~1.1 MB per 60 steps, no Gen0 GCs); this is CPU only. The remaining gap is mostly Win32 accessibility (#24784, separate PR) and layout.

PR Checklist ✅

Validation

  • Runtime (Skia Win32, local): Given_Visual_Damage 3/3, including the new When_Visual_Moves_Under_Rounded_Clip_Then_Old_And_New_Areas_Are_Damaged. A composition/Border/ScrollViewer/ItemsRepeater/RenderTargetBitmap sweep passed apart from 4 Given_ScrollViewer layout asserts that fail only at non-100% display scale (175 vs 175.2); those are pre-existing and unrelated.
  • Compile: Uno.UI.Composition.Skia built without UnoFastDevBuild, so analyzers ran.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AzHtsXz33DcziPre7h3b9f

MartinZikmund and others added 2 commits September 28, 2026 13:52
Every visual on every scroll frame intersected its accumulated clip as an
SKPath, and under a rounded ancestor clip (any Fluent Button) its damage
contribution went through an exact path region: a stroke outset, a path
intersect and a DamageRegion.Union boolean. Damage only needs bounds, so
thread a root-space rect through the render walk and contribute rects,
matching master (74afcfc, dbb62a5). The rect is a superset of the
exact region, so this only widens damage.

ItemsRepeater grid of 2837 Fluent Buttons, 12 x 60 scroll steps, UI-thread
render time: 2374 ms -> 338 ms (6.5.237: 157 ms).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AzHtsXz33DcziPre7h3b9f
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 48s —— View job


Review complete

  • Gather context (PR diff, changed files, AGENTS.md rules)
  • Review Visual.Damage.skia.cs changes
  • Review Visual.skia.cs changes
  • Review new runtime test in Given_Visual_Damage.cs
  • Post inline findings
  • Post summary

Verdict: fix-first — the rect-based damage refactor itself is correct and well-reasoned (bounds-of-bounds under an affine transform is always a conservative superset, so the "damage only widens" invariant holds through preClip/postClip/TryGetPaintDamageRegion); one cleanup gap should be closed before merge.

Findings by severity:

  • Medium (1): ShapeVisual.Paint/BorderVisual.Paint still build and return an SKPath via BuildOwnContentPath() that nothing consumes anymore — dead computation on the exact hot path (per-visual, per-repaint) this PR is designed to shrink. Flagged inline on Visual.skia.cs:538.
  • Low/nit (1): the new regression test could carry a [GitHubWorkItem] link to Scroll frames pay O(realized visuals) Skia path booleans for damage #23984 for traceability. Flagged inline on the test file.

Cross-cutting notes:

  • Verified DamageRegion.Union(SKPath) is not dead code post-refactor — it's still exercised via CompositionTarget.Rendering.skia.cs's cross-frame carried damage and ICompositionTarget.AddDamage(SKPath), unrelated to this PR's per-visual walk.
  • The _pathPool removal in Visual.skia.cs/Visual.Damage.skia.cs is clean — no leaked/imbalanced allocate-free pairs, and remaining _pathPool users elsewhere in the file are untouched and still needed.
  • No behavior change for shadowed visuals: the removed "exact path" branch was already gated off (ShadowState is null) in the old code, so TryGetLocalContentBounds's shadow-silhouette path is unaffected.
  • New test's assertions (vacated/newly-covered/untouched corner) line up correctly with DamageRegion's rect-fusion heuristic — the two 44×44 rects here are far apart, so they don't get fused into one bounding box and the "untouched corner" assertion holds.
  • Could not run a full local build/runtime-test pass in this environment (no crosstargeting_override.props, sandboxed git fetch); assessment is by code inspection only, cross-checked against every remaining caller of the touched members in src/.
    · branch

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235990 did not find any UI Test snapshots differences.

Visual no longer consumes the path returned by Paint(), so ShapeVisual and
BorderVisual were building it for nothing on every repaint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G7PsEU6gSpLZXrYuK8WWpt
Copilot AI balanced review requested due to automatic review settings October 2, 2026 05:48
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 36s —— View job


Review complete

  • Gather context (PR diff since last review, AGENTS.md rules)
  • Check whether prior findings were addressed
  • Review new/changed commits since last review
  • Post inline findings (none — see below)
  • Post summary

Verdict: ship — commit de97f1d4 ("Drop unused own-content path building") cleanly resolves both points raised in the earlier review pass:

  • Medium finding resolved: ShapeVisual.Paint/BorderVisual.Paint no longer call the now-dead BuildOwnContentPath(); both now return null (matching SpriteVisual.Paint/RedirectVisual.Paint). BuildOwnContentPath() and the _ownContentPathBuffer fields (plus their now-stale doc comments) were deleted from both files. Confirmed no remaining references to BuildOwnContentPath, _ownContentPathBuffer, or _ownContentPath anywhere under src/Uno.UI.Composition/.
  • Low/nit resolved: When_Visual_Moves_Under_Rounded_Clip_Then_Old_And_New_Areas_Are_Damaged now carries [GitHubWorkItem("https://github.com/unoplatform/uno/issues/23984")], consistent with the convention used elsewhere in Given_ContainerVisual.cs/Given_ExpressionAnimation.cs, with the matching using SamplesApp.UITests; added.

No new issues found in this incremental change — it's a pure deletion of now-unreachable code plus a one-line test annotation, nothing else was touched. No inline comments were needed this pass.
· branch

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Core repaint-region semantics can cause subtle visual artifacts and warrant final rendering-focused human review.

Review effort: Balanced
Findings: None

What changed in this PR

Optimizes Skia compositor damage tracking on 6.8 by replacing per-visual path operations with conservative rectangle bounds.

Changes:

  • Threads root-space SKRect clip bounds through rendering.
  • Removes cached exact content paths and accumulates rectangular damage.
  • Tests movement beneath a rounded clip.

Review findings: No specific issues identified.

File Description
Given_Visual_Damage.cs Adds rounded-clip movement coverage.
Visual.skia.cs Propagates clip bounds instead of paths.
Visual.Damage.skia.cs Calculates rect-only damage regions.
ShapeVisual.skia.cs Removes exact content-path construction.
BorderVisual.skia.cs Removes exact content-path construction.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 236899 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 236899 has failed on Uno.UI - CI.

@mergify

mergify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@agneszitte
agneszitte merged commit 5253057 into servicing/6.8 Oct 2, 2026
44 of 45 checks passed
@agneszitte
agneszitte deleted the dev/mazi/68-scroll-damage-rects branch October 2, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants