Skip to content

perf(uno-ui): Reuse boxes on the inherited-property and hit-test paths - #24525

Merged
MartinZikmund merged 4 commits into
masterfrom
dev/mazi/perf-inherited-registration
Oct 2, 2026
Merged

MartinZikmund merged 4 commits into
masterfrom
dev/mazi/perf-inherited-registration

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #24524

PR Type:

🔄 Refactoring (no functional changes, no api changes)

What changed? 🚀

Note

Rebased onto master on 2026-09-29. The AncestorsDictionary, Control/ButtonBase.CoerceIsEnabled and Boxes enum-table parts below have since landed on master through the cached-boxes sweep (d7a77ad and the Uno.UI.Helpers.Boxes namespace refactor), so this PR now carries only the InheritedPropertiesDisposable field typing, the shared HitTestability boxes, the AreDifferent remark and the new test. The measurements below were taken against the pre-sweep base and overstate what remains.

Four values were boxed on paths that run per element, and in two cases once per element of an entire subtree:

  • AncestorsDictionary stores probe results in an object-valued HashtableEx, so every Set boxed a bool during inherited-property re-registration — now Boxes.Box(bool), the helper that already exists for this.
  • InheritedPropertiesDisposable held its callback as IDisposable, boxing a readonly struct on every registration. It now stores the callback's state inline — just the parent store's weak reference, since the callback's child store is always the owner — so it stays two references wide (a concretely typed callback field would have grown every DependencyObject by 8 B).
  • CoerceHitTestVisibility returns object, so each of its five returns boxed a HitTestability. That property inherits, so one coercion re-coerces the subtree below it — once per element.
  • Control.CoerceIsEnabled (and ButtonBase.CoerceIsEnabled for a command whose CanExecute is false) did the same with a bare false on IsEnabledProperty, which also inherits and, via OnIsEnabledChanged → UpdateHitTest(), runs immediately before the hit-test coercion over the same subtree.

Two supporting changes:

  • Boxes' enum tables were broken. VerticalAlignmentBoxes, StretchBoxes and NullableDoubleBoxes declared value-typed fields, so Box(VerticalAlignment)/Box(Stretch) boxed on every call and cached nothing. They are object-typed now. This has no measurable effect today (both overloads are uncalled and the one live use runs once per property registration) — it is included because this PR's whole thesis is "share the box", and leaving a …Boxes helper that doesn't box is a trap for the next caller.
  • AreDifferent now records the invariant everything here depends on: boxed DP values are compared by value, never by reference, so a ReferenceEquals fast path added there later would silently change change-detection for shared boxes.

Measured impact 📊

GC.GetAllocatedBytesForCurrentThread, median of 7 rounds, two runs per side, against master. A box is 24 B on x64, so the absolute deltas double as box counts:

Workload Before After Δ ≈ boxes
ListView (2,000 items) scroll step 178,237 B 172,169 B −6,068 B (−3.4 %) ~253
Same, over 1,000 steps 189,588 B 183,552 B −6,036 B (−3.2 %) ~252
Enter + Leave a 40-control page 797,457 B 790,553 B −6,904 B (−0.9 %) ~288
Enter + Leave ListViewItem 37,789 B 37,368 B −421 B (−1.1 %) ~18
Enter + Leave CheckBox 24,744 B 24,512 B −232 B (−0.9 %) ~10
Enter + Leave Button 18,592 B 18,408 B −184 B (−1.0 %) ~8
Theme toggle on that page 539,832 B 539,112 B −720 B (−0.1 %) ~30

The win is a flat ~24 B per element coerced, so it scales with subtree size, not with a workload's total — the 40-control page shows a smaller percentage than one ListViewItem while saving 16× more bytes.

Per-instance footprint, measured because InheritedPropertiesDisposable lives inline on every DependencyObject. Re-measured after rebasing onto current master (01f8a9f), same harness; "concrete field" is the first revision of this PR, which typed the disposable's field as the callback struct:

Workload master concrete field this PR Δ vs master
new Border() 2,576 B 2,560 B 2,552 B −24 B
new Grid() 2,784 B 2,768 B 2,760 B −24 B
new Button() 5,152 B 5,136 B 5,128 B −24 B

The first revision's −16 B was the removed hit-test box (−24 B) partly offset by the struct growing from two references to three (+8 B per DependencyObject). Storing only the parent's weak reference keeps the struct at master's size, so construction now saves the full box.

The same re-measurement for the per-step workloads (medians, two runs per side, bytes within ~250 B between runs): ListView scroll step 160,641 B → 154,695 B (−5,946 B, −3.7 %); Enter + Leave Button 17,264 B → 17,080 B (−184 B). The earlier tables were taken on an older master, so their absolute values differ, but the deltas match.

Scope and limits. Skia-measured only — the hit-test path also compiles for WASM (UNO_HAS_MANAGED_POINTERS), where the effect is expected but not demonstrated. Wall-clock is not reported: it varied by more than the effect between identical runs. Gen0 over 1,000 scroll steps moved 15 → 14, within the ±1 this instrument shows across builds, so this is an allocation claim, not a frame-time one.

Estimate accuracy, since these came from an automated audit: the inherited-property items were estimated at ~3.9 KB/step and measured ~1.4 KB (~2.8× optimistic); the hit-test item was estimated ~4.4 KB and measured ~4.2 KB. The first pair alone was too small to ship, which is why they are bundled.

Validation ✅

Runtime tests, Skia Desktop — Given_UIElement, Given_VisualTreeHelper, Given_InputManager, Given_InputInjector, Given_ThemeResource, Given_ElementTheme, Given_Style, Given_VisualStateManager, Given_NonFE_DataContextBinding, Given_ResourceDictionary_DataContext, Given_BindingExpression, Given_DependencyObjectExtensions, Given_DependencyProperty_AttachedPropagation, Given_ListViewBase, Given_Button, Given_CheckBox: 969 run, 957 passed, 22 skipped, 1 inconclusive, 11 failed.

The failures are the Given_ListViewBase layout-rounding/timeout set and the Given_UIElement clip/transform set, all of which reproduce identically on a build of the merge-base (verified by building master in a separate worktree and running the same classes: 563 passed / 5 failed, same five names).

Given_VisualTreeHelper.When_Ancestor_Not_HitTestVisible_Then_Descendant_Collapsed was added: the existing hit-test tests all exercise geometry, and none asserted that a descendant follows its ancestor's IsHitTestVisible/Visibility — which is exactly the inheritance mechanism whose boxed values changed here.

It was mutation-checked: with the coercion changed so a descendant no longer inherits an ancestor's Collapsed, it is the only failure in Given_VisualTreeHelper (1 of 10; the nine geometry-based hit-test tests still pass). So it guards the inheritance leg specifically, rather than duplicating existing coverage. It also passes on the merge-base, i.e. it asserts behaviour this PR preserves.

After rebasing onto 01f8a9f and the review fixes: runtime tests, Skia Desktop — Given_VisualTreeHelper, Given_Button, Given_Control, Given_NonFE_DataContextBinding, Given_DependencyObjectExtensions, Given_ElementTheme, Given_ThemeResource: 188 run, 188 passed. Uno.UI.UnitTests: 4,129 passed, 12 failed — all When_Gregorian_FixedDate*, a known pre-existing local failure (they assume a UTC machine; green on CI).

Perf axis: work removed 📊

The ≈ boxes column above is the deterministic operation count for this change — every eliminated box is one heap allocation that no longer happens, and the count follows directly from the 24 B box size on x64:

Metric, per ListView scroll step Before After
Boxes allocated on the inherited-property and hit-test coercion paths ~253 0
Boxes per element coerced (flat, so it scales with subtree size) 1 0

This is an allocation change, so the tables above are the performance evidence: the CPU benefit is the GC pressure removed, not fewer instructions in the coercion walk itself.

CPU time is deliberately not reported, and that is demonstrable rather than asserted. Re-measuring on this machine with a thread-cycle counter (QueryThreadCycleTime sampled on the UI thread, where the work runs) showed that reversing the order of the two measurement phases flips the sign of the apparent result, and that the spread within a single phase reaches 74–97 % on the same build and workload. A timing column produced here would report machine state, not the change. Wall-clock is worse and is not reported either — as already noted above, it varied by more than the effect between identical runs. The byte figures are unaffected: allocation is deterministic and reproduces to ~10 B on the low-variance workloads.

Provenance. Measured with a headless Skia app (Uno.UI.Runtime.Skia.Headless) project-referencing the framework, with Fluent resources merged; bytes via GC.GetAllocatedBytesForCurrentThread on the dispatcher thread, median of 7 rounds, two runs per side. Not BenchmarkDotNet — this repository has no BenchmarkDotNet harness, and the workload runs on the dispatcher thread, which is where the allocation counter has to be read.

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!)

Follow-ups this PR deliberately leaves open

  • PropagateInheritedNonLocalProperties still allocates a HashtableEx per call (the audit's item 3 for that finding); the Count == 0 early return is the current mitigation.
  • _childrenStores is a copy-on-write ImmutableList, so register/unregister each allocate a fresh array.
  • Both enum Box overloads in Uno.UI.Helpers.Boxes are currently uncalled — worth either adopting or deleting.

🤖 Generated with Claude Code

https://claude.ai/code/session_012QzKQawubFcPPX9JSoZLkX


Internal tracking: unoplatform/uno-private#2349 (finding 8) and unoplatform/uno-private#2368 (finding 2), under unoplatform/uno-private#2346.

Copilot AI lite review requested due to automatic review settings September 16, 2026 09:56
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 10s —— View job


Review complete ✅

Todo list

  • Gather context (diff, changed files)
  • Review Boxes.cs changes
  • Review Control.cs (CoerceIsEnabled) changes
  • Review DependencyObject.AncestorsDictionary.cs changes
  • Review DependencyObject.Store.cs changes
  • Review UIElement.Pointers.Managed.cs (CoerceHitTestVisibility) changes
  • Review new runtime test in Given_VisualTreeHelper.cs
  • Post inline comments for findings (none warranted — see below)
  • Post summary

Verdict: Ship — no blocking issues found

This is a tightly-scoped, mechanical refactor and it holds up under inspection:

  • Boxes.cs: The enum tables (VerticalAlignmentBoxes, StretchBoxes, NullableDoubleBoxes) were indeed declared with value-typed fields, so Box(VerticalAlignment)/Box(Stretch) boxed on every call — confirmed by reading the switch expressions. Retyping to object fixes this. Also confirmed the one live caller (DependencyProperty.cs:584, Boxes.StretchBoxes.Fill) is assigned to an object-returning method, so the field type change doesn't break that call site — it actually benefits from it now too.
  • AncestorsDictionary.Set and Control.CoerceIsEnabled: straightforward swap to Boxes.Box(bool); semantics preserved (is false pattern match on a boxed bool is unaffected by which box instance is used).
  • InheritedPropertiesDisposable: retyping the field/ctor param from IDisposable to the concrete InheritedPropertyChangedCallbackDisposable struct is safe — verified the only call site (RegisterInheritedProperties) already produces that concrete type, and the outer container field (InheritedPropertiesDisposable?) is a Nullable<T> of a struct, so no interface-boxing is introduced anywhere in the chain.
  • CoerceHitTestVisibility: the three shared s_hitTest* boxes replace equivalent bare-enum returns 1:1 across all five return points; verified against the #if UNO_HAS_MANAGED_POINTERS gating (this file is entirely under that symbol, consistent with the platform-targeting rules).
  • AreDifferent doc-only change: verified the stated invariant against the actual implementation (Equals for value types/strings, ReferenceEquals otherwise) — the comment accurately describes existing behavior and is a reasonable guardrail note for future changes to that method.
  • New runtime test (When_Ancestor_Not_HitTestVisible_Then_Descendant_Collapsed): correctly placed inside the #if HAS_UNO block, correctly [Ignore]s under !UNO_HAS_MANAGED_POINTERS (matching the production code's gating), and exercises the inheritance leg that the boxing change touches rather than duplicating the existing geometry-based hit-test tests. It follows the same UITestHelper.Load-without-explicit-cleanup pattern already used by the neighboring Nested_Setup_HitTest test in this file, so it's consistent with local convention.

No SOLID/layering, async/cancellation, DependencyProperty registration, or cross-platform-suffix concerns apply here — this PR doesn't touch any of those surfaces. No new warnings or #pragma/NoWarn additions. Commit message and PR type follow Conventional Commits.

No inline comments were posted since no concrete defects were found.

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

Unresolved moderate findings remain in test cleanup, the ButtonBase coercion path, and per-instance storage overhead.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR reduces boxing allocations in inherited-property and managed hit-test paths while adding regression coverage.

Changes:

  • Reuses boxed boolean and hit-testability values.
  • Uses concrete inherited-property callback storage and fixes box caches.
  • Adds inherited hit-test visibility coverage.
File summaries
File Summary
src/Uno.UI/UI/Xaml/UIElement.Pointers.Managed.cs Reuses hit-testability boxes.
src/Uno.UI/UI/Xaml/DependencyObject.Store.cs Avoids disposable boxing and documents value comparison.
src/Uno.UI/UI/Xaml/DependencyObject.AncestorsDictionary.cs Reuses boxed booleans.
src/Uno.UI/UI/Xaml/Controls/Control/Control.cs Reuses the boxed false value.
src/Uno.UI/Helpers/Boxes.cs Corrects cached box field types.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media/Given_VisualTreeHelper.cs Adds inherited hit-test visibility coverage.
Review details

Suppressed comments (2)

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media/Given_VisualTreeHelper.cs:113

  • The platform skip is expressed by conditionally adding a hard [Ignore] via #if. Runtime tests use PlatformCondition for platform-specific coverage; mark this as PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.Skia) instead of compiling an ignored test on every native target. That keeps the test discoverable and states precisely where the managed-pointer implementation under test exists.
		[TestMethod]
		[RunsOnUIThread]
#if !UNO_HAS_MANAGED_POINTERS
		[Ignore("Hit-test visibility coercion is only used by managed hit testing.")]
#endif

src/Uno.UI/UI/Xaml/DependencyObject.Store.cs:1448

  • Because _inheritedProperties is an InheritedPropertiesDisposable? field on every DependencyObject (the field is at DependencyObject.Store.cs:77), this change inlines InheritedPropertyChangedCallbackDisposable's two references into every object. The old outer struct held one callback reference plus _owner; the new one holds the callback's two references plus _owner, so nullable storage grows even for objects that never register inherited properties. Please use a reference-backed wrapper or provide a net-memory measurement before taking this per-instance footprint tradeoff.
			// Typed concretely: the only caller passes this struct, and an IDisposable field would box it.
			private readonly InheritedPropertyChangedCallbackDisposable _inheritedPropertiesCallback;
			private readonly DependencyObject _owner;

			public InheritedPropertiesDisposable(DependencyObject owner, InheritedPropertyChangedCallbackDisposable inheritedPropertiesCallback)
  • Files reviewed: 6/6 changed files
  • Comments generated: 3
  • Review effort level: Lite

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 233999 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Focus_FocusVisual_Properties.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
  • skia-windows-screenshots: 2310 changed over 2408

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • ApplicationViewSizing.png-dark
    • AppWindowFeatures.png-dark
    • AppWindowTitleBar Properties.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationPropertiesExtensions_Role.png
    • AutoSizedTopLeft.png-dark
    • AutoSizedTopLeft.png
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapIcon_Generic.png-dark
    • BitmapIcon_Generic.png
    • BorderBottomwithmargins.png-dark
    • BorderBottomwithmargins.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

Copilot AI review requested due to automatic review settings September 18, 2026 07:55
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/perf-inherited-registration branch from 038941e to f0461ce Compare September 18, 2026 07:55
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

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


Review complete ✅

Todo list

  • Gather context (diff since last review, changed files)
  • Check whether prior review feedback (Copilot, morning4coffe-dev) was addressed
  • Review Boxes.cs changes
  • Review Control.cs / ButtonBase.cs (CoerceIsEnabled) changes
  • Review DependencyObject.AncestorsDictionary.cs changes
  • Review DependencyObject.Store.cs changes (InheritedPropertiesDisposable footprint)
  • Review UIElement.Pointers.Managed.cs (CoerceHitTestVisibility) changes
  • Review runtime test in Given_VisualTreeHelper.cs (cleanup, PlatformCondition, GitHubWorkItem)
  • Post inline comments for remaining findings (none — see below)
  • Post summary

Verdict: Ship — 0 blocking, 0 moderate, 0 minor findings

This is a re-review of the current HEAD against origin/master, after three follow-up commits landed on top of the version the earlier automated/Copilot reviews saw. All previously raised points are resolved:

  • ButtonBase.CoerceIsEnabled (Copilot: raw false still allocated on the command-disabled path) — fixed in a17001f8; it now returns Boxes.Box(false).
  • Per-instance footprint growth of InheritedPropertiesDisposable (Copilot + morning4coffe-dev: typing the field concretely grew it from 2 references to 3) — fixed in 87cfc97b, and it's a root-cause fix rather than a patch: InheritedPropertyChangedCallbackDisposable was removed entirely, and RegisterInheritedPropertyChangedCallback now returns the bare ManagedWeakReference it used to wrap. InheritedPropertiesDisposable holds exactly the same two references (ManagedWeakReference + DependencyObject) as the pre-PR IDisposable-typed field did, so the per-DependencyObject footprint this PR started with is restored while still avoiding the interface-boxing the PR set out to fix. Verified the sole call sites (TryRegisterInheritedProperties, CleanupInheritedPropertyChangedCallback) line up with the new signature.
  • Missing test cleanup (Copilot: UITestHelper.Load leaves WindowContent set) — fixed in f0461ce8, body now wrapped in try/finally resetting WindowHelper.WindowContent = null.
  • Missing GitHubWorkItem annotation — added, pointing at Boxed values on the inherited-property and hit-test coercion paths #24524.
  • [Ignore] via #if !UNO_HAS_MANAGED_POINTERS instead of PlatformCondition (Copilot, suppressed/optional) — left as-is; confirmed this matches the existing local convention (three other tests in this same file use the identical pattern), so it's consistent rather than a new anti-pattern being introduced.

Re-verified the core boxing changes independently on this pass (Boxes.cs enum tables now object-typed with a single live caller at DependencyProperty.cs:584; AncestorsDictionary.Set and the hit-test/IsEnabled coercions all route through shared boxes; AreDifferent's doc update accurately reflects the value/reference-equality split it documents). No SOLID/layering, async, DependencyProperty-registration, or platform-suffix concerns apply — this PR doesn't touch those surfaces. No new warnings or #pragma/NoWarn growth. Commits and title follow Conventional Commits.

No inline comments were posted since no concrete defects remain.
(branch)

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

It touches core dependency-property inheritance and managed hit-testing coercion paths where subtle regressions can be hard to detect despite good test coverage.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 234484 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
  • skia-windows-screenshots: 2310 changed over 2408

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonTest.png-dark
    • AppBarToggleButtonTest.png-dark
    • AppWindowFeatures.png
    • Arrange_Performance01.png
    • Attributed_text_Supserscript.png
    • AutoBorderStretchwithleftmargin.png
    • AutomationProperties_AutomationId.png-dark
    • AutoSizedTopLeft.png-dark
    • AutoSuggestBox_Keyboard.png
    • AutoSuggestBox_Reason.png-dark
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BorderVersusPanelClipping.png-dark
    • BorderVersusPanelClipping.png
    • Border_Clipped_Change_Property.png-dark
    • Border_Clipped_Change_Property.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 234484 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 2m 34s —— View job


Review complete ✅

Todo list

  • Gather context (diff since last review, rebase changes)
  • Review DependencyObject.Store.cs (InheritedPropertiesDisposable)
  • Review UIElement.Pointers.Managed.cs (hit-test boxes)
  • Review Given_VisualTreeHelper.cs (test)
  • Post inline comments for findings
  • Post summary

Verdict: Ship — 0 blocking, 0 moderate, 2 minor findings

This is a re-review of the current HEAD (5fd8e12b) against origin/master, after the rebase noted in the PR description. The rebase dropped the AncestorsDictionary, Control/ButtonBase.CoerceIsEnabled, and Boxes enum-table changes (confirmed: zero diff remains in Boxes.cs, Control.cs, ButtonBase.cs, DependencyObject.AncestorsDictionary.cs vs origin/master — they landed separately). The diff is now exactly the 3 files listed: DependencyObject.Store.cs, UIElement.Pointers.Managed.cs, and the new runtime test.

Verified independently:

  • InheritedPropertiesDisposable — traced the full call chain (RegisterInheritedProperties → RegisterInheritedPropertyChangedCallback → CleanupInheritedPropertyChangedCallback). The struct now holds (owner, parentStoreWeak), the same two references as the pre-PR IDisposable-typed field, with the nested InheritedPropertyChangedCallbackDisposable struct removed entirely (grepped for stale references — none remain). Dispose() correctly resolves the parent from the weak reference and removes _owner from that._childrenStores, matching original semantics. This resolves the per-instance footprint regression both Copilot and morning4coffe-dev flagged on earlier revisions.
  • Hit-test boxes — the three s_hitTest* fields replace all five CoerceHitTestVisibility return points 1:1; confirmed the whole file is gated under #if UNO_HAS_MANAGED_POINTERS.
  • New test (When_Ancestor_Not_HitTestVisible_Then_Descendant_Collapsed) — has the try/finally cleanup and GitHubWorkItem attribute that were requested on earlier revisions. Confirmed the #if !UNO_HAS_MANAGED_POINTERS [Ignore] is correct: GetHitTestVisibility() takes an entirely different, unrelated code path under that symbol, so the test would validate the wrong mechanism if run there.
  • AreDifferent doc update — accurately describes the existing value/reference-equality split and correctly flags the invariant the shared boxes now depend on.

Two minor (non-blocking) findings posted inline:

  1. UIElement.Pointers.Managed.cs: the new hit-test boxes are hand-rolled s_* fields rather than added to Uno.UI.Helpers.Boxes, where the codebase's existing enum-box convention (and this PR's own earlier fix to VerticalAlignmentBoxes/StretchBoxes) already lives — a consistency nit, not a correctness issue.
  2. DependencyObject.Store.cs:1139-1141: a doc comment still refers to "the disposable" this method returns, but it now returns a bare ManagedWeakReference — leftover wording from the removed InheritedPropertyChangedCallbackDisposable struct.

No SOLID/layering, async/cancellation, DependencyProperty-registration, or platform-suffix concerns apply to this diff. No new warnings or #pragma/NoWarn growth. Commits follow Conventional Commits.
· branch

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 236282 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2304, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • ButtonClippingTestsControl.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Image_AnimatedWebP.png-dark
  • skia-windows-screenshots: 2304 changed over 2502

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AnimatedIconPage.png-dark
    • Accessibility_ScreenReader.png-dark
    • AppBar_KeyBoard.png-dark
    • AppBarToggleButtonTest.png-dark
    • AppBarButtonWithIconTest.png-dark
    • ApplicationViewSizing.png
    • AppWindowClosing.png
    • ApplicationViewSizing.png-dark
    • AppWindowTitleBar Properties.png-dark
    • AppWindowPresenters.png-dark
    • AppWindowPositionAndSize.png-dark
    • Attributed_text_FontSize_Changing.png
    • ArcSegment.png
    • AppXamlDefinedResources.png
    • AutoBorderStretchwithleftmargin.png
    • AuthenticationBroker_Demo.png-dark
    • Attributed_text_Simple.png
    • AutomationProperties_AutomationId.png
    • AutoBorderStretchwithtopmargin.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Uno_Web.Http.CookieManagerTests
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@MartinZikmund MartinZikmund added the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Sep 30, 2026
Copilot AI lite review requested due to automatic review settings October 2, 2026 05:59
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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


Review complete ✅

Todo list

  • Gather context (diff since last review, new commits)
  • Review Boxes.cs (new HitTestabilityBoxes)
  • Review UIElement.Pointers.Managed.cs (converged on shared Boxes helper)
  • Review DependencyObject.Store.cs (stale comment wording fix)
  • Review Given_VisualTreeHelper.cs (no change expected, confirmed)
  • Post inline comments for findings (none — see below)
  • Post summary

Verdict: Ship — 0 blocking, 0 moderate, 0 minor findings

This is a re-review of current HEAD (97ce555c) against origin/master. Since the last automated review (which left two minor, non-blocking notes), one new commit landed — 97ce555c: refactor: Move hit-test boxes to shared Boxes helper — and it resolves both of them:

  • Hit-test boxes converged into Uno.UI.Helpers.Boxes (the first minor finding): the ad hoc s_hitTestCollapsed/s_hitTestInvisible/s_hitTestVisible fields that previously lived in UIElement.Pointers.Managed.cs are gone — grepped the file to confirm no s_hitTest* remnants remain. A new HitTestabilityBoxes class in Boxes.cs holds the three cached instances, matching the existing convention of per-enum *Boxes classes there (VerticalAlignmentBoxes, StretchBoxes, RoutedEventFlagBoxes). CoerceHitTestVisibility's five return points now route through HitTestabilityBoxes.{Collapsed,Invisible,Visible} 1:1 with the prior bare-enum/local-box returns — verified line by line.
  • Stale "the disposable" wording (the second minor finding): DependencyObject.Store.cs's comment above RegisterInheritedPropertyChangedCallback's return now reads "A weak reference, so the parent does not keep the child alive..." — accurately describing the ManagedWeakReference it returns, with no leftover reference to the removed InheritedPropertyChangedCallbackDisposable struct.

Re-verified the rest of the diff is otherwise unchanged from the prior (Sept 29) review pass — InheritedPropertiesDisposable still holds exactly (owner, parentStoreWeak), two references, matching master's pre-PR footprint; the new Given_VisualTreeHelper test still has its try/finally cleanup and GitHubWorkItem attribute; AreDifferent's doc update is unchanged and still accurate.

No SOLID/layering, async/cancellation, DependencyProperty-registration, or platform-suffix concerns apply to this diff. HitTestabilityBoxes isn't wired into the BoxingDiagnosticAnalyzer's HasSpecialBox special-casing, but that's consistent with the existing gap for VerticalAlignmentBoxes/StretchBoxes (pre-existing, already called out in the PR's own follow-up list) — not a regression introduced here. No new warnings or #pragma/NoWarn growth. Commit message follows Conventional Commits.

No inline comments were posted since no concrete defects remain.
· branch

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.

Copilot review overview

🟢 Approval recommended

The only final comment is a non-blocking documentation nit; the reviewed changes are otherwise approval-ready.

Review effort: Lite
Findings: None

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 236916 found UI Test snapshots differences: skia-linux-screenshots: 116, skia-windows-screenshots: 136

Details
  • skia-linux-screenshots: 116 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • DisplayInformation.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
  • skia-windows-screenshots: 136 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Examples.png
    • Image_Placeholder.png-dark
    • Image_Placeholder.png
    • Grid_in_GridClipping.png-dark
    • Grid_in_GridClipping.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

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

MartinZikmund and others added 4 commits October 2, 2026 14:56
Two values were boxed on paths that run per element, once per element of a
whole subtree:

- InheritedPropertiesDisposable held its callback as IDisposable, boxing the
  readonly InheritedPropertyChangedCallbackDisposable struct on every
  registration, though the concrete type is statically known.
- CoerceHitTestVisibility returns object, so each of its five returns boxed a
  HitTestability. HitTestVisibilityProperty inherits, so one coercion re-coerces
  the subtree below it, boxing once per element.

AreDifferent records the invariant this relies on: boxed DP values are compared
by value, so a ReferenceEquals fast path there would change change-detection for
shared boxes. The AncestorsDictionary, Control.CoerceIsEnabled and Boxes-table
parts of the original change landed on master with the cached-boxes sweep.

When_Ancestor_Not_HitTestVisible_Then_Descendant_Collapsed covers the
inheritance leg of hit-test visibility, which the existing geometry-focused
hit-test tests did not.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012QzKQawubFcPPX9JSoZLkX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014vRr9HufCgBEVgt1z8J5Ay
Typing the callback field concretely removed the box but grew the struct from
two references to three, adding 8 B to every DependencyObject. The callback's
child store is always the owner, so store only the parent's weak reference and
unregister directly, dropping the nested callback struct.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019C454B8usXZRfvcjWT1BB4
Copilot AI lite review requested due to automatic review settings October 2, 2026 12:57
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/perf-inherited-registration branch from 97ce555 to 181b264 Compare October 2, 2026 12:57
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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


Review complete ✅

Todo list

  • Gather context (diff since last review, confirm current HEAD)
  • Review Boxes.cs
  • Review DependencyObject.Store.cs
  • Review UIElement.Pointers.Managed.cs
  • Review Given_VisualTreeHelper.cs (test)
  • Post inline comments for any new findings (none — see below)
  • Post summary

Verdict: Ship — 0 blocking, 0 moderate, 0 minor findings

Confirmed the current HEAD (181b2641) is byte-identical to the state the previous automated review (Oct 2, 06:07 UTC) already verdicted "Ship" with 0 findings — the blob hashes for all four changed files (Boxes.cs → 35dc074c, UIElement.Pointers.Managed.cs → 02873c98, DependencyObject.Store.cs → b563eddd, Given_VisualTreeHelper.cs → 1f741b31) match exactly what's listed in this PR's changed-files metadata. No new commits landed since that pass, so there is nothing new to review; I re-verified the diff against origin/master directly rather than relying on that conclusion alone:

  • Boxes.cs: HitTestabilityBoxes follows the established per-enum *Boxes convention (VerticalAlignmentBoxes, StretchBoxes, RoutedEventFlagBoxes) — three object-typed cached instances, no boxing per access.
  • UIElement.Pointers.Managed.cs: all five CoerceHitTestVisibility return points route through HitTestabilityBoxes.{Collapsed,Invisible,Visible} 1:1 with the prior bare-enum returns; file is fully gated under #if UNO_HAS_MANAGED_POINTERS as expected for the managed hit-test path.
  • DependencyObject.Store.cs: traced the full chain — RegisterInheritedPropertyChangedCallback now returns the bare ManagedWeakReference (no more InheritedPropertyChangedCallbackDisposable wrapper struct, confirmed removed with no stale references left), InheritedPropertiesDisposable holds exactly (owner, parentStoreWeak) — two references, matching master's pre-PR IDisposable-typed field size, and Dispose() correctly calls CleanupInheritedPropertyChangedCallback(_parentStoreWeak, _owner) then _owner.CleanupInheritedProperties(), preserving original semantics. The AreDifferent remark accurately documents the value/reference-equality split the shared boxes rely on, and the previously-flagged stale "disposable" wording is gone.
  • Given_VisualTreeHelper.cs: new test has try/finally resetting WindowHelper.WindowContent, a GitHubWorkItem attribute pointing at Boxed values on the inherited-property and hit-test coercion paths #24524, and correctly scopes the #if !UNO_HAS_MANAGED_POINTERS [Ignore] to the managed-only coercion path it exercises.

All prior reviewer findings (Copilot's three, morning4coffe-dev's one, and the two minor notes from the Sept 29 automated pass) are resolved in this state — no regressions reintroduced.

No SOLID/layering, async/cancellation, DependencyProperty-registration, or platform-suffix concerns apply to this diff. No new warnings or #pragma/NoWarn growth. Commits follow Conventional Commits.

Cross-cutting note (not a code finding): the CI screenshot-diff bot has reported a very large, consistent fraction of snapshots changing (skia-windows-screenshots ~2300+/2408-2502, i.e. nearly the whole baseline) across every run on this branch since Sept 16 — including runs before this PR's remaining diff was pared down to these 4 files. Given this PR is allocation-only with no rendering/layout changes, and the magnitude/consistency hasn't tracked the PR's own content changes across rebases, this looks like a master-side baseline/environment issue rather than something introduced here — worth confirming against a clean master build before treating it as a merge blocker.

No inline comments were posted since no concrete defects were found.
· branch

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.

Copilot review overview

🟢 Approval recommended

The focused changes preserve behavior and include targeted regression coverage.

Review effort: Lite
Findings: None

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 236964 found UI Test snapshots differences: skia-linux-screenshots: 116, skia-windows-screenshots: 157

Details
  • skia-linux-screenshots: 116 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • DisplayInformation.png-dark
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
  • skia-windows-screenshots: 157 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • DynamicBrushes_On_Shapes.png-dark
    • DynamicBrushes_On_Shapes.png
    • Focus_FocusVisual_Properties.png-dark
    • Grid_Spacing_Adjustable.png-dark
    • Grid_Spacing_Adjustable.png
    • Grid_Star_Auto_WithTextblock.png-dark
    • Grid_Star_Auto_WithTextblock.png
    • Grid_Style_Local_Override.png-dark
    • Grid_Style_Local_Override.png
    • Grid_Two_bottom_row_Auto__middle_col_auto.png-dark

@mergify

mergify Bot commented Oct 2, 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
MartinZikmund merged commit 77316bb into master Oct 2, 2026
56 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/perf-inherited-registration branch October 2, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Boxed values on the inherited-property and hit-test coercion paths

5 participants