Repository navigation
perf(composition): Backport scroll-frame damage cost to 6.8 - #24612
Merged
Merged
Conversation
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]>
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24612/wasm-skia-net9/index.html |
ajpinedam
approved these changes
Sep 23, 2026
agneszitte
enabled auto-merge
September 23, 2026 16:46
agneszitte
disabled auto-merge
September 23, 2026 17:20
Contributor
|
The build 235295 did not find any UI Test snapshots differences. |
ramezgerges
enabled auto-merge
September 23, 2026 17:21
This was referenced Sep 23, 2026
2 of 5 tasks
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: #23984
PR Type:
🐞 Bugfix
What changed? 🚀
Backport of the scroll-frame damage work to
servicing/6.8, cherry-picked from the same two commits as #24582.6.8is in the same pre-fix state as6.7: noDamageRegion, nopreferBoundshint,SkiaSharpVersionat3.119.0.A frame's damage region was accumulated as an
SKPath, and every contribution went throughSKPath.Op(SKPathOp.Union)— a full path boolean. With ~111 realized visuals, oneItemsRepeaterscroll frame paid ~222 of them.perf(composition): Make scroll-frame damage cheaper for moved visuals— a visual that only moved, with unchanged content, reports its bounds instead of building and transforming a content path.TryGetPaintDamageRegiontakes apreferBoundshint and skips the analytic path when local bounds are available.perf(composition): Accumulate frame damage as rectangles— introducesDamageRegion, which holds the frame's damage as a bounded list of rectangles and materialises anSKPathonly once per frame, inSnapshotAndReset, when the renderer needs one. Unioning becomes rect arithmetic: a contribution grows the open rect when that costs no extra area, otherwise closes it and opens a new one, collapsing to overall bounds past a rect cap.SKPath? damagebecomesDamageRegion? damagethroughCompositor,Visual,PaintingSession,Visual.Damage,SkiaRenderHelperandCompositionTarget.Rendering;DamageRegionExtensions.skia.csis superseded and removed.This mirrors what is already on
master. No SkiaSharp bump is required — the only 4.x-only idiom in master's version wasSKPathBuilder, replaced here by anSKPathwithWindingfill plus a scratch path for the frame clamp.SKPath.Transform(SKMatrix, SKPath)andSKPaint.GetFillPath(SKPath, SKPath)both exist in 3.119.Both commits cherry-picked onto
servicing/6.8without conflicts.Measurements
ItemsRepeater+UniformGridLayoutin aScrollViewer, 2800 items, 60 scroll steps of 40px at 16 ms,realized=111.The measuring machine was under variable load, so rather than quote two absolute numbers the runs were interleaved in pairs (control, then backport, four times) so drift affects both arms equally:
servicing/6.8as-isCPU time over the scroll, lower is better; the backport is faster in every pair. The absolute values drift upward across the session and should not be compared against the figures in #24582, which were taken on a quieter machine.
Validation
Uno.UI.Composition.Skia,Uno.UI.SkiaandSamplesApp.Skia.Generic(net10.0) build clean on this branch.Given_Visual_Damagepasses 2/2 on Skia Desktop (When_Ancestor_Clip_Grows_Then_Revealed_Region_Is_Damaged,When_Clip_Shape_Changes_Within_Same_Bounds_Then_It_Is_Damaged). The fixture was adapted to the new type using the sameSnapshotDamagehelpermasteruses.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code