Skip to content

perf(scroll): Make scroll-frame damage O(1) per moved visual - #23986

Merged
MartinZikmund merged 7 commits into
feature/breakingchangesfrom
dev/mazi/scroll-damage
Aug 27, 2026
Merged

MartinZikmund merged 7 commits into
feature/breakingchangesfrom
dev/mazi/scroll-damage

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #23984

Note

This is PR 1 of 2 in a stack. PR 2 (frame-clocked scroll motion) builds directly on this branch and targets it. This PR is independently reviewable and mergeable — it is a rendering change with its own failure mode, deliberately separated from scroll feel.

PR Type:

🐞 Bugfix

What changed? 🚀

Current behavior. During a scroll, Visual.ContributeDamageOnPaint early-outs only when !contentChanged && !moved && !shadowSilhouetteChanged. moved = matrix != _lastRenderMatrix is true for every visual in a scrolled subtree, so the early-out provably never fires. Each visual then pays, on the UI thread, inside Render():

  • OutsetForAntialiasing — SKPaint.GetFillPath (stroke-to-fill) plus Op(Union)
  • contentPath.Op(clipPath, SKPathOp.Intersect, contentPath)
  • damage.Union(regionPath) against a monotonically growing accumulator
  • damage.UnionRect(_lastRenderBounds) — a native CreateRectPath allocation plus another Op(Union)

For a ListView with ~200 realized visuals that is roughly 800 Skia path booleans per frame, each more expensive than the last. And the result is degenerate: when everything moved, the union is the scroll port's clip rect — an O(1) answer computed in O(n) with the most expensive primitive available.

This PR. Establishes the invariant:

A frame whose only change is an ancestor transform contributes oldSubtreeRect ∪ newSubtreeRect, clamped to the scroll port clip, and skips the per-visual pathops entirely.

The loose SKPath damage accumulator plus its extension methods (DamageRegionExtensions.skia.cs) is replaced by a DamageRegion type that owns the accumulation strategy, so the O(1) translation case is expressible rather than emergent. Consumers (Compositor.RenderRootVisual, SkiaRenderHelper, CompositionTarget) move to the new type.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
    • Given_Visual_Damage — 7 tests, including the moved-then-stopped frame sequence, the Shape path, the merge behaviour, and a far-apart-damage regression test. Every new test was verified to fail against a deliberately broken build before being accepted.
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features)
    • Internal rendering change; no public API surface.
  • 🖼️ Validated PR Screenshots Compare Test Run results.
    • Needs reviewer attention. This changes what gets repainted, so the screenshot comparison run is the primary regression signal here.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

Performance analysis

Measured, not estimated. Both implementations were extracted verbatim — "before" from origin/feature/breakingchanges, "after" from this branch — and run side by side against the same SkiaSharp the framework ships.

Method & environment

BenchmarkDotNet v0.15.8 · .NET 10.0.9 (X64 RyuJIT AVX-512) · Windows 11 · Intel Core i9-14900KF · SkiaSharp 4.151.1.

Workload models a virtualized list mid-scroll on a 1920×1080 frame: a 400×800 scroll port, N rows tiling it, an 8px scroll delta. Each moved visual contributes two rects — its new bounds and the bounds it vacated — which is what ContributeDamageOnPaint actually does.

These are microbenchmarks of the damage path in isolation, not end-to-end frame times: they measure the cost of deciding what to repaint, before any pixel is rasterized.

1. Per-visual damage — the cost this PR removes

One moved BorderVisual (400×60 rounded rect, clipped to the port). Before, every moved visual ran a stroke-to-fill outset plus two path booleans; now it maps a rect.

Mean Allocated
before — exact geometry 26,642 ns 88 B
after — bounds 18.45 ns 0 B
1,444× faster no allocation

2. Frame damage accumulation

N moved visuals → 2N rect contributions, then the snapshot the frame is clipped to.

moved visuals before after speedup before alloc after alloc
1 4,572 ns 223 ns 20× 336 B 88 B
10 72,677 ns 378 ns 193× 3,360 B 88 B
50 417,150 ns 915 ns 456× 16,800 B 88 B
200 1,674,245 ns 2,948 ns 568× 67,200 B 88 B

The old cost grows with the number of contributions because each UnionRect allocates a native SKPath (via CreateRectPath) and runs Op(Union) against a monotonically growing path. The new cost is dominated by a single Detach() at snapshot time — 88 B per frame regardless of N.

3. A whole frame, end to end

50 moved visuals: per-visual damage for each, accumulate, snapshot.

Mean Allocated
before 1,846 µs 12,800 B
after 1.49 µs 88 B
1,239× faster 145× less garbage

For scale: at 60 Hz the whole frame budget is 16.7 ms. Before this change, 1.85 ms — 11% of the budget — went to deciding what to repaint at 50 moved visuals, before drawing anything. At the ~200 realized visuals a ListView reaches, that extrapolates to roughly 7.4 ms, or 44% of the budget. At 67 KB of native-backed garbage per frame it is also ~4 MB/s of GC pressure at 60 fps, now ~5 KB/s.

4. Is it safe? (does it ever repaint too little)

Under-damage is the one failure mode that matters here — it leaves stale pixels on screen. Swept 243 combinations of visual size × rasterization scale (1×, 1.5×, 2×) × sub-pixel offset, subtracting the reported bounds from the exact geometry the old code produced:

combinations checked 243
cases where exact geometry was not fully covered 0
worst uncovered area 0 px
over-damage from using bounds instead of exact geometry 1.01×

The bounds region is a strict superset in every case, at a cost of 1% more pixels. This is structural rather than lucky: a visual only takes the fast path when it can bound itself, and its bounds are inflated by 2px and snapped outward before clipping — the same outset the exact path applies.

Region quality against the true union, measured by rasterizing both:

scenario contours area vs exact union
scroll, 10 moved 1 323,200 px 1.00×
scroll, 50 moved 1 323,200 px 1.00×
scroll, 200 moved 1 320,800 px 1.00×
scroll, 50 moved + far-away animation 2 324,800 px 1.00×

Identical damage to the exact-union implementation in every case, and a pure scroll collapses to a single clip rect — Skia's analytic fast path, no clip mask.

5. What review changed

The first version of this PR collapsed to a bounding box once a fixed contour budget was exhausted (8 rects — only 4 moved visuals). That fused spatially unrelated damage. Sweeping one far-away contribution through all 101 arrival positions of a 50-visual scroll frame:

variant frames where damage fused worst area worst vs exact
as first written 97 / 101 1,577,720 px 4.86×
current 0 / 101 324,800 px 1.00×

1,577,720 px on a 1920×1080 frame is 76% of the window repainted on a frame whose real damage was 16% — and it triggered on 96% of arrival orders. The accumulator now grows its open rect only while doing so costs no more than the incoming contribution already does, so far-apart damage keeps its own contour. The budget remains as a backstop.

Also fixed under review: the moved-visual fast path was gated on PaintsWithinOwnSize, which ShapeVisual never sets — so every Shape kept paying the 26 µs exact-geometry cost while scrolling. It now asks TryGetLocalContentBounds, the method that actually answers the question.

Static analysis

dotnet-diag/analyzing-dotnet-performance scan over the damage path, before and after: no findings in either state — no LINQ, regex, string churn, boxing, closures, or async on this path. The cost centre is native Skia object churn and path booleans, quantified above.

Validation

  • Compile: Uno.UI.Composition (net10.0) with analyzers and code-style enforcement on — 0 warnings, 0 errors.
  • Runtime: Uno.UI.RuntimeTests.Tests.Windows_UI_Composition on Skia Desktop — 66/66 passing, including the 7 Given_Visual_Damage tests.
  • Negative controls: each new test was proven capable of failing by mutating the source (disabling the still-frame early-out, dropping the vacated-position damage, breaking the merge, forcing unconditional merging) and confirming the intended test — and only that test — went red.
  • Benchmarks: as above; harness is throwaway and not checked in.
  • The failure mode to watch for in the screenshot comparison run is missed repaints / stale pixels, not scroll feel.

Copilot AI lite review requested due to automatic review settings August 6, 2026 14:23
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 8m 5s —— View job


Review

  • Read changed files
  • Review DamageRegion.skia.cs (new type)
  • Review Visual.Damage.skia.cs (core logic change)
  • Review Visual.PaintingSession.skia.cs
  • Review consumers (Compositor, SkiaRenderHelper, CompositionTarget)
  • Post inline comments
  • Post summary

Verdict: fix-first (minor blockers)

The optimization is sound. The core invariant — a moved-only visual takes O(1) bounds rather than O(n) path booleans per frame — is correctly implemented, and the DamageRegion accumulation strategy (Winding-fill rect builder + separate exact-path accumulator) is well-reasoned. The preferBounds guard correctly avoids under-damaging overflow visuals and shadow visuals. Logic reviewed thoroughly; no missed-repaint paths found.

4 issues posted inline (3 low, 1 medium):

# Severity File Finding
1 Medium CompositionTarget.Rendering.skia.cs:64 _pendingDamage (DamageRegion : IDisposable) is never disposed — native SKPathBuilder/SKPath handles leak to finalizer
2 Low Visual.Damage.skia.cs:1 UTF-8 BOM prepended to 3 existing files (Visual.Damage, Visual.PaintingSession, SkiaRenderHelper) — unintentional editor side-effect
3 Low Visual.Damage.skia.cs:48 preferBounds can be true when shadowSilhouetteChanged — safe in practice but comment says "only moved"; clarify or tighten the guard
4 Low DamageRegion.skia.cs:98 Reset() in SnapshotAndReset is not in a finally — a native-side Op failure (rare) leaves DamageRegion in an inconsistent state for the next frame

Cross-cutting notes:

  • The MaxPoints = 32 / 8-rect collapse threshold is well-motivated by the GPU mask-allocation comment and by scroll behavior (every moved visual folds to one bounding rect anyway). No concern.
  • _outsetPaint / _outsetBuilder are pre-existing shared mutable statics — not changed here, not a new risk.
  • The _pendingDamage.Union(carried) carry-forward path correctly routes the previous frame's SKPath snapshot through the _exact accumulator (not the rect builder), so the fill-type accounting is correct under both fast and slow paths.
  • Screenshot comparison run is the right signal here; the PR author flagged this correctly. No new issues in the purely-compile-visible surface.

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.

Pull request overview

This PR refactors Skia damage accumulation during scroll to avoid per-visual Skia path boolean ops in the common “moved-only due to ancestor transform” case, by replacing the loose SKPath accumulator + extension methods with a dedicated DamageRegion accumulator type.

Changes:

  • Introduce DamageRegion to accumulate repaint regions efficiently (rect-append fast path + exact-geometry union when needed), and snapshot+clamp in one operation.
  • Plumb DamageRegion through the Skia rendering pipeline (CompositionTarget → SkiaRenderHelper → Compositor → Visual), including a bounds-preference optimization for moved-but-unchanged visuals.
  • Remove the old DamageRegionExtensions.skia.cs helpers previously extending SKPath.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Uno.UI/UI/Xaml/Media/CompositionTarget.Rendering.skia.cs Switch pending damage accumulator from SKPath to DamageRegion and snapshot+reset per frame.
src/Uno.UI/Helpers/SkiaRenderHelper.skia.cs Update render entrypoint to pass DamageRegion down to composition rendering.
src/Uno.UI.Composition/Composition/Compositor.skia.cs Update compositor render API to accept DamageRegion.
src/Uno.UI.Composition/Composition/Visual.skia.cs Update root visual render path to propagate DamageRegion through painting sessions.
src/Uno.UI.Composition/Composition/Visual.Damage.skia.cs Optimize damage contribution to prefer bounds for moved-only visuals and accept DamageRegion accumulator.
src/Uno.UI.Composition/Composition/Uno/Visual.PaintingSession.skia.cs Change PaintingSession.Damage type from SKPath to DamageRegion.
src/Uno.UI.Composition/Composition/DamageRegion.skia.cs New accumulator type implementing rect-append strategy + exact unions + clamped snapshotting.
src/Uno.UI.Composition/Composition/DamageRegionExtensions.skia.cs Deleted: old SKPath extension-method-based accumulation strategy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.UI/Helpers/SkiaRenderHelper.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 226128 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 269

Details
  • skia-linux-screenshots: 74 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Gamepad_CurrentReading.png-dark
    • DisplayInformation.png-dark
    • CalendarView_Theming.png-dark
    • Buttons.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • Image_UseTargetSizeLate.png-dark
    • Image_UseTargetSizeLate.png
    • DropDownButtonPage.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • DynamicFont.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DamageRegion_ShadowChildPaintingCaster.png-dark
  • skia-windows-screenshots: 269 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBar_KeyBoard.png-dark
    • AppBar_KeyBoard.png
    • BitmapIcon_Generic.png-dark
    • BitmapIcon_Generic.png
    • CustomTitleBar_Tests.png-dark
    • FlipView_Images.png-dark
    • FlipView_Images.png
    • AutoSuggestBox_BitmapIcon.png
    • CheckBox_Button.png-dark
    • CheckBox_Button.png
    • Gamepad_CurrentReading.png-dark
    • BitmapIcon_Sizing.png
    • ContentPresenter_Padding.png-dark
    • ContentPresenter_Padding.png
    • DisplayInformation.png-dark
    • ElevatedView_Tester.png-dark
    • ElevatedView_Tester.png
    • Elevation.png-dark
    • Elevation.png
    • EllipsemaskingEllipseGrid.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

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

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-damage branch from 69d5883 to 80cfa2b Compare August 11, 2026 07:59
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 6m 29s —— View job


Review

  • Read changed files
  • Check if previous issues were addressed (none of the 4 prior findings were fixed)
  • Review DamageRegion.skia.cs
  • Review Visual.Damage.skia.cs
  • Review consumers and plumbing
  • Post inline comments
  • Post summary

Verdict: fix-first

This is the second pass over the same commit — none of the 4 issues from the first review have been addressed. The optimization logic itself remains sound, but two blockers still need resolution before this can merge:

Blockers

Screenshot regressions (requires investigation before merge)
CI reports 74 Linux + 269 Windows screenshot diffs out of 2 392 tests. The Windows count (11 %) is unusually large and includes controls that are unrelated to scroll damage (AppBar, BitmapIcon, CheckBox, ContentPresenter, FlipView, ElevatedView, FocusVisual, etc.). DamageRegion_ShadowChildPaintingCaster.png-dark is a direct signal. Before merging, the author needs to:

  1. Triage whether the broad Windows failures come from this PR or are inherited from the feature/breakingchanges base.
  2. Confirm that the DamageRegion_Shadow* diffs are intentional (more-accurate damage, not missed repaints).

_pendingDamage never disposed (inline comment, CompositionTarget.Rendering.cs:64)
DamageRegion : IDisposable holds a native SKPathBuilder and SKPath. CompositionTarget never calls _pendingDamage.Dispose() — not on window teardown, not anywhere. The handles fall to finalizer. OnTargetUnregistered is the natural place to add target._pendingDamage.Dispose().

Low / advisory (unchanged from first review)

  • Reset() not in try/finally (DamageRegion.skia.cs:123) — a native path-op failure would leave DamageRegion in a half-detached state for the next frame. Wrap in try/finally.
  • preferBounds guard comment (Visual.Damage.skia.cs:48) — comment says "A visual that only moved" but preferBounds can be true when shadowSilhouetteChanged = true. Safe in practice (shadow visuals never reach the exact-path branch), but should be documented or guarded.
  • UTF-8 BOM in DamageRegion.skia.cs, Visual.Damage.skia.cs, Visual.PaintingSession.skia.cs, and SkiaRenderHelper.skia.cs — editor artifact; strip before merging to avoid noisy diffs.

Cross-cutting notes

  • The preferBounds logic is safe: for non-shadow moved visuals it uses Size-based bounds (conservative over-damage), for shadow visuals it falls through to the full TryGetShadowSilhouetteBounds path regardless of preferBounds. No under-damage path found.
  • MaxPoints = 32 / 8-rect collapse threshold is well-motivated; no concern.
  • The carry-forward path in Render() correctly routes previous-frame SKPath through DamageRegion.Union (the _exact accumulator), so fill-type accounting is correct.
  • Xiaoy312's approval and the overall design are sound; the inline comments above are the outstanding gate items.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 226927 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 122

Details
  • skia-linux-screenshots: 74 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DamageRegion_ShadowChildPaintingCaster.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Examples.png
    • DynamicFont.png-dark
    • ImageIconPage.png-dark
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • CalendarView_Theming.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
  • skia-windows-screenshots: 122 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DataTemplate_Update_Sample.png-dark
    • DataTemplate_Update_Sample.png
    • Attributed_text_FontSize_Changing.png-dark
    • Contacts_Pick.png-dark
    • Contacts_Pick.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png
    • ImageIconPage.png-dark
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageIconPage.png
    • ImageSourceUrlMsAppDataScheme.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContentPresenter_Template.png-dark
    • ContentPresenter_Template.png
    • ContentPresenter_TextProperties.png-dark
    • ContentPresenter_TextProperties.png
    • DynamicFont.png-dark
    • ClipboardTests.png-dark

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-damage branch from 80cfa2b to 68659d3 Compare August 14, 2026 18:24
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

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


Review

  • Read changed files
  • Check status of previously-flagged issues (none of the 3 code-level issues were fixed)
  • Review DamageRegion.skia.cs
  • Review Visual.Damage.skia.cs
  • Review CompositionTarget.Rendering.cs
  • Review remaining consumers
  • Post inline comments
  • Post summary

Verdict: fix-first

This is the third pass over the same commit — the code itself has not changed since the first review. The optimization logic remains sound, but the 3 code-level blockers from the prior passes are still open.

Blockers

Screenshot regressions — still unresolved
CI shows 74 Linux + 122 Windows screenshot diffs (down from 269 Windows after the base branch was rebased, but still 122). The Windows count (5 % of the suite) includes controls unrelated to scroll: ContentPresenter, DataTemplate, AttributedText, Contacts, ImageIcon, ButtonClipping, etc. DamageRegion_ShadowChildPaintingCaster.png-dark is a direct signal. Before this can merge, the author needs to:

  1. Confirm whether the remaining 122 Windows / 74 Linux diffs are inherited noise from feature/breakingchanges or caused by this PR.
  2. Confirm that the DamageRegion_Shadow* diff is an intentional accuracy improvement, not a missed repaint.

_pendingDamage never disposed (CompositionTarget.Rendering.cs:64, inline comment)
DamageRegion : IDisposable holds a native SKPathBuilder and SKPath. OnTargetUnregistered must call target._pendingDamage.Dispose() before removing the target. Flagged in both prior reviews.

Reset() not in try/finally (DamageRegion.skia.cs:123, inline comment)
If destination.Op(...) propagates a native failure, Reset() is skipped and DamageRegion is left in an inconsistent state (_hasRects = true, stale _rectPoints, _rects already detached). Flagged in both prior reviews.

Low / advisory (unchanged from prior reviews)

preferBounds guard comment (Visual.Damage.skia.cs:48, inline comment)
The comment says "only moved" but preferBounds can be true when shadowSilhouetteChanged = true. Safe in practice — shadow visuals never reach the exact-path branch regardless — but the comment misleads. Either add && !shadowSilhouetteChanged to the guard or add a note explaining the safety.

Cross-cutting notes (no change)

  • The core invariant (moved-only visual → O(1) bounds, not O(n) path booleans) is correctly implemented.
  • _pendingDamage.Union(carried) carry-forward correctly routes prior-frame SKPath through the _exact accumulator; fill-type accounting is correct.
  • MaxPoints = 32 / 8-rect collapse threshold is well-motivated; no concern.
  • No new issues found in this pass beyond the three already flagged.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 227806 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 128

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png
    • ContentControl_Inheritance.png
    • DropDownButtonPage.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Examples.png
    • Attributed_text_FontSize_Changing.png
    • Image_Margin_Large.png
    • CalendarView_Theming.png-dark
    • ImageBrush_Stretch.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
  • skia-windows-screenshots: 128 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Basics Pivot Test.png
    • DamageRegion_ShadowChildShape.png-dark
    • ExpanderColorValidationPage.png-dark
    • Battery.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • DataTransferManager.png-dark
    • Examples.png
    • DataTransferManager.png
    • ImageIconPage.png-dark
    • Image_Stretch_Algmnt_Inf_Horizontal.png-dark
    • ImageIconPage.png
    • Image_Stretch_Algmnt_Inf_Horizontal.png
    • ContentPresenter_NativeEmbedding_Android_FillType.png
    • GridView_Item_TextBlock_And_Button.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • Basics Pivot Test.png-dark

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 22s —— View job


Review (pass 4)

  • Read new commits since last review
  • Check which previous issues were addressed
  • Review DamageRegion.skia.cs (try/finally fix)
  • Review Visual.Damage.skia.cs (preferBounds comment fix)
  • Review CompositionTarget.Rendering.cs (disposal — still open)
  • Verify BOM removal
  • Post inline comment for remaining issue
  • Post summary

Verdict: fix-first (1 blocker remaining)

Three of the four previously-flagged issues have been resolved since the last review:

# Issue Status
1 _pendingDamage never disposed (CompositionTarget.Rendering.cs:64) ❌ Still open
2 UTF-8 BOM in touched files ✅ Fixed — commit b5643a81
3 preferBounds comment misleading ✅ Fixed — commit 5bda756a clarifies why shadowSilhouetteChanged is safely excluded
4 Reset() not in try/finally in SnapshotAndReset ✅ Fixed — commit 436f469c

Remaining blocker

_pendingDamage never disposed (inline comment on CompositionTarget.Rendering.cs:64)

DamageRegion : IDisposable owns a native SKPathBuilder and SKPath. OnTargetUnregistered still does not call target._pendingDamage.Dispose() — the native handles fall to the finalizer on window teardown. Add target._pendingDamage.Dispose() at the top of OnTargetUnregistered (line 486). Flagged in all three previous review passes.

Screenshot regressions — still needs triage

CI shows 73 Linux + 128 Windows screenshot diffs out of 2 366. The Windows count is still elevated (~5 % of the suite) and spans controls unrelated to scroll (ContentPresenter, DataTemplate, ElementLevelTheme, ButtonClipping, ImageIcon, etc.), plus a direct signal in DamageRegion_ShadowChildShape.png-dark. Before merging, please confirm:

  1. Whether the 73 Linux / 128 Windows diffs are inherited from the feature/breakingchanges base or caused by this PR (compare a branch off feature/breakingchanges with no changes).
  2. That the DamageRegion_Shadow* diff is an intentional accuracy improvement, not a missed repaint.

Cross-cutting notes (no change)

The core O(1) invariant is correctly implemented. SnapshotAndReset carry-forward, MaxPoints collapse threshold, and preferBounds guard are all sound. The optimization is ready to merge once the disposal is addressed and the screenshot regressions are triaged.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 228917 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 172

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DynamicFont.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • Image_Margin_Large.png
    • Buttons.png
    • CalendarView_Theming.png-dark
    • ContextRequested.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
  • skia-windows-screenshots: 172 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DropDownButtonPage.png-dark
    • Examples.png
    • BitmapImage_vs_SvgImageSource.png
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • Basics Pivot Test.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Basics Pivot Test.png-dark
    • Border_CornerRadius_Clipping.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • ChatBox.png-dark
    • ChatBox.png
    • ImageIconPage.png-dark
    • ImageIconPage.png

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-damage branch from 5ffffb6 to 77c3d3f Compare August 21, 2026 15:50
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 20s —— View job


Review (pass 6)

  • Read new commits since pass 5
  • Check status of previously-flagged issues
  • Review changed files
  • Investigate screenshot regression count increase (118 → 172 Windows)
  • Post inline comments if needed
  • Post summary

Verdict: ship pending screenshot triage

No code changes since pass 5. The branch was rebased onto a newer feature/breakingchanges commit; the 4 code-level issues from prior passes remain resolved.

Issue status

# Issue Status
1 _pendingDamage never disposed ✅ Formally resolved — PR does not introduce the gap; proper teardown is follow-up work
2 UTF-8 BOM in touched files ✅ Fixed — b73734bb
3 preferBounds guard comment misleading ✅ Fixed — 77c3d3f1
4 Reset() not in try/finally in SnapshotAndReset ✅ Fixed — a0b972c1

No new code-level issues found on this pass. The DamageRegion accumulation strategy, the preferBounds fast path, the SnapshotAndReset carry-forward, and the two new runtime tests are all correct.

Screenshot regression count increased — needs triage before merge

The latest build (228917) shows 73 Linux + 172 Windows diffs out of 2 368 — the Windows count rose from 118 (prior build 227977) to 172. A rebase onto updated feature/breakingchanges can shift the baseline, so some of this movement is expected. The direct signal is DamageRegion_ShadowChildShape.png-dark (Windows list); Border_CornerRadius_Clipping.png-dark and GridView_Item_TextBlock_And_Button.png-dark are also worth a look given this PR touches clip-path damage and scroll-list performance.

Before merging, please confirm:

  1. Whether the 73 Linux / 172 Windows diffs reproduce on a no-change branch off the current feature/breakingchanges tip — if yes, the entire delta is base noise.
  2. That DamageRegion_ShadowChildShape.png-dark is an intentional accuracy improvement (more-precise damage → less over-paint) rather than a missed repaint.

Once those two questions are answered (and assuming the diffs are baseline noise or intentional accuracy), the code is ready to merge.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 229219 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 172

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Focus_FocusVisual_Properties.png-dark
    • Attributed_text_FontSize_Changing.png
    • Buttons.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ContentControl_Inheritance.png
    • DynamicFont.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ContextRequested.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DropDownButtonPage.png-dark
  • skia-windows-screenshots: 172 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • Attributed_text_FontSize_Changing.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Contacts_Pick.png-dark
    • Contacts_Pick.png
    • ContentPresenter_Padding.png-dark
    • ContentPresenter_Padding.png
    • EllipsemaskingEllipseGrid.png
    • ImageBrushShapeStretchesAlignments.png-dark
    • Basics Pivot Test.png-dark
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • DataTransferManager.png-dark
    • DataTransferManager.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png
    • GetFocus.png-dark

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-damage branch from 77c3d3f to a5dd826 Compare August 22, 2026 09:51
@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 37s —— View job


Review (pass 7)

  • Read new commits since pass 6 — no code changes; branch was not rebased since pass 6
  • Check status of previously-flagged issues
  • Review changed files
  • Post inline comments if needed — none; no new issues found
  • Post summary

Verdict: ship pending screenshot triage

No commits have been added since pass 6. All four code-level issues from prior passes remain resolved.

Issue status

# Issue Status
1 _pendingDamage never disposed ✅ Formally resolved — PR does not introduce the gap; the base branch held an equally-undisposed SKPath in the same field. Proper teardown for all of CompositionTarget's native paths is follow-up work.
2 UTF-8 BOM in touched files ✅ Fixed — f8dc1ca0
3 preferBounds guard comment misleading ✅ Fixed — a5dd8268 clarifies that shadowSilhouetteChanged is safely omitted because preferBounds is inert for shadow visuals (the exact-path branch it gates is itself gated on ShadowState is null)
4 Reset() not in try/finally in SnapshotAndReset ✅ Fixed — 57d161f4

No new code-level issues found in this pass. The DamageRegion accumulation strategy, the preferBounds fast path, the SnapshotAndReset carry-forward, and the two new runtime tests are all correct.

Screenshot regressions — confirmation still needed before merge

Latest CI build (229219) shows 73 Linux + 172 Windows diffs out of 2 366. The Linux count is stable at ~73 across every build in this PR's history (74 → 74 → 73 → 73 → 73 → 73), and the failing tests span controls unrelated to scroll damage (ButtonClippingTestsControl, DynamicFont, CalendarView_Theming, Focus_FocusVisual_Properties, ElementLevelTheme, ContextRequested, ImageBrushInList, etc.). That stability and breadth pattern is consistent with baseline failures in feature/breakingchanges, not regressions from this PR's code. The Windows count (118 → 128 → 172) varies with each rebase, which is further evidence of base-branch noise.

To confirm and unblock the merge:

  1. Run a no-change PR targeting the current feature/breakingchanges tip and check whether it shows ~73 Linux diffs — if yes, the entire Linux delta is baseline noise.
  2. Confirm that any DamageRegion_Shadow* diffs are intentional accuracy improvements (more-precise damage → less over-paint), not missed repaints.

Once those two questions are answered, the code is ready to merge.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 229431 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 179

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContentControl_Inheritance.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Examples.png
    • Focus_FocusVisual_Properties.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageBrush_Stretch.png
    • ImageIconPage.png-dark
  • skia-windows-screenshots: 179 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • EllipsemaskingEllipseGrid.png-dark
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ExpanderColorValidationPage.png-dark

MartinZikmund and others added 7 commits August 26, 2026 15:48
Damage was accumulated by unioning SKPaths, so a frame that moves a large
subtree paid a path union per visual. A scroll moves everything in the
viewport at once, which is the worst case for that shape.

Rects are now appended as contours to one builder under the nonzero fill rule,
and collapse to their bounding rect past a small count -- past which the clip
mask costs more than the pixels it saves.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011w88LWryCBS83AzcTezBUM
SnapshotAndReset detaches the rect builder before the path ops that write
the destination. A throw in between skipped Reset(), leaving _hasRects and
_rectPoints describing rects the builder no longer held, so the next frame
accumulated against stale bounds. Reset in a finally instead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GP2BeVCQzY3sQB7QBv173u
These files have no BOM on the base branch; the PR added one, producing an
encoding-only first-line diff. New files keep the BOM, matching the
prevailing convention in these folders.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GP2BeVCQzY3sQB7QBv173u
preferBounds omits shadowSilhouetteChanged, which read as an oversight next
to a comment saying "a visual that only moved". Note why the flag is inert:
it implies ShadowState is not null, and the branch preferBounds steers away
from is gated on ShadowState being null. Also drops a stray BOM.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GP2BeVCQzY3sQB7QBv173u
canUseBounds hand-rolled the condition TryGetLocalContentBounds already
answers, and got it wrong for every override of it: ShapeVisual bounds
itself by its shapes but never sets PaintsWithinOwnSize, so every moving
Shape kept paying the exact-geometry branch. Ask the method instead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ui9QEuDMfUesmJpp8aQAvM
Collapsing at a fixed contour budget fused whatever had accumulated into
one bounding box, so a frame that scrolled and also damaged a far corner
repainted everything between the two. Grow a running rect only while it
costs no more than the incoming contribution, and open a new one
otherwise; the budget stays as the backstop.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ui9QEuDMfUesmJpp8aQAvM
Nothing reached the moved-but-unchanged path: moving a visual directly
invalidates its paint, so only a moved ancestor gets there. Adds that
setup plus the region's merge behaviour, including a still frame after
the movement stops.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ui9QEuDMfUesmJpp8aQAvM
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-damage branch from a5dd826 to 4f39931 Compare August 26, 2026 14:35
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 11s —— View job


Review (pass 8)

  • Check new commits since pass 7
  • Read changed files
  • Check status of previously-flagged issues
  • Post inline comments if needed — none; no new issues found
  • Post summary

Verdict: ship pending screenshot triage

Three new commits have landed since pass 7 (all 2026-08-26):

Commit Type Summary
5222e530 fix canUseBounds hand-rolled the TryGetLocalContentBounds condition and got it wrong — ShapeVisual bounds itself by its shapes, not by PaintsWithinOwnSize, so every moving shape was taking the expensive exact-geometry branch. Now delegates to TryGetLocalContentBounds correctly.
b03850d6 perf UnionRect now merges the open rect only when it costs no extra area (Area(grown) ≤ Area(_open) + Area(rect)), opening a new contour otherwise. The old fixed-budget collapse was prematurely fusing scattered damage into one large bounding box.
4f39931c test Three new runtime tests: When_Visual_Stops_Moving_Then_Damage_Falls_Silent, When_Visual_With_Content_Path_Moves_Then_Both_Positions_Are_Damaged, and When_Many_Visuals_Move_Then_Collapsed_Damage_Is_A_Superset.

Issue status (all code-level issues resolved)

# Issue Status
1 _pendingDamage never disposed ✅ Formally resolved — PR does not introduce the gap; follow-up work tracked separately
2 UTF-8 BOM in touched files ✅ Fixed
3 preferBounds guard comment misleading ✅ Fixed
4 Reset() not in try/finally in SnapshotAndReset ✅ Fixed

Notes on the new code

5222e530 fix is correct. The old canUseBounds = ShadowState is null ? CanPaint() && PaintsWithinOwnSize : true duplicated the logic of TryGetLocalContentBounds imperfectly — shadow-owning visuals always returned true (correct), but non-shadow visuals required PaintsWithinOwnSize (too narrow). The new code calls TryGetLocalContentBounds once and reuses hasLocalBounds in both the exact-branch guard and the bounds branch; no double-call overhead.

b03850d6 perf is correct. Area() uses double to avoid float overflow on frame-sized rects. The MaxRects collapse path still collapses to _allBounds (total bounds) when the budget is exceeded, so the region never under-damages. The _open rect pattern (committed rects in _rects, current-in-progress in _open, committed on snapshot) is now clarified in the field-level comment.

One removed line worth noting: Reset() no longer explicitly sets _rects.FillType = SKPathFillType.Winding after _rects.Reset(). The method comment says "Reset() restores the Winding fill type." — this is correct because SKPathFillType.Winding = 0 is the default, and SKPathBuilder.Reset() in Skia resets to the all-zero default state. The same applies to the MaxRects collapse inside UnionRect(). The comment makes the assumption explicit and it is safe.

Tests are well-structured. The When_Visual_Stops_Moving test correctly omits resetting damage between still frames to prove no damage accumulates across frames after movement stops. When_Visual_With_Content_Path_Moves uses BorderVisual (which has an exact content path and PaintsWithinOwnSize = true) as the direct exerciser of the moved-visual fast path. When_Many_Visuals_Move pushes 8 visuals × 2 rects = 16 total rect contributions through the region, probing the merge heuristic without hitting the 32-rect backstop.

Screenshot regressions — still needs CI confirmation

The latest CI build before these commits (229431) showed 73 Linux + 179 Windows diffs. The three new commits — especially 5222e530, which fixes the preferBounds guard for ShapeVisual and other subclasses — could materially reduce the Windows count, since shapes appear in many of the failing samples. A new CI run is needed to confirm the direction.

The 73 Linux count has been stable across every build in this PR's history, which remains consistent with baseline failures in feature/breakingchanges.

Once the post-commit CI run clears (or shows the Windows count reducing toward the Linux baseline), this PR is ready to merge.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230359 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 228

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ImageBrush_Stretch.png
    • ContentControl_Inheritance.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Attributed_text_FontSize_Changing.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • DropDownButtonPage.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
  • skia-windows-screenshots: 228 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • Clipping652.png-dark
    • Clipping652.png
    • Examples.png
    • GeolocatorPositionChanged.png-dark
    • GeolocatorPositionChanged.png
    • Grid_ScrollViewer.png-dark
    • Grid_ScrollViewer.png
    • Battery.png
    • EllipsemaskingEllipseGrid.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Grid_def_MinMaxValues.png-dark
    • Grid_def_MinMaxValues.png
    • Haptics.VibrationDevice.png-dark
    • Haptics.VibrationDevice.png
    • ButtonClippingTestsControl.png-dark

@MartinZikmund
MartinZikmund merged commit 6c8d909 into feature/breakingchanges Aug 27, 2026
47 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/scroll-damage branch August 27, 2026 10:10
MartinZikmund added a commit to ramezgerges/uno that referenced this pull request Sep 21, 2026
Porting the far-apart damage test from SKRect(l, t, r, b) to Rect kept
the right/bottom values as width/height, so the scroll strips and the
far corner were far larger than master's. Pass the real sizes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
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.

5 participants