Skip to content

fix(skia): Bound SKCanvasVisual damage by its size (6.8) - #24792

Merged
agneszitte merged 3 commits into
servicing/6.8from
dev/mazi/68-skcanvas-damage-bounds
Oct 7, 2026
Merged

agneszitte merged 3 commits into
servicing/6.8from
dev/mazi/68-skcanvas-damage-bounds

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24790

PR Type:

🐞 Bugfix (performance)

What changed? 🚀

SKCanvasVisual clips its drawing to its Size but didn't declare PaintsWithinOwnSize. So damage tracking couldn't bound it and fell back to the visual's whole clip, which is the window. SKCanvasElement repaints every frame for Lottie, so any running ProgressRing, AnimatedIcon or AnimatedVisualPlayer made every frame a full-window repaint, defeating damage regions entirely.

This PR declares PaintsWithinOwnSize => true. Master is unaffected: its SKCanvasVisual derives from BorderVisual, which already declares it.

Measurements 📊

Static grid of Fluent Buttons plus one 60×60 ProgressRing, Skia Win32 at 250%:

  • DamageRegionOverlay: the whole window was damaged every frame before this PR; with it, only the ring's box is.
  • Process CPU per 3 s: ~3.3 s → ~1.4 s (6.5.237: ~0.6–0.7 s). Measured on a loaded machine, so the numbers are noisy but the direction held on every run.

The remaining gap against 6.5 is tracked for the rendering owner in #24791.

PR Checklist ✅

Validation

  • Runtime (Skia Win32, local): Given_Visual_Damage + Given_ProgressRing + Given_AnimatedVisualPlayer + Given_AnimatedIcon + Given_SKCanvasElement + the rest of Windows_UI_Composition: 65/65. The new test fails without the fix (damage spills over the whole root) and passes with it.
  • Compile: Uno.UI.Skia built without UnoFastDevBuild (6.8), so analyzers ran.

🤖 Generated with Claude Code

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 56s —— View job


Review complete ✅

  • Gather context (diff vs origin/servicing/6.8)
  • Review SKCanvasVisual.skia.cs change
  • Review Given_Visual_Damage.cs test
  • Post inline findings (if any)
  • Post summary

Verdict: Ship. No issues found — no inline comments posted.

Findings by severity: 0 blocking, 0 non-blocking.

Why this holds up:

  • The fix is a single boolean flag (PaintsWithinOwnSize => true) that exactly matches the clip SKCanvasVisual.Paint() already applies (ClipRect(0, 0, Size.X, Size.Y)), so the damage-bounding contract in Visual.skia.cs/Visual.Damage.skia.cs is satisfied truthfully — this isn't a bound that happens to work, it's a declaration of an invariant the code already enforces.
  • It mirrors the existing pattern used by BorderVisual, SpriteVisual, and TextVisual, so it's consistent with the rest of the composition layer rather than a one-off special case.
  • Given_Visual_Damage.cs's new test (When_SKCanvasVisual_Repaints_Then_Damage_Stays_Within_Its_Bounds) is a genuine red/green regression test: it asserts both that the repaint is damaged and that the damage doesn't spill past the visual's bounds (with reasonable antialiasing slack), which is exactly the invariant this PR restores. It's properly gated with [Ignore] off-Skia and follows the Given_/When_ runtime-test conventions.
  • No cross-cutting concerns: change is scoped to Skia (.skia.cs), doesn't touch DPs, events, or public API, and doesn't affect native/WASM targets (master's BorderVisual-derived version is unaffected, confirmed by PR description and code inspection).

Validation performed: Code review only (read SKCanvasVisual.skia.cs, SKCanvasVisualBase.cs, Visual.skia.cs, Visual.Damage.skia.cs, and the new test) — did not re-run the runtime tests locally; relying on the PR description's reported 65/65 pass and fail-before/pass-after evidence.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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


Review complete

  • Gather context (diff vs origin/servicing/6.8)
  • Review SKCanvasVisual.skia.cs change
  • Review Given_Visual_Damage.cs test
  • Review RealAppLaunchIntegrationTests.cs change
  • Post inline findings
  • Post summary

Verdict: fix-first — the core Skia fix is correct and well-tested; one moderate finding on scope/root-cause, one minor test-strengthening nit.

Findings by severity: 1 moderate (non-blocking, but should be tracked), 1 minor/nit. 0 blocking.

Cross-cutting notes (not tied to a single line):

  • The core change (internal override bool PaintsWithinOwnSize => true; in SKCanvasVisual.skia.cs) is correct and root-cause: it declares an invariant (Paint() already clips to Size) that the damage-bounding machinery in Visual.Damage.skia.cs/Visual.skia.cs was already designed to consume, and it mirrors the existing SpriteVisual/BorderVisual/TextVisual pattern rather than introducing a new mechanism.
  • Given_Visual_Damage.cs's new test is a genuine fail-before/pass-after regression test, correctly gated off non-Skia targets and following this file's existing Given_/When_ and #if __SKIA__ conventions.
  • The RealAppLaunchIntegrationTests.cs change is unrelated to the Skia fix and disables (rather than fixes) coverage for the real DevServer app-launch connection path — see inline comment for the root cause and a pointer to the actual fix.
  • No DependencyProperty, event, or cross-platform-suffix concerns; no new event Action/.Result/GetAwaiter().GetResult() usage introduced.

Validation performed: Code review only (diff inspection + reading SKCanvasVisual.skia.cs, SKCanvasVisualBase.cs, Visual.skia.cs, Visual.Damage.skia.cs, SolutionHelper.cs, and both test files). Did not re-run the runtime or integration test suites locally; relying on the PR description's reported 65/65 pass and fail-before/pass-after evidence for the Skia fix.
· branch dev/mazi/68-skcanvas-damage-bounds

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

Copilot AI balanced review requested due to automatic review settings October 2, 2026 05:41
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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


Review complete

  • Gather context (diff vs origin/servicing/6.8, re-reviewed latest commit)
  • Review latest commit since previous rounds (17d3e4c2 test: Bound SKCanvasVisual damage on left and top too)
  • Check whether prior findings were addressed
  • Post inline findings (if any)
  • Post summary

Verdict: Ship (with one previously-flagged item still outstanding, non-blocking for this fix).

Findings by severity: 0 new, 0 blocking. No new inline comments posted — latest commit is a pure test strengthening with no issues.

What changed since the last review round:

  • Given_Visual_Damage.cs's When_SKCanvasVisual_Repaints_Then_Damage_Stays_Within_Its_Bounds now also asserts reported.Bounds.Left >= 10 && reported.Bounds.Top >= 10, in addition to the existing Right <= 70 / Bottom <= 70. This directly resolves the earlier minor nit (the assertion previously only bounded the trailing edges, so a regression to a full-root-clip fallback anchored at the origin wouldn't have been caught). The added bounds use the same slack convention as the rest of the file and as the pre-existing Right/Bottom checks, so the test is now symmetric and will fail-before/pass-after on a left/top-side regression too.
  • No other files changed in this commit; the core fix (SKCanvasVisual.skia.cs: PaintsWithinOwnSize => true) is untouched and remains correct per the prior reviews.

Cross-cutting note (previously flagged, still outstanding, not reintroduced here):

  • RealAppLaunchIntegrationTests.cs still [Ignore]s WhenRealAppBuiltAndRunWithDevServer_RealConnectionEstablished rather than fixing the root cause (SolutionHelper.cs's hardcoded Uno.Templates@*-* resolving to 7.0 prereleases on this 6.8 servicing branch). This was already raised as an inline comment in an earlier review round and is unchanged, so no duplicate comment was posted — flagging it again here only so it isn't lost: it's scope creep bundled into a Skia-titled PR and silently drops CI coverage for the real DevServer↔app-launch connection path on servicing/6.8. Worth tracking/splitting into its own issue rather than leaving it parked behind [Ignore] indefinitely.

Validation performed: Code review only (diff vs merge-base, full file reads of SKCanvasVisual.skia.cs, Given_Visual_Damage.cs, RealAppLaunchIntegrationTests.cs). Did not re-run the runtime or integration test suites locally; relying on the PR description's reported 65/65 pass and fail-before/pass-after evidence.
· branch dev/mazi/68-skcanvas-damage-bounds

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

🟡 Changes recommended

The unrelated DevServer integration test should be fixed through compatible template pinning rather than disabled.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Bounds SKCanvasVisual damage to its size, preventing full-window repaints during small Skia animations.

Changes:

  • Declares size-bounded painting.
  • Adds damage-region regression coverage.
  • Disables a DevServer integration test due to template incompatibility.

Review result: 1 blocking issue.

File Description
SKCanvasVisual.skia.cs Declares bounded painting.
Given_Visual_Damage.cs Tests bounded canvas damage.
RealAppLaunchIntegrationTests.cs Ignores an incompatible integration test.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

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

MartinZikmund and others added 3 commits October 3, 2026 11:26
SKCanvasVisual clips its drawing to Size but did not declare
PaintsWithinOwnSize, so the damage code fell back to the visual's whole
clip. SKCanvasElement repaints every frame for Lottie, so any running
ProgressRing, AnimatedIcon or AnimatedVisualPlayer damaged the entire
window on every frame and defeated partial repaint. Master is unaffected:
its SKCanvasVisual derives from BorderVisual.

Static grid with one spinning ProgressRing, damage overlay: whole window
-> the ring's box. Process CPU per 3 s: ~3.3 s -> ~1.4 s (6.5: ~0.7 s).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AzHtsXz33DcziPre7h3b9f
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/68-skcanvas-damage-bounds branch from 17d3e4c to b0079f3 Compare October 3, 2026 09:27
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 27s —— View job


Review complete

  • Gather context (diff vs origin/servicing/6.8)
  • Review SKCanvasVisual.skia.cs change
  • Review Given_Visual_Damage.cs test change
  • Review against AGENTS.md rules (SOLID, async discipline, platform suffixes, DP correctness, root-cause, allocations, test coverage, XAML, release cleanliness, code style, commits, events)
  • Post inline findings (if any)
  • Post summary

Verdict: Ship. 0 blocking, 0 non-blocking findings — no inline comments posted.

Current diff vs origin/servicing/6.8: exactly the 2 files / +44/-0 described in the PR body (SKCanvasVisual.skia.cs +4, Given_Visual_Damage.cs +40). The branch already contains servicing/6.8's HEAD (630ab44d), so the merge @agneszitte asked for is done: Given_Visual_Damage.cs now has both this PR's test and #24788's When_Visual_Moves_Under_Rounded_Clip_Then_Old_And_New_Areas_Are_Damaged back-to-back, and the RealAppLaunchIntegrationTests.cs [Ignore] that drew three review threads in earlier rounds is no longer part of this diff — it's inherited unchanged from base (#24801), so those threads are moot now.

Why it holds up:

  • internal override bool PaintsWithinOwnSize => true; declares an invariant Paint() already enforces (ClipRect(0, 0, Size.X, Size.Y) before invoking RenderCallback), verified against the actual consumers of the flag in Visual.skia.cs:887 (shadow-silhouette skip) and Visual.Damage.skia.cs:125 (damage bounding) — this is a true root-cause fix, not a bound that happens to work.
  • It's the same declaration already used by SpriteVisual, BorderVisual, and TextVisual (all .skia.cs), so it's consistent with the established pattern rather than a one-off.
  • The new test constructs a 40×40 SKCanvasVisual at offset (20,20) in a 200×200 root, invalidates it, and asserts the second frame's damage both covers the canvas center and stays within [10,70]×[10,70] — generous slack over the real [20,60] bounds for antialiasing bleed, but far short of the full 200×200 window a regression to the old fallback would produce. The bound is now symmetric on all four edges (the earlier left/top gap was closed in b0079f3d), and per-platform skip follows this file's existing #if !__SKIA__ / [Ignore] convention used by its sibling tests.
  • Commits are Conventional-Commits compliant (fix(skia), test(skia), test).

Cross-cutting notes: none outstanding. The RealAppLaunchIntegrationTests.cs template-pinning concern raised in earlier rounds is a real issue but is no longer scoped to this PR's diff (inherited from base), and multiple reviewers already agreed it should be tracked as its own follow-up rather than block this fix.

Validation performed: Code review only (diff vs origin/servicing/6.8, full reads of SKCanvasVisual.skia.cs, SKCanvasVisualBase.cs, Visual.skia.cs, Visual.Damage.skia.cs, and Given_Visual_Damage.cs). Did not re-run the runtime test suite locally; relying on the PR description's reported 65/65 pass and the independently-confirmed fail-before/pass-after result from @agneszitte's local merge check.
· branch dev/mazi/68-skcanvas-damage-bounds

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@mergify

mergify Bot commented Oct 7, 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 06d268c into servicing/6.8 Oct 7, 2026
42 of 43 checks passed
@agneszitte
agneszitte deleted the dev/mazi/68-skcanvas-damage-bounds branch October 7, 2026 14:27
agneszitte added a commit to unoplatform/uno.templates that referenced this pull request Oct 7, 2026
Head of servicing/6.8 (06d268c): adds the SKCanvasVisual damage fix
(unoplatform/uno#24792) on top of the #24786 / #24788 perf fixes and
#24806. Updater files aligned in the same commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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