Skip to content

fix(skia): Bound SKCanvasVisual damage by its size (6.7) - #24793

Merged
agneszitte merged 3 commits into
release/stable/6.7from
dev/mazi/67-skcanvas-damage-bounds
Nov 3, 2026
Merged

agneszitte merged 3 commits into
release/stable/6.7from
dev/mazi/67-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: 10/10 (the new test was shown to fail without the fix on 6.8, where the code is identical).
  • 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 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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


Code Review

  • Gather context and read changed files
  • Review SKCanvasVisual.skia.cs fix
  • Review Given_Visual_Damage.cs tests
  • Post inline comments for findings
  • Update summary

Summary

Verdict: LGTM with minor suggestions — no blocking issues.

Fix (SKCanvasVisual.skia.cs) — correct and well-motivated. Paint already clips the canvas to new SKRect(0, 0, Size.X, Size.Y), so declaring PaintsWithinOwnSize => true is semantically accurate. The damage subsystem then uses Size as the upper bound instead of falling back to the window clip, which is exactly the right fix. The comment is clear without over-explaining. The backport rationale (master's SKCanvasVisual inherits BorderVisual which already declares the property) is correct per the codebase.

Test (Given_Visual_Damage.cs) — the new When_SKCanvasVisual_Repaints_Then_Damage_Stays_Within_Its_Bounds test correctly:

  • renders two frames (first to warm the compositor, second after Invalidate)
  • asserts the damage covers the visual's footprint
  • asserts the damage doesn't blow out to a full-window repaint

Findings (2 low-severity suggestions, both inline):

# Severity Finding
1 Low Missing [GitHubWorkItem("https://github.com/unoplatform/uno/issues/24790")] on the new test — runtime-tests.md convention for issue traceability
2 Low No Assert.IsFalse(damage.IsEmpty, …) guard before SnapshotDamage — ambiguous failure message if no damage is reported at all

Neither finding is a correctness issue; the fix is sound and the test validates the right invariant.

@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Sep 28, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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


Code Review

  • Read changed files
  • Check if prior suggestions were addressed
  • Review for new issues
  • Post inline comments
  • Update summary

Summary

Verdict: LGTM with minor suggestions — the new commit (49cdbb33) correctly suppresses the flaky app-launch integration test with a clear explanation; no new issues introduced.

Prior suggestions (2 low-severity, both re-posted as inline comments):

The two suggestions from the previous review pass are still unaddressed:

# File Line Finding
1 Given_Visual_Damage.cs 141 Missing [GitHubWorkItem("…/issues/24790")] — runtime-tests.md convention for issue traceability
2 Given_Visual_Damage.cs 167 No Assert.IsFalse(damage.IsEmpty, …) before SnapshotDamage — ambiguous failure message if no damage is reported at all

Neither is a correctness issue; the fix and core test logic are sound. The [Ignore] addition in RealAppLaunchIntegrationTests.cs is well-motivated and correctly attributed.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@MartinZikmund

Copy link
Copy Markdown
Member Author

@agneszitte merge this one please

@mergify

mergify Bot commented Sep 29, 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.

MartinZikmund and others added 3 commits October 3, 2026 10:49
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
Uno.Templates@*-* now resolves to 7.0.0-dev.17, so MyApp is built on
7.0 packages and the locally built 6.x RemoteControl client never
connects. Mirrors the master ignore (37dc650).

Refs #24800

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014RHVD5sbb5nMHzf8Lu24gZ
Copilot AI balanced review requested due to automatic review settings October 3, 2026 08:49
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/67-skcanvas-damage-bounds branch from 49cdbb3 to 95cd9b9 Compare October 3, 2026 08:49

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Improves Skia compositor damage tracking for SKCanvasVisual so repaints are bounded to the visual’s size (avoiding full-window redraws), and adds a runtime test covering the regression.

Changes:

  • Declare SKCanvasVisual.PaintsWithinOwnSize => true to allow damage tracking to clamp to Size.
  • Add a Skia-specific runtime test asserting invalidation damage remains within the canvas bounds.
  • Disable a RemoteControl dev server integration test due to template/package version mismatch.
File Description
src/​Uno.UI/​Graphics/​SKCanvasVisual.skia.cs Flags SKCanvasVisual as painting within its own size to improve damage region bounding.
src/​Uno.UI.RuntimeTests/​Tests/​Windows_UI_Composition/​Given_Visual_Damage.cs Adds regression test validating bounded damage for SKCanvasVisual invalidations under Skia.
src/​Uno.UI.RemoteControl.DevServer.Tests/​AppLaunch/​RealAppLaunchIntegrationTests.cs Ignores an integration test due to Uno.Templates scaffolding against incompatible packages.

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

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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


Code Review

  • Read changed files
  • Check if prior suggestions were addressed
  • Review for new issues
  • Post inline comments
  • Update summary

Summary

Verdict: LGTM with minor suggestions — no new issues introduced; the two low-severity suggestions from prior review passes are still unaddressed.

Fix (SKCanvasVisual.skia.cs) — correct and complete. Paint already clips to new SKRect(0, 0, Size.X, Size.Y), so PaintsWithinOwnSize => true is semantically accurate. The comment is clear and concise.

Integration test ignore (RealAppLaunchIntegrationTests.cs) — the [Ignore] is well-justified: on the 6.7 branch, Uno.Templates@*-* resolves to 7.0 prereleases, so the scaffolded app targets packages the locally-built 6.x RemoteControl client can't connect to. The comment and message both say this clearly.

Persistent suggestions (2 low-severity, re-posted as inline comments):

# File Line Finding
1 Given_Visual_Damage.cs 141 Missing [GitHubWorkItem("…/issues/24790")] — runtime-tests.md convention for issue traceability
2 Given_Visual_Damage.cs 167 No Assert.IsFalse(damage.IsEmpty, …) before SnapshotDamage — ambiguous failure if no damage is reported at all

Neither is a correctness issue; the fix is sound and the test validates the right invariant.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund MartinZikmund added the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Oct 3, 2026
@nventive-devops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

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

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: SKCanvasVisual's Paint clips to its own Size (ClipRect(0, 0, Size)), so declaring PaintsWithinOwnSize => true is correct. The PR's claim that master is unaffected holds on GitHub master (0599dad): there SKCanvasVisual derives from BorderVisual, and BorderVisual.skia.cs declares PaintsWithinOwnSize => true. Note that the local uno checkout is stale. There SKCanvasVisual still derives from SKCanvasVisualBase, so I checked GitHub master for this.

Findings:

  1. Undisclosed test disable (blocking for merge as written). src/Uno.UI.RemoteControl.DevServer.Tests/AppLaunch/RealAppLaunchIntegrationTests.cs gets the same [Ignore] as #24787. It is not mentioned in the PR body. Please move it to its own PR or disclose the reason and re-enable condition.
  2. Weakened test versus 6.8 (#24792). The 6.8 test asserts Left >= 10 and Top >= 10 as well as Right <= 70 and Bottom <= 70. The 6.7 version drops the lower bounds without explanation. The upper-bound check still catches the full-window repaint, but please restore the lower bounds unless 6.7 damage legitimately extends above or left of the canvas, in which case say why.

Validation: code review and master comparison only. I did not build or run tests. The PR body reports 10/10 on the 6.8 code, which is identical in SKCanvasVisual.skia.cs, not on this branch.

@agneszitte

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@agneszitte
agneszitte disabled auto-merge November 3, 2026 06:56
@agneszitte
agneszitte merged commit 0ad13cc into release/stable/6.7 Nov 3, 2026
49 of 67 checks passed
@agneszitte
agneszitte deleted the dev/mazi/67-skcanvas-damage-bounds branch November 3, 2026 06:56
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 ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants