Skip to content

perf(composition): Backport scroll-frame damage cost to 6.7 - #24582

Merged
agneszitte merged 2 commits into
release/stable/6.7from
backport/6.7/scroll-damage-perf
Sep 24, 2026
Merged

agneszitte merged 2 commits into
release/stable/6.7from
backport/6.7/scroll-damage-perf

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #23984

PR Type:

🐞 Bugfix

What changed? 🚀

Backport of the scroll-frame damage work to release/stable/6.7. 6.7 regressed against earlier releases on scroll-heavy content: a frame's damage region was accumulated as an SKPath and every contribution went through SKPath.Op(SKPathOp.Union), a full path boolean. With ~111 realized visuals an ItemsRepeater scroll frame paid ~222 of them.

Two commits:

perf(composition): Make scroll-frame damage cheaper for moved visuals — a visual that only moved, with unchanged content, now reports its bounds instead of building and transforming a content path. TryGetPaintDamageRegion takes a preferBounds hint and skips the analytic path when local bounds are available.

perf(composition): Accumulate frame damage as rectangles — introduces DamageRegion, which keeps the frame's damage as a bounded list of rectangles and only materialises an SKPath once per frame, in SnapshotAndReset, when the renderer needs one. Unioning is now rect arithmetic: a contribution either grows the open rect when that costs no extra area, or closes it and opens a new one, collapsing to overall bounds past a rect cap. SKPath? damage becomes DamageRegion? damage through Compositor, Visual, PaintingSession, Visual.Damage, SkiaRenderHelper and CompositionTarget.Rendering; DamageRegionExtensions.skia.cs is superseded and removed.

This mirrors what is already on master. No SkiaSharp bump is needed — SkiaSharpVersion stays at 3.119.0. The only 4.x-only idiom in master's version was SKPathBuilder, replaced here by an SKPath with Winding fill plus a scratch path for the frame clamp; SKPath.Transform(SKMatrix, SKPath) and SKPaint.GetFillPath(SKPath, SKPath) both exist in 3.119.

Measurements

ItemsRepeater + UniformGridLayout in a ScrollViewer, 2800 items, 60 scroll steps of 40px at 16 ms, realized=111. Same machine, same harness, two runs per configuration:

Build CPU (ms) Wall (ms)
6.7.103 ~2875 —
6.7 + first commit only 2250, 1891 2375, 2159
6.7 + both commits 1391, 1547 1748, 1699
master as-is, for reference ~1727 —

The first commit alone recovers roughly a third of the gap; DamageRegion accounts for the rest and brings 6.7 to parity with master.

Validation

  • Compile — Uno.UI.Composition.Skia, Uno.UI.Skia and SamplesApp.Skia.Generic (net10.0) build clean.
  • Runtime — Given_Visual_Damage passes (2/2) on Skia Desktop: When_Ancestor_Clip_Grows_Then_Revealed_Region_Is_Damaged and When_Clip_Shape_Changes_Within_Same_Bounds_Then_It_Is_Damaged. The fixture was adapted to the new type, using the same SnapshotDamage helper master uses.
  • The scroll harness above was run against both configurations.

PR Checklist ✅

🤖 Generated with Claude Code

ramezgerges and others added 2 commits September 21, 2026 13:07
Backport of the preferBounds guard from master.

ContributeDamageOnPaint only early-outs when nothing changed, and during a
scroll every visual in the scrolled subtree has moved, so the early-out never
fires. Each visual then paid the expensive branch of TryGetPaintDamageRegion on
the UI thread - a stroke-to-fill outset plus two path booleans - and the cost
scaled with the number of realized visuals, which is exactly the long
content-rich list users notice.

A visual that only moved is damaged at its old location too, and that one is
only ever a rect, so computing exact geometry for the new location buys nothing.
Take the bounds branch instead, but only when bounds can actually answer for the
visual: falling through to the clip would report a far larger region than the
exact path it replaced. TryGetLocalContentBounds is asked directly rather than
hand-rolling the condition, since its overrides disagree with the obvious guess
(ShapeVisual bounds itself by its shapes without setting PaintsWithinOwnSize).

Deliberately excludes the SkiaSharp 4 idioms and the DamageRegion type that
landed alongside this on master: 6.7 is on SkiaSharp 3, and neither is needed
for the fix.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The per-visual damage union ran SKPath.Op(Union) for every contribution,
which is a full path boolean. At ~111 realized visuals a scroll frame paid
~222 of them. DamageRegion keeps the region as a bounded list of rects and
only materialises an SKPath once per frame, when the renderer needs one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Sep 21, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

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

@ramezgerges

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

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

@ajpinedam

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@mergify mergify Bot added the queued label Sep 23, 2026
@agneszitte agneszitte added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2026
@mergify mergify Bot added dequeued and removed queued labels Sep 23, 2026
@agneszitte agneszitte removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dequeued labels Sep 24, 2026
@agneszitte
agneszitte merged commit fa6f4f8 into release/stable/6.7 Sep 24, 2026
48 checks passed
@agneszitte
agneszitte deleted the backport/6.7/scroll-damage-perf branch September 24, 2026 14:36
@mergify mergify Bot added the dequeued label Sep 24, 2026
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 dequeued

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants