Skip to content

perf(composition): Walk shapes by index on the frame path (backport #24231) - #25751

Merged
agneszitte merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24231
Oct 27, 2026
Merged

agneszitte merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24231

Conversation

@mergify

@mergify mergify Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #24222

PR Type:

🔄 Refactoring (no functional changes, no api changes)

What changed? 🚀

RequiresRepaintOnEveryFrame, DamageRegionSamplingMargin and CanPaint() are queried once per shape element per frame, and each was a LINQ chain — so every frame allocated a collection enumerator, one or two iterators and a closure per shape visual. BorderVisual already implements the equivalent members as plain expressions.

Walk the collection by index instead. DamageRegionSamplingMargin keeps a seen flag so DefaultIfEmpty(0f) semantics are preserved exactly: 0 is returned when there is no sprite shape at all, rather than clamping a set of margins up to 0, which a naive Max starting from 0 would do.

Measured impact 📊

Workload Metric Before After Δ
render.full-paint alloc / frame 381,830 B 271,826 B −28.8 %
render.full-paint alloc / element / frame 244.6 B 174.1 B −28.8 %
render.full-paint time / frame 70.08 ms 69.28 ms −1.1 % (noise)

Same 1,561-element rounded tree, paint only, 5 runs each, median. Allocation figures vary by <5 B across runs. Measured on a tree that already has the RectangleClip cache applied.

Validation ✅

Same suite as the clip-path PR (Given_Border, Given_ContainerVisual, Given_ShapeVisual, Given_Visual_Damage, Given_UIElement, Windows_UI_Xaml_Shapes.*): 671 run, 654 passed, 16 failed, set-compared against a baseline build — 0 new failures, 0 newly passing.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — n/a, no API or behaviour change for app authors
  • 🖼️ Validated PR Screenshots Compare Test Run results. — to check once CI has run
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

This is an automatic backport of pull request #24231 done by [Mergify](https://mergify.com).

RequiresRepaintOnEveryFrame, DamageRegionSamplingMargin and CanPaint are
queried once per shape element per frame, and each was a LINQ chain, so
every frame allocated a collection enumerator, one or two iterators and a
closure per shape visual. BorderVisual already implements the same two
members as plain expressions.

Walk the collection by index instead. DamageRegionSamplingMargin keeps a
`seen` flag so DefaultIfEmpty(0f) semantics are preserved exactly: 0 is
returned when there is no sprite shape at all, rather than clamping a set
of margins up to 0.

Measured on the same 1561-element rounded tree
(specs/059-performance-improvements): paint allocations drop from 382 KB
to 272 KB per frame (-29%), and to -48% cumulatively against the tree
before the clip-path fix. Rendering runtime tests: identical pass/fail
sets, 0 new failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015DSdL5YzLhjx8CeGXZf1Au
(cherry picked from commit b0e17dd)
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 27, 2026
@agneszitte
agneszitte merged commit ccc286b into release/stable/6.7 Oct 27, 2026
17 of 28 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-24231 branch October 27, 2026 21:42
@unodevops

Copy link
Copy Markdown
Contributor

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

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.

3 participants