Repository navigation
Description
What would you like to be added? 💡
Four values are boxed on paths that run per element, and in two cases once per element of an entire subtree:
AncestorsDictionary(inherited-property re-registration) keeps its probe results in an object-valuedHashtableEx, so everySetboxes abool.InheritedPropertiesDisposableholds its callback asIDisposable, so the readonly structInheritedPropertyChangedCallbackDisposableis boxed on every registration, though the concrete type is statically known at the only call site.CoerceHitTestVisibilityreturnsobject, so each of its fivereturn HitTestability.X;statements boxes the enum.HitTestVisibilityPropertyis declared withFrameworkPropertyMetadataOptions.Inherits, so one coercion re-coerces every descendant, boxing once per element. It runs on everyVisibility,IsHitTestVisible,IsEnabledandIsLoadedtransition.Control.CoerceIsEnableddoes the same with a barefalseonIsEnabledProperty, which also inherits — andOnIsEnabledChangedcallsUpdateHitTest(), so the two coercions run back to back over the same subtree.
Separately, Uno.UI.Helpers.Boxes does not do what its name promises for enums: VerticalAlignmentBoxes, StretchBoxes and NullableDoubleBoxes declare value-typed fields, so Boxes.Box(VerticalAlignment) and Boxes.Box(Stretch) box a fresh object on every call and cache nothing. Only BooleanBoxes is typed object and actually works.
Why is this needed? 🤔
All of these are removable with shared boxes or a more precise field type, with no change to the values involved. The property system compares boxed DP values with object.Equals (AreDifferent), never by reference, so a shared box per constant is indistinguishable from a fresh one — indeed PropertyMetadata.DefaultValue already hands every element the same boxed default for these properties.
Measured impact 📊
Managed bytes allocated per iteration on the UI thread (GC.GetAllocatedBytesForCurrentThread, median of 7 rounds, two runs per side; reproduces within ~1%). Boxes are 24 B on x64, so the absolute deltas are also 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 saving is a flat ~24 B per element coerced, so it scales with subtree size rather than with the workload's total — which is why the 40-control page shows a smaller percentage than a single ListViewItem while saving 16× more bytes.
Per-element construction, measured to check that a more precise field type does not grow every DependencyObject:
| Workload | Before | After | Δ |
|---|---|---|---|
new Border() |
2,528 B | 2,512 B | −16 B |
new Grid() |
2,736 B | 2,720 B | −16 B |
new Button() |
5,104 B | 5,088 B | −16 B |
No per-instance growth is observable; construction allocates slightly less.
Renderer 🎨
- Skia
For which platforms 📱💻🖥️
All platforms 🌍
Anything else we need to know? 💬
Measured with a headless Skia app (Uno.UI.Runtime.Skia.Headless) that project-references the framework, with Fluent resources merged. Skia-measured only; WASM is unmeasured — the hit-test coercion path is compiled for both (UNO_HAS_MANAGED_POINTERS), so the WASM 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 reduction and not a GC-pause claim.
On estimate accuracy, since these come from an automated audit: the inherited-property items were estimated at ~3.9 KB per scroll step and measured ~1.4 KB (~2.8× optimistic), while the hit-test item was estimated at ~4.4 KB and measured ~4.2 KB. Worth keeping in mind when prioritising the remaining findings.
Activity
test: Reset window content in hit-test inherit test
test: Reset window content in hit-test inherit test
test: Reset window content in hit-test inherit test
test: Reset window content in hit-test inherit test