Repository navigation
Skip unchanged renders for rebuilt animation declarations - #1710
Alexandre Zollinger Chohfi (azchohfi) merged 10 commits into
Conversation
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>
…tras-rerender-skip # Conflicts: # CHANGELOG.md
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
✅ smaller / |
There was a problem hiding this comment.
🟡 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
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
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>
There was a problem hiding this comment.
🟡 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
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>
There was a problem hiding this comment.
🔵 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
…tras-rerender-skip
There was a problem hiding this comment.
🟡 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>
There was a problem hiding this comment.
🟡 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>
There was a problem hiding this comment.
🔵 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
…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
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>


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
460c392d9f407c70479080bd387b70e38b233a8c↑ 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.
.Keyframes()/.ScrollLinked()elements failed on unchanged code.↓ 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:
ScrollVieweris the sameThe 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:
TransitionEnginesubscribes to the change notification once per process, and each notification refreshes every Reactor host through the theme resource listeners. That covers windows andReactorHostControlalike, 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.ShallowEqualsnow 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
.Keyframes()/.ScrollLinked()elements weren't shallow-equal on unchanged code. Unit tests also cover each hand-compared field.Animate_RebuiltExtrasSkipandAnimate_RebuiltExtrasChildSkipcover the direct and child-skip paths. Checks:ModifierTransform_Transitionsadds an equal-render step on the direct and child-diff skip paths, covering the deferred scale reset.ReducedMotionSubscriptionTestspins theTransitionEnginesubscription and its capability guard, and the root-pass poll behind the missing-capability guard.dotnet test tests/Reactor.Tests: 16,398 passed, 0 failed.Animate_andModifierTransform_Transitionsfilters have 0 failures.tests/Reactor.AppTests.Hostandtests/Reactor.Tests(withsrc/Reactor): 0 errors.animationtopic recompiled. API index unchanged, since the overrides keep the synthesized signatures.Perf, Release build, interleaved with the merge base. Time per reconcile of 300 unchanged rows:
.OpacityTransition().WithTransitions().InteractionStates()brush.Keyframes().ScrollLinked()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.
/perfhere will give a reliable number.Risk / breaking changes
EqualsonImplicitTransitions,ThemeTransitions,InteractionStateValues,KeyframeAnimationDefandScrollAnimationConfignow compares by value instead of by reference.