Skip to content

Skip unchanged renders for rebuilt animation declarations - #1710

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 10 commits into
mainfrom
azchohfi-animation-extras-rerender-skip
Nov 26, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 10 commits into
mainfrom
azchohfi-animation-extras-rerender-skip

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 460c392d9f407c70479080bd387b70e38b233a8c

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ CI is green on this head: 47 checks, including the solution build, selftests, packaged and AOT selftests, and coverage.
↑ Mutation checks of transition settings, brush color, keyframe owner retargeting (direct and child-skip paths), the setting refresh and the poll fallback each fail a new test.
↑ Six Copilot review rounds. Every finding was fixed or answered, and the last round had no open issues.
↓ The real settings notification can't be raised in a test, and the pre-19041 poll can't run on these machines. Both are covered by structural tests plus selftests that drive their handlers directly.
↓ The local stress benchmark was too noisy to resolve. An A/A run with identical code also flagged a regression.
Diagnosis confidence 9.5/10 ↑ A unit test with two identical, separately built .Keyframes()/.ScrollLinked() elements failed on unchanged code.
Evidence fit 9/10 ↑ The issue describes exactly this mechanism, and the repro matches its steps.
↓ The issue came from static review, so there's no field report of the cost.

Summary

Since #1552, the skip check compares all animation declarations together with record equality. .Keyframes(), .ScrollLinked(), the implicit transitions (.OpacityTransition() and friends), .WithTransitions() and .InteractionStates() rebuild arrays and WinUI objects on every render, and those compared by reference. So an unchanged element using any of them never skipped. With .ScrollLinked(), every parent render also restarted the scroll expressions.

These declarations now compare by value:

  • keyframe definitions and arrays
  • scroll expressions, when the ScrollViewer is the same
  • implicit transition duration, plus axes for scale and translation
  • theme transition settings, per WinUI type, including navigation transition infos
  • solid brushes, by color and opacity

The animation group stays compiler-generated, so a new field is still compared automatically. A changed or removed declaration still updates, so #1536 stays fixed.

Two follow-on fixes came from equal elements now skipping:

  • Keyframe channel owners. Each owner records the keyframe array its layer applied, by reference, so a decorator and the child sharing its control stay distinct. Each skip arm now moves the owner to the skipped element's new array. Before, a later removal could miss the deferred modifier reset and leave the element stuck at the loop's value.
  • "Animation effects" setting. TransitionEngine subscribes to the change notification once per process, and each notification refreshes every Reactor host through the theme resource listeners. That covers windows and ReactorHostControl alike, whether or not the app uses charts. Windows builds before 10 2004 have no notification, so there each root pass polls the setting and refreshes every host when it moved. Before, an unchanged element kept implicit transitions installed under the old setting.

ShallowEquals now compares animations after the element's own properties. An element that changed anyway skips the WinUI property reads.

Linked issue / spec

Fixes #1702. Follow-up to #1536 / #1552, spec 014.

Test plan

  • New unit test reproduced the bug first: two identical .Keyframes()/.ScrollLinked() elements weren't shallow-equal on unchanged code. Unit tests also cover each hand-compared field.
  • New selftests Animate_RebuiltExtrasSkip and Animate_RebuiltExtrasChildSkip cover the direct and child-skip paths. Checks:
    • rebuilt equal transitions, theme transitions, brushes, keyframes and scroll configs skip
    • each changed setting still updates
    • scroll expressions restart only on a real update
    • the setting notification and the poll fallback refresh implicit transitions
  • ModifierTransform_Transitions adds an equal-render step on the direct and child-diff skip paths, covering the deferred scale reset.
  • ReducedMotionSubscriptionTests pins the TransitionEngine subscription and its capability guard, and the root-pass poll behind the missing-capability guard.
  • Mutation checks: each of these fails a new check.
    • ignoring transition settings
    • treating solid brushes as always equal
    • a no-op owner retarget
    • a plain render in place of the setting refresh
    • a poll that never refreshes
  • dotnet test tests/Reactor.Tests: 16,398 passed, 0 failed.
  • Selftests: full corpus 0 failures on an earlier head. On the final head, the Animate_ and ModifierTransform_Transitions filters have 0 failures.
  • Release builds of tests/Reactor.AppTests.Host and tests/Reactor.Tests (with src/Reactor): 0 errors.
  • Docs: animation topic recompiled. API index unchanged, since the overrides keep the synthesized signatures.
  • CI on this head: all checks green, including the solution build, selftests, packaged and AOT selftests.

Perf, Release build, interleaved with the merge base. Time per reconcile of 300 unchanged rows:

Scenario Before (ms) After (ms)
.OpacityTransition() 3.68 0.19
All implicit transitions 6.31 0.75
.WithTransitions() 21.9 0.34
.InteractionStates() brush 2.11 0.33
.Keyframes() 2.70 0.11
.ScrollLinked() 26.9 0.11
Plain elements 0.049 0.055

An equal compare costs up to about 1.5µs per element, from the WinUI reads. Elements whose own props changed don't pay it. The local stress harness flagged a Renders/sec drop, but an A/A run of identical code flagged a similar one, so that machine can't resolve it. /perf here will give a reliable number.

Risk / breaking changes

  • No API signature changes. Public Equals on ImplicitTransitions, ThemeTransitions, InteractionStateValues, KeyframeAnimationDef and ScrollAnimationConfig now compares by value instead of by reference.
  • The first three read WinUI properties, so they need the UI thread that created those objects. That's documented on each override. The reconciler always runs there.
  • A changed "Animation effects" setting now triggers a full refresh pass in every host, the same pass a theme resource change uses. The setting changes rarely, so the cost is acceptable. Before Windows 10 2004, each root pass also reads the setting once.

Since #1552 the shallow skip compares AnimationExtras with record equality, and
.Keyframes(), .ScrollLinked(), implicit transitions, .WithTransitions() and
.InteractionStates() rebuild arrays and WinUI objects on every render, so an
unchanged element using them never skipped. .ScrollLinked() also restarted its
expressions on every parent render.

The declarations now compare by value: keyframe definitions and arrays,
scroll expressions with the same ScrollViewer, implicit transition durations
and components, theme transition settings per WinUI type, and solid brushes by
color. AnimationExtras stays compiler-generated, so a new field is still
compared. A changed or removed declaration still updates (#1536).

ShallowEquals compares animations after the element's own properties, so an
element that changed anyway doesn't pay for the WinUI reads. An update that
leaves .ScrollLinked() unchanged no longer restarts its expressions unless the
element declares another animation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Restart scroll expressions on every non-skipped update again. A modifier
  write on the same channel can replace one, and the value-equality skip
  already avoids the restarts the issue reported.
- Compare keyframe channel owner scopes by sequence, so a skipped equal render
  doesn't block the deferred modifier reset.
- Refresh every element when the "Animation effects" setting changes, since
  implicit transitions apply that gate and equal elements now skip.
- Compare navigation transition infos by type and setting.
- Move brush equality to BrushHelper, and note the UI-thread requirement on
  the public Equals overrides.
- Cover each hand-compared field, and fix the docs and CHANGELOG wording.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azchohfi Alexandre Zollinger Chohfi (azchohfi) added the agent-preparing Agent is addressing feedback or completing required validation and CI label Nov 25, 2026
…tras-rerender-skip

# Conflicts:
#	CHANGELOG.md
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for 85222b7 vs the base branch (c3bf429).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 2.14 MB 2.14 MB +3.54 KB (+0.16%) ⚠️
Microsoft.UI.Reactor.Advanced.nupkg 530.0 KB 530.0 KB -8 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 287.8 KB 287.8 KB -10 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Microsoft.UI.Reactor.dll 2.90 MB 2.90 MB +4.00 KB (+0.13%) ⚠️
Reactor.Analyzers.dll 444.5 KB 444.5 KB +0 B (0.00%) ≈
Reactor.Localization.Generator.dll 16.0 KB 16.0 KB +0 B (0.00%) ≈
Reactor.Wrappers.Abstractions.dll 10.5 KB 10.5 KB +0 B (0.00%) ≈
Reactor.Wrappers.Generator.dll 164.0 KB 164.0 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Advanced

Artifact base PR Δ
Microsoft.UI.Reactor.Advanced.dll 1.08 MB 1.08 MB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Devtools

Artifact base PR Δ
Microsoft.UI.Reactor.Devtools.dll 787.5 KB 787.5 KB +0 B (0.00%) ≈

✅ smaller / ⚠️ larger / ≈ within noise. Sizes come from a Release dotnet pack on the CI runner: packages are the compressed .nupkg download size, assemblies the uncompressed DLL inside it.
workflow run.

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.

🟡 Changes recommended

Active issues leave implicit-animation resources stale when palette notifications arrive first or animation-setting notifications are missed by chart-free windows and embedded hosts.

2 open issues
What changed in this PR

This PR addresses #1702 by comparing rebuilt animation declarations by value, allowing Reactor to skip unchanged elements while preserving updates for changed or removed settings.

Changes:

  • Adds value equality for keyframes, scroll expressions, transitions, and interaction-state brushes.
  • Adjusts keyframe ownership checks and requests a full refresh when animation settings change.
  • Adds regression coverage and updates animation documentation.
File Description
tests/​Reactor.Tests/​Core/​ReducedMotionSubscriptionTests.cs Targets the extracted animation-settings handler.
tests/​Reactor.Tests/​AnimationExtrasEqualityTests.cs Tests rebuilt declarations and changed values.
tests/​Reactor.AppTests.Host/​SelfTest/​SelfTestFixtureRegistry.cs Registers two animation skip fixtures.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​TransformModifierFixtures.cs Tests keyframe cleanup after skipped renders.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​AnimateModifierTests.cs Tests native equality, skips, and settings refresh.
src/​Reactor/​Hosting/​ReactorHost.cs Requests refreshes on animation-setting changes.
src/​Reactor/​Elements/​BrushHelper.cs Centralizes solid-brush value comparison.
src/​Reactor/​Core/​Reconciler.cs Updates keyframe ownership matching and adds scroll instrumentation.
src/​Reactor/​Core/​Element.cs Integrates value equality and compares animations last.
src/​Reactor/​Animation/​ScrollAnimation.cs Compares scroll expressions by value.
src/​Reactor/​Animation/​KeyframeBuilder.cs Compares keyframe definitions by value.
src/​Reactor/​Animation/​InteractionStates.cs Adds brush-aware interaction-state equality.
src/​Reactor/​Animation/​AnimationEquality.cs Adds shared animation comparison helpers.
docs/​guide/​animation.md Updates the generated equality guidance.
docs/​_pipeline/​templates/​animation.md.dt Documents skip behavior and equality exceptions.
CHANGELOG.md Records the animation skip and refresh changes.

Review effort: Balanced

Comment thread src/Reactor/Hosting/ReactorHost.cs Resolved
Comment thread src/Reactor/Hosting/ReactorHost.cs Resolved
Comment thread src/Reactor/Elements/BrushHelper.cs Resolved
Comment thread src/Reactor/Elements/BrushHelper.cs Resolved
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for 85222b7 vs the base branch (c3bf429) — unit + selftest merged.

Metric base PR Δ
Line 89.06% 89.08% +0.02 pp ≈
Branch 44.56% (18558/41647) 44.63% (18718/41939) +0.07 pp ≈

No coverage change beyond the noise floor. ✅

✅ higher / ⚠️ lower / ≈ within noise. Δ is in percentage points; coverage is unit + selftest merged (Debug x64) on the CI runner. Cobertura reports attached to the workflow run as artifacts.

Subscribe to the "Animation effects" notification once, process-wide, in
TransitionEngine, and refresh every registered host through the theme
resource listeners. Chart-free windows and embedded hosts now get the
refresh too, and a palette notification arriving first can't suppress it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

A critical sequence-equality bug conflates independent child and decorator declarations, allowing child-only removal or replacement to stop or restart the decorator’s retained animation loop; declaration-layer identity and shared-target regression coverage are needed.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/Reactor/Core/Reconciler.cs Resolved
main split Reconciler.cs into partial files (#1706), so the scroll counter now
lives in Reconciler.Keyframes.cs.

Keyframe channel owners keep matching the array their layer applied by
reference, so a decorator and a child sharing a control with equal keyframes
stay distinct. Each skip arm instead moves an owner to the skipped element's
new array when an equal render rebuilt it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Changes to native animation ownership and process-wide WinRT notifications lacked independent Windows validation of shared-target and multi-host behavior, leaving the review reliant on source inspection and reported test results.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge agent-preparing Agent is addressing feedback or completing required validation and CI and removed agent-preparing Agent is addressing feedback or completing required validation and CI ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge labels Nov 26, 2026

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.

🟡 Changes recommended

On supported Windows builds before 19041, animation-setting changes can leave stale or missing implicit-animation keys because neither the subscription nor ordinary renders refresh them, requiring a render-time fallback for both host types and a regression test.

1 open issue

Review effort: Balanced

Before Windows 10 2004 "Animation effects" has no change notification, and
equal elements now skip their updates, so each root pass polls the setting
there and refreshes every host when it moved.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

The animation fixture incorrectly expects the Opacity key to survive on supported Windows builds before 19041, where polling correctly removes it, so the assertion must be capability-dependent.

1 open issue
1 resolved since last review

Review effort: Balanced

Before Windows 10 2004 the root pass's own poll drops the key, so the
fixture's equal-render positive control depends on that capability.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Actual WinRT Settings-event delivery and refresh behavior across separate UI dispatchers require live Windows validation unavailable in this snapshot; the supplied tests exercise only the refresh path directly.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Nov 26, 2026
…tras-rerender-skip

# Conflicts:
#	CHANGELOG.md
…tras-rerender-skip

# Conflicts:
#	src/Reactor/Core/ChildReconciler.cs
#	src/Reactor/Core/Reconciler.Keyframes.cs
#	src/Reactor/Core/Reconciler.ReactorState.cs
#	src/Reactor/Core/V1Protocol/ItemsHostReconciliation.cs
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 2cac495 into main Nov 26, 2026
50 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-animation-extras-rerender-skip branch November 26, 2026 04:27
@azchohfi Alexandre Zollinger Chohfi (azchohfi) removed the ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge label Nov 26, 2026
Alexandre Zollinger Chohfi (azchohfi) added a commit to PaperHammer/microsoft-ui-reactor that referenced this pull request Nov 26, 2026
Resolves the microsoft#1710 CHANGELOG conflict by keeping both entries. microsoft#1710's keyframe skip retarget auto-merged alongside this branch's opacity path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] .Keyframes(), .ScrollLinked() and .OpacityTransition() elements never skip on re-render

2 participants