You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spec 066 layer 3: pool lanes and the native VisualTaken marker - #1656
Spec 066 layer 3. A control whose composition visual Reactor took now goes back to the pool instead of being dropped. Each poolable type gets two lanes. The plain lane is unchanged. The visual lane holds controls whose visual was taken, reset to a fresh control's pixels by the §7.3 list, and only an element that takes the visual at mount and has no .Set setter or .OnMount callback rents from it. So user code never gets a control whose Rotation or Scale write would throw.
ElementPool has a plain and a visual lane per type, each capped at 32. CleanElement runs the §7.3 reset on visual-lane controls. It stops animations, drops implicit animations, writes identity to the visual, disables translation, zeroes the Translation facade and forgets Reactor's composition bookkeeping. It skips the facade writes WinUI refuses after a handoff.
Both lanes clear ChildrenTransitions, ChildTransitions and ContentTransitions ([Bug] ElementPool doesn't clear ChildrenTransitions/ChildTransitions/ContentTransitions on return #1639). The visual lane also clears a brush transition on any panel or border, zeroes the relative offset and size adjustments, and writes the layout offset (ActualOffset) back, since layout doesn't rewrite an unchanged position after a stopped animation or a direct visual write. XAML also pushes UIElement.Opacity to the visual only when it changes, so the reset writes opacity 1 and a visual-lane renter gets its own UIElement.Opacity on the visual when it loads, without a fade, unless something already owns or wrote the visual's opacity.
A control unmounted mid-hover gets its interaction-state brushes restored, so a recycled control doesn't show the previous renter's hover color. A connected-animation source is the exception: it stays out of the pool, keeps its pixels for WinUI's snapshot, and only drops the element and handlers it hosted.
The lane is picked at rent from the declarations being mounted, including a keyed Memo over the element. App handlers never get the visual lane. That covers per-host and derived-type registrations, global ControlRegistry overrides of a built-in, and records derived from a built-in element.
Exit completions are keyed to their exit. A completion that outlives a control torn down mid-exit no longer pools it a second time. Navigation pages stay out of the pool, since their transition completion can still reach them.
Docs: element-pool.md.dt (recompiled), the diagram, TESTING.md's soak description, AGENTS.md and the pr-review correctness notes.
One deliberate reading of §7.2. A feature counts as demand only when it takes the visual at mount. .InteractionStates() takes it on the first state change, and an exit-only .Transition() on removal, so a fresh control keeps writable facades until then. Those elements rent from the plain lane. The spec sentence now says so.
Linked issue / spec
Implements docs/specs/066-transforms-on-composition-visual.md §7 (layer 3 in §13).
Related to #1624. This fixes the compositor-side leak, and layer 2 finishes it (OpacityTransition and BackgroundTransition).
Test plan
dotnet test tests/Reactor.Tests -p:Platform=x64 passed except CompilationLoaderTests.Cold_load_under_500ms_warm_under_50ms_for_minimal_project, a CLI timing test that also fails on a loaded machine without this change. New ElementPoolLaneTests cover the lane rules and mirror ModifierTable.VisualOwningModifiers.
TransformsMatrixTests.Ledger_ChangesFromTheBase_AreAllDeclared passed with REACTOR_TRANSFORMS_BASE_REF=origin/azchohfi-spec-066-layer-1-implicit-anim-slots.
ModifierTransform_Handoff_*, TransformHandoff_Transition_*, RotationUnits_CompositorTransitionRunning and three ConnectedNav_* checks fail identically on the layer 1 base on my desktop (an RDP session with no compositor animations), so they aren't from this change.
Mutation checks, each turning the named checks red. Marker on the early handoff path → Stagger_ChildMarked. Exit guard → ExitTornDown_PooledOnce. Identity writes → VisualLane_IdentityVisual. Translation facade reset → VisualLane_TranslationZero. StopAnimation → VisualLane_NoRunningAnimation. Implicit collection clear → VisualLane_NoImplicitKeys. Theme-transition clear → ThemeTransitions_StackPanel_Cleared. Setter block → LaneRules_SetterWithDemand. App-handler check → AppHandler_FacadeWriteWorks. Pool exclusion → NavTaint_PoolRefusesPage. Hover as demand → LaneRules_InteractionStatesOnly. The ambient-exit guard isn't caught because a stopped ambient fade never completes here, so it stays as a defensive check.
pr-review pass (seven dimensions plus a GPT cross-check). Its findings are fixed in 38d1c66.
Later review rounds added ElementPoolLanes_HoverBrush, _ResetLeftovers, _LayoutOffset, _MemoAppHandler, _ReturnTwice, _MemoKeyframes, _ConnectedSource and _KeyframeNames. _ResetLeftovers also covers a styled 0.65 opacity, an interrupted enter fade, and a visual hidden before the renter loads. Each one turns red locally with its fix removed, except the .ScrollLinked cases of _LayoutOffset. Those only show the frozen offset on a hosted runner, where they failed before 1c0db63 and pass after it. The pool's local Foreground and setter-written UIElement.Clip aren't reset in either lane, the same as main. That's tracked in Pool keeps a previous renter's local Foreground and UIElement.Clip #1662.
Perf, Release x64, interleaved with layer 1 (be95c3d). Each cycle mounts 30 keyed children, lays them out, removes them and lays out again. Median of 5 reps, 40 cycles, two processes each:
Workload
Layer 1
This PR
Border(TextBlock) plain
271 ms
271 ms
Border(TextBlock).Animate()
625–662 ms
402–486 ms
Border(TextBlock).LayoutAnimation()
369–394 ms
298–347 ms
VStack(TextBlock).Animate()
713–831 ms
556–612 ms
TextBlock.Animate()
583–645 ms
369–404 ms
Button plain
308 ms
320 ms (within noise, n=12)
Button.Animate()
975–1043 ms
624–679 ms
Per type, in one process with the visual lane switched off and on, the lane costs this share of discarding the control: Border 0.90, StackPanel 0.67, Grid 0.70, Canvas 0.69, TextBlock 0.63, RichTextBlock 0.65, ScrollViewer 0.31, Viewbox 0.63, ProgressBar 0.95, ProgressRing 0.25, Image 0.54, InfoBadge 0.47, Button 0.51, TextBox 0.49, ToggleSwitch 0.91. The pool's own return and rent cost is unchanged from layer 1 (about 58 µs for a Border, 110 µs for a Button). The visual reset adds about 15.5 µs, matching the spec's 12.8 to 18.6 µs.
One shape is slower. An empty, childless 6×6 Border with .Animate() or .LayoutAnimation(), rendered a frame per cycle, is about 25 to 35% slower than layer 1, because a new bare Border costs almost nothing to create. I considered a per-type rule that discards visual-taken Borders, but that would give up the 10% win for a Border with content and the 30 to 37% wins for panels and text, so the lane stays on for every type. It's the same trade-off the plain lane already makes on main for cheap controls. Lanes hold 32 per type, so large lists are unaffected either way.
Risk / breaking changes
No public API change. ElementPool.TryRent(Type) keeps renting from the plain lane.
Elements with .Animate(), an enter .Transition(), .Keyframes(), .LayoutAnimation() or .ScrollLinked() now reuse pooled controls. The reset is pixel-identical to a fresh control in the selftests. A control nested in a removed panel still isn't recycled, because ForceDetach rejects it. That predates this change and is left alone.
A control whose composition visual was taken now returns to a visual lane,
reset by the spec 066 section 7.3 list, instead of leaving the pool. Only a
built-in element that takes the visual itself and carries no setters or mount
callbacks rents from it. The lane marker lives on the native control's
ReactorState and every AnimationHelper.GetElementVisual sets it, replacing the
wrapper-keyed taint table. Both lanes clear ChildrenTransitions,
ChildTransitions and ContentTransitions. Exit completions are keyed to their
exit, so one that outlives a torn-down control can't return it to the pool
twice, and navigation pages stay out of the pool.
Fixes#1639, #1643 and the rest of #1624.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Keep app handlers off the visual lane: exact built-in element types only,
plus global ControlRegistry overrides (a contested registration) and
derived-type registrations, not just per-host RegisterHandler.
- Count a feature as demand only when it takes the visual at mount, so
.InteractionStates(), an exit-only .Transition() and a ScrollLinked
without a ScrollViewer rent from the plain lane (spec 066 section 7.2).
- Tests: app-handler, ambient-exit and pool-exclusion cases, lazy-feature
lane rules, and a mirror test against ModifierTable.VisualOwningModifiers.
- Docs: lane cap label, TESTING.md soak description, spec 7.2 wording.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Artifact sizes for c98885d vs the base branch (344e6c5).
Packages (compressed .nupkg)
Artifact
base
PR
Δ
Microsoft.UI.Reactor.nupkg
2.10 MB
2.10 MB
+5.70 KB (+0.27%)
⚠️
Microsoft.UI.Reactor.Advanced.nupkg
528.7 KB
528.7 KB
-5 B (0.00%)
≈
Microsoft.UI.Reactor.Devtools.nupkg
287.8 KB
287.7 KB
-7 B (0.00%)
≈
Assemblies in Microsoft.UI.Reactor
Artifact
base
PR
Δ
Reactor.Analyzers.dll
437.5 KB
437.5 KB
+0 B (0.00%)
≈
Reactor.dll
2.84 MB
2.85 MB
+9.50 KB (+0.33%)
⚠️
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
Δ
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.0 KB
787.0 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.
Coverage for c98885d vs the base branch (28a8722) — unit + selftest merged.
Metric
base
PR
Δ
Line
88.70%
88.80%
+0.10 pp
✅
Branch
45.68% (18380/40239)
45.52% (18489/40617)
-0.16 pp
⚠️
✅ 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.
Recorded by run 44897514815 (transforms-matrix-record). The changes are all
#1643: staggered children are now marked visual-taken, plain renters no longer
get a taken visual, and the soak's visual-lane probes pass the section 7.3
reset checks. Each is declared in transforms-ledger.expected.json.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Visual-lane reuse can corrupt connected-animation snapshots, and concurrent keyframe cleanup can throw; visual reset and test coverage issues also remain.
Implements spec 066 layer 3 in Reactor’s native-control pool, enabling reuse of controls whose composition visual was taken while keeping them separate from renters that require writable facade transforms. It targets the handoff-marker and theme-transition leaks described in #1643 and #1639.
Changes:
Adds native VisualTaken state, separate plain and visual pool lanes, mount-time eligibility checks, and visual cleanup.
Guards stale exit completions, excludes navigation participants from pooling, and clears theme transitions.
Adds lane and soak coverage, updates recorded baselines, and documents the pooling contract.
- Keep a prepared connected-animation source out of the pool: WinUI
captures it at the next frame.
- Restore Visual.IsVisible and clear a Grid/StackPanel BackgroundTransition
in the visual-lane reset.
- Drop the cross-host keyframe trigger scan from the reset; unmount already
removes those entries.
- Declare the soak's violation counts with exact before/after values.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical teardown and pooling defects can leave stale references and triggers or rent the same control twice, while reset gaps can leak visual state between renters.
PoolPolicy.Reset runs after _pool.Return and can take the visual through CompositorProvider.EnsureCompositor when no compositor is cached. The control then remains in the plain stack, so the next .Set(b => b.Rotation = 10) can receive it and throw. Recheck the marker when renting and discard stale plain-lane entries, or finish the author reset before choosing the lane.
Clear foreground brushes before pooling controls
src/Reactor/Core/ElementPool.cs:292
Visual-lane controls can retain the previous renter's foreground because CleanElement clears neither Control.Foreground nor TextBlock.Foreground. Removing an animated red TextBlock and mounting an animated one without a foreground can therefore leave the new text red. Clear both foreground properties on return, including local brushes left by interaction states.
Clear attached child visuals during reset
src/Reactor/Core/ElementPool.cs:649
The visual-lane reset leaves a visual attached with SetElementChildVisual in place. An element that installs a sprite in .OnMount(...) and declares .Animate(...) can now be pooled, so a later animated renter displays the previous renter's sprite. Clear the attached child visual during reset.
- Make ElementPool.Return idempotent: a control already on a stack isn't
pushed again, so a handler's ReturnControl plus the engine's return can't
hand one control to two renters.
- Record keyframe trigger names on the native control and drop exactly those
entries in the visual reset, so a keyed Memo's keyframes don't suppress the
next renter's playback. (#1659 tracks the Memo .Ref gap, which predates
this layer.)
- Wait for matching layout before the pixel comparison in the VisualLane
fixture.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unsynchronized global registries can corrupt reconciliation across UI threads, while incomplete pool cleanup and memo handling can leak state or cause exceptions.
Clear overridden foreground brushes when returning controls to the pool
src/Reactor/Core/ElementPool.cs:306
Removing a TextBlock or Button while an interaction state overrides its foreground leaves a local brush behind. The next animated renter inherits that hover color because neither ClearInteractionStates nor CleanElement clears Foreground. Clear the corresponding foreground dependency property on return.
Stop and reset expression targets across keyed Memo wrappers
src/Reactor/Core/ElementPool.cs:648
A keyed Memo can apply .ScrollLinked(...) to its inner control, but CleanupElementChainForUnmount does not visit the wrapper. Custom expression targets such as RelativeOffsetAdjustment and RotationAxis are missing from the reset's stop list, so an old viewer can keep driving the recycled control. Record and stop the actual expression targets, including wrapper declarations, and restore their values or exclude unsupported targets before pooling.
Reset relative offset and size adjustments before reuse
src/Reactor/Core/ElementPool.cs:663
The reset leaves RelativeOffsetAdjustment and RelativeSizeAdjustment unchanged. An outgoing element can write either property through its visual in .OnMount(...), then enter the visual lane through .Animate(), causing a later renter to inherit its relative position or size. Restore both properties to zero during reset.
Clear background transitions on every poolable Panel
src/Reactor/Core/ElementPool.cs:675
This misses poolable Canvas controls, which also inherit Panel.BackgroundTransition. A canvas that sets a background transition and takes its visual can enter the visual lane, leaving that transition active for the next animated renter. Clear the property for every poolable Panel, rather than only Grid and StackPanel.
Clear memo transparency before invoking registered handlers
src/Reactor/Core/Reconciler.Mount.cs:126
A registered handler for KeyedMemoElement still inherits Transparent = true. If it mounts a plain Border and then writes Rotation, an .Animate() declaration on the memo lets the child rent a taken visual and makes that write throw. Clear memo transparency before invoking any registered handler; the same issue affects all three registry dispatch branches.
Allocate exit tokens only when an ambient animation is active
src/Reactor/Core/Reconciler.cs:5130
This allocates an exit token for every removal without an explicit transition, even when there is no ambient animation and the token is never used. That adds avoidable allocations to ordinary list and virtualization churn. Create the token only when an effective ambient animation is present.
Restore interaction-state brushes when a control unmounts mid-hover, stop every animatable visual property in the visual reset and zero the relative adjustments, clear brush transitions on any panel or border, keep memo transparency away from registered handlers, and allocate the ambient exit token only when an ambient animation is active.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore interaction-state brushes only on unmount, so an update that drops the states keeps its new brushes. Put back the Offset and Size layout last wrote when the visual reset stops an animation on them, since layout won't rewrite an unchanged position.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The visual reset writes opacity 1 again, since the visual's static value can be an interrupted enter fade's 0. A visual-lane renter instead gets its UIElement.Opacity on the visual when it loads, unless a Reactor feature owns the visual's opacity by then, because XAML pushes it only when it changes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The load-time opacity sync skips pool-excluded controls and visuals written since the reset, and holds back the renter's implicit Opacity key so the value shows without a fade.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Snapshot preservation and cleanup span multiple unmount and pooling paths, while permissive visual baselines add uncertainty that warrants human assessment.
The sync runs on the first layout pass that finds the renter in the live tree, before its first frame, with Loaded kept for popups. WinUI can raise Loaded late or skip it for a control re-added while its Unloaded is pending, which made the opacity fixtures intermittent on CI. A return unsubscribes a renter that never loaded. The fixtures wait on the sync itself, assert it ran, and reproduce navigation's mount, hide, attach order. Pixel comparisons recapture until both bitmaps have the same size and report the sizes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Opacity-sync handlers can remain registered after cancellation or when pooling is disabled after rent, and the stale generated guide snippet will fail documentation CI.
A renter's pending opacity sync is cancelled on every unmount, not only on a pool return, so one unmounted before it attached (a cancelled navigation, a disabled pool) doesn't stay on the window's layout list.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
XAML may push a styled opacity itself when a control re-enters the tree, which made the final visual value an unreliable oracle on CI. A test-only counter records the sync's writes: HiddenBeforeLoad asserts the sync made none, and NoFade judges only a fade after a sync write.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ready-for-reviewAgent work and technical checks complete; awaiting review, not approval or mergetransforms-matrixRun the spec 066 transforms matrix against the ledger (Transforms matrix workflow)
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Spec 066 layer 3. A control whose composition visual Reactor took now goes back to the pool instead of being dropped. Each poolable type gets two lanes. The plain lane is unchanged. The visual lane holds controls whose visual was taken, reset to a fresh control's pixels by the §7.3 list, and only an element that takes the visual at mount and has no
.Setsetter or.OnMountcallback rents from it. So user code never gets a control whoseRotationorScalewrite would throw.What changes:
ReactorState.VisualTakenreplaces the wrapper-keyed_compositorTaintedtable. It lives on the native control, so every wrapper sees it, and everyAnimationHelper.GetElementVisualsets it, including the stagger andEnsureCompositorhandoffs that never did ([Bug] ElementPool can recycle controls whose composition visual was taken (Stagger handoff isn't tainted; taint is lost across RCW wrappers) #1643).ElementPoolhas a plain and a visual lane per type, each capped at 32.CleanElementruns the §7.3 reset on visual-lane controls. It stops animations, drops implicit animations, writes identity to the visual, disables translation, zeroes theTranslationfacade and forgets Reactor's composition bookkeeping. It skips the facade writes WinUI refuses after a handoff.ChildrenTransitions,ChildTransitionsandContentTransitions([Bug] ElementPool doesn't clear ChildrenTransitions/ChildTransitions/ContentTransitions on return #1639). The visual lane also clears a brush transition on any panel or border, zeroes the relative offset and size adjustments, and writes the layout offset (ActualOffset) back, since layout doesn't rewrite an unchanged position after a stopped animation or a direct visual write. XAML also pushesUIElement.Opacityto the visual only when it changes, so the reset writes opacity 1 and a visual-lane renter gets its ownUIElement.Opacityon the visual when it loads, without a fade, unless something already owns or wrote the visual's opacity.Memoover the element. App handlers never get the visual lane. That covers per-host and derived-type registrations, globalControlRegistryoverrides of a built-in, and records derived from a built-in element.element-pool.md.dt(recompiled), the diagram, TESTING.md's soak description, AGENTS.md and the pr-review correctness notes.One deliberate reading of §7.2. A feature counts as demand only when it takes the visual at mount.
.InteractionStates()takes it on the first state change, and an exit-only.Transition()on removal, so a fresh control keeps writable facades until then. Those elements rent from the plain lane. The spec sentence now says so.Linked issue / spec
Implements docs/specs/066-transforms-on-composition-visual.md §7 (layer 3 in §13).
Fixes #1639
Fixes #1643
Related to #1624. This fixes the compositor-side leak, and layer 2 finishes it (
OpacityTransitionandBackgroundTransition).Test plan
dotnet test tests/Reactor.Tests -p:Platform=x64passed exceptCompilationLoaderTests.Cold_load_under_500ms_warm_under_50ms_for_minimal_project, a CLI timing test that also fails on a loaded machine without this change. NewElementPoolLaneTestscover the lane rules and mirrorModifierTable.VisualOwningModifiers.TransformsMatrixTests.Ledger_ChangesFromTheBase_AreAllDeclaredpassed withREACTOR_TRANSFORMS_BASE_REF=origin/azchohfi-spec-066-layer-1-implicit-anim-slots.dotnet run --project tests/Reactor.AppTests.Host --no-build -c Debug -p:Platform=x64 -- --self-test --filter <prefix>) passed forElementPoolLanes,PooledFacadeTransform,ModifierTransform_CompositionOwnership,NavCov_Transition,ImplicitAnimationSlots,RegisterType,CovBoost_ElementPool,Stagger,AnimationCombination.ModifierTransform_Handoff_*,TransformHandoff_Transition_*,RotationUnits_CompositorTransitionRunningand threeConnectedNav_*checks fail identically on the layer 1 base on my desktop (an RDP session with no compositor animations), so they aren't from this change.Stagger_ChildMarked. Exit guard →ExitTornDown_PooledOnce. Identity writes →VisualLane_IdentityVisual. Translation facade reset →VisualLane_TranslationZero.StopAnimation→VisualLane_NoRunningAnimation. Implicit collection clear →VisualLane_NoImplicitKeys. Theme-transition clear →ThemeTransitions_StackPanel_Cleared. Setter block →LaneRules_SetterWithDemand. App-handler check →AppHandler_FacadeWriteWorks. Pool exclusion →NavTaint_PoolRefusesPage. Hover as demand →LaneRules_InteractionStatesOnly. The ambient-exit guard isn't caught because a stopped ambient fade never completes here, so it stays as a defensive check.pr-reviewpass (seven dimensions plus a GPT cross-check). Its findings are fixed in 38d1c66.ElementPoolLanes_HoverBrush,_ResetLeftovers,_LayoutOffset,_MemoAppHandler,_ReturnTwice,_MemoKeyframes,_ConnectedSourceand_KeyframeNames._ResetLeftoversalso covers a styled 0.65 opacity, an interrupted enter fade, and a visual hidden before the renter loads. Each one turns red locally with its fix removed, except the.ScrollLinkedcases of_LayoutOffset. Those only show the frozen offset on a hosted runner, where they failed before 1c0db63 and pass after it. The pool's localForegroundand setter-writtenUIElement.Cliparen't reset in either lane, the same as main. That's tracked in Pool keeps a previous renter's local Foreground and UIElement.Clip #1662.transforms-matrix-record, run 44912244613, 0 failures). Every difference is [Bug] ElementPool can recycle controls whose composition visual was taken (Stagger handoff isn't tainted; taint is lost across RCW wrappers) #1643. Staggered children now readtaken=1, plain renters no longer get a taken visual, and the soak's visual-lane probes reportanims=0 facade=0 keys=0 taken=0 visual=0. All are declared intransforms-ledger.expected.json, andTransformsMatrixTestspassed (57/57) against layer 1.Perf, Release x64, interleaved with layer 1 (be95c3d). Each cycle mounts 30 keyed children, lays them out, removes them and lays out again. Median of 5 reps, 40 cycles, two processes each:
Border(TextBlock)plainBorder(TextBlock).Animate()Border(TextBlock).LayoutAnimation()VStack(TextBlock).Animate()TextBlock.Animate()ButtonplainButton.Animate()Per type, in one process with the visual lane switched off and on, the lane costs this share of discarding the control: Border 0.90, StackPanel 0.67, Grid 0.70, Canvas 0.69, TextBlock 0.63, RichTextBlock 0.65, ScrollViewer 0.31, Viewbox 0.63, ProgressBar 0.95, ProgressRing 0.25, Image 0.54, InfoBadge 0.47, Button 0.51, TextBox 0.49, ToggleSwitch 0.91. The pool's own return and rent cost is unchanged from layer 1 (about 58 µs for a Border, 110 µs for a Button). The visual reset adds about 15.5 µs, matching the spec's 12.8 to 18.6 µs.
One shape is slower. An empty, childless 6×6
Borderwith.Animate()or.LayoutAnimation(), rendered a frame per cycle, is about 25 to 35% slower than layer 1, because a new bareBordercosts almost nothing to create. I considered a per-type rule that discards visual-taken Borders, but that would give up the 10% win for a Border with content and the 30 to 37% wins for panels and text, so the lane stays on for every type. It's the same trade-off the plain lane already makes on main for cheap controls. Lanes hold 32 per type, so large lists are unaffected either way.Risk / breaking changes
No public API change.
ElementPool.TryRent(Type)keeps renting from the plain lane.Elements with
.Animate(), an enter.Transition(),.Keyframes(),.LayoutAnimation()or.ScrollLinked()now reuse pooled controls. The reset is pixel-identical to a fresh control in the selftests. A control nested in a removed panel still isn't recycled, becauseForceDetachrejects it. That predates this change and is left alone.