Repository navigation
perf(listview): Drop dead recycle visibility pass - #24529
Conversation
|
Claude finished @MartinZikmund's task in 5m 5s —— View job Review complete ✅
Verdict: ship (1 minor/nit finding, non-blocking) Findings by severity
Cross-cutting notes
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate findings remain around Android coverage, test cleanup, and collection replacement semantics.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Removes the obsolete ListView recycle visibility pass and adds allocation-focused optimizations across XAML resource, collection, traversal, and boxing paths.
Changes:
- Removes the dead virtualization visibility sweep and call site.
- Adds optimized walkers, enumeration, and cached boxed values.
- Adds runtime coverage for styles, collections, and inherited hit-test behavior.
File summaries
| File | Summary |
|---|---|
src/Uno.UI/UI/Xaml/UIElement.Pointers.Managed.cs |
Caches hit-test enum boxes. |
src/Uno.UI/UI/Xaml/ResourceResolver.cs |
Uses the resource walker. |
src/Uno.UI/UI/Xaml/Documents/InlineCollection.cs |
Exposes fast enumeration. |
src/Uno.UI/UI/Xaml/DependencyObjectCollection.cs |
Adds indexed, versioned traversal. |
src/Uno.UI/UI/Xaml/DependencyObject.Theming.cs |
Uses optimized traversal. |
src/Uno.UI/UI/Xaml/DependencyObject.Store.cs |
Adds resource walking and typed disposal. |
src/Uno.UI/UI/Xaml/DependencyObject.PropertySystem.mux.cs |
Uses optimized collection walks. |
src/Uno.UI/UI/Xaml/DependencyObject.AncestorsDictionary.cs |
Reuses boxed booleans. |
src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs |
Uses fast inline enumeration. |
src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.managed.cs |
Removes the visibility-pass call. |
src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelGenerator.managed.cs |
Removes the obsolete visibility pass. |
src/Uno.UI/UI/Xaml/Controls/Control/Control.cs |
Reuses boxed disabled values. |
src/Uno.UI/Helpers/Boxes.cs |
Provides shared boxed values. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Style.cs |
Tests resource-scope ordering. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_DependencyObjectCollection.cs |
Tests themed collection traversal. |
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media/Given_VisualTreeHelper.cs |
Tests inherited hit-test state. |
Review details
Suppressed comments (5)
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_DependencyObjectCollection.cs:99
- This new
<see cref="When_Theme_Changes_Then_Items_In_Collections_Are_Updated"/>target does not exist anywhere in the runtime-test sources, so the documentation points to a nonexistent test and may produce an unresolved-cref warning. Reference the re-entry test above or remove the cref.
/// Same collections as <see cref="When_Theme_Changes_Then_Items_In_Collections_Are_Updated"/>, but
/// resolved by the Enter walk when the subtree joins the tree with a theme already set.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Style.cs:101
- The description says that no new tests are added, but this hunk adds a new runtime test and the diff adds several more. Please update the PR description/checklist (or split unrelated work) so the stated scope and validation match the submitted changes.
[TestMethod]
[RunsOnUIThread]
#if __ANDROID__
[Ignore("ContentControl implicit styles don't pass in CI on Android, as for When_ImplicitStyle")]
#endif
public async Task When_ImplicitStyle_Nearest_Scope_Wins()
src/Uno.UI/UI/Xaml/DependencyObject.Store.cs:1584
- This PR is described as a ListView-only dead-pass removal with no functional changes, but this hunk introduces a new resource traversal implementation; the same diff also changes collection enumeration and coercion paths. The listed ListView baseline tests cannot validate these changes. Please split the unrelated optimizations or update the PR scope and add validation for them.
internal ResourceDictionaryWalker EnumerateResourceDictionaries(
bool includeAppResources,
FrameworkElement? resourceContextProvider = null,
ResourceDictionary? containingDictionary = null)
=> new(
src/Uno.UI/UI/Xaml/DependencyObjectCollection.cs:399
- This custom fast path explicitly promises
List<T>.Enumerator-style fail-fast behavior, but the added tests only cover theme values. There is no regression test that mutates aDependencyObjectCollectionduring an Enter/Leave or resource walk, so a missed mutation hook could silently change lifecycle behavior; add coverage for a mid-walk mutation and the resulting exception.
// Same contract as List<T>.Enumerator: a collection modified mid-walk fails rather
// than silently skipping or revisiting an item.
if (_collection.ItemsVersion != _version)
{
throw new InvalidOperationException("Collection was modified; enumeration operation may not execute.");
src/Uno.UI/UI/Xaml/DependencyObjectCollection.cs:355
- The diff adds a new collection/tree-walk implementation, resource-walker changes, boxing/coercion changes, and multiple runtime tests, while the PR description says it only removes the ListView visibility pass and adds no tests. The supplied ListView/ItemsControl validation does not exercise these additional changes; please split the unrelated work or update the description and add targeted validation.
internal ref struct DependencyObjectItems
- Files reviewed: 16/16 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24529/wasm-skia-net9/index.html |
|
The build 234033 found UI Test snapshots differences: Details
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Reviewed the exact current head. The removed recycle visibility pass is redundant with the existing container lifecycle and does not change observable ListView virtualization, selection, focus, or visibility behavior. No significant issue found.
1cb2c62 to
ce98ced
Compare
|
Claude finished @MartinZikmund's task in 2m 5s —— View job Review complete ✅
Verdict: ship (0 blocking findings, 1 informational note below) What changed since the last review roundThe branch is now exactly 2 commits ahead of
Verified by inspection
Cross-cutting note (informational, non-blocking)The PR description's performance framing says No other issues found — no SOLID/DP/async/cross-platform/event-declaration concerns, no new warnings or suppressions, commit messages follow Conventional Commits, and the diff is now fully scoped to what the title describes. |
🤖 Addressed PR comments up to this point
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24529/wasm-skia-net9/index.html |
|
The build 234487 found UI Test snapshots differences: Details
|
|
|
ce98ced to
9207078
Compare
|
Claude finished @MartinZikmund's task in 38s —— View job Review complete ✅
Verdict: ship (0 findings — no new inline comments posted) What changed since the last review roundNo functional diff since the previous
Verified by inspection
Cross-cutting notes (non-blocking, carried over from the prior round — still accurate)
|
UpdateVisibilities() collapsed every container in the recycle pool once per layout cycle, but since 8fef29f a recycled container is removed from Panel.Children before being cached, so the write lands on a detached element and has no visual effect. Its doc comment describes batching toggles to help WebAssembly scrolling, which dated from when pooled containers stayed attached and Visibility drove DOM visibility. The paired Visible assignment in TryDequeueCachedContainer is kept on purpose: it runs once per dequeue rather than per layout cycle, and it still covers a container collapsed by an app or an ItemContainerStyle. Given_ListViewBase and Given_ItemsControl (169 tests, Skia Desktop) report an identical result with and without this change, including the same 7 failures, which are pre-existing on this base. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012QzKQawubFcPPX9JSoZLkX
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_019C454B8usXZRfvcjWT1BB4
9207078 to
9f398a2
Compare
|
Claude finished @MartinZikmund's task in 14s —— View job Review complete ✅Verdict: ship (0 blocking findings, 0 inline comments) The diff is unchanged in substance since the last round: 2 commits, +1/−19 over 3 files.
Checked by inspection (code review only; I did not build or run tests in this pass):
Notes (non-blocking):
|
|
The build 238522 found UI Test snapshots differences: Details
|
|
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. |

GitHub Issue: closes #24528
PR Type:
🔄 Refactoring (no functional changes, no api changes)
What changed? 🚀
VirtualizingPanelGenerator.UpdateVisibilities()walked the entire recycle pool once per layout cycle and wroteVisibility.Collapsedonto every cached container. Since8fef29fc610("remove containers from the visual tree when recycled even if cached"),RecycleViewForItem()removes a recycled container fromPanel.Childrenbefore caching it, so that write lands on a detached element and has no visual effect.This removes the method and its single call site in
VirtualizingPanelLayout.UpdateCompleted().The pass predates the current architecture — its own doc comment explained that batching the toggles "significantly improves scrolling performance in WebAssembly", which was true when pooled containers stayed attached to the panel and
Visibilitydrove real DOM visibility.The paired
Visibility = Visibleassignment inTryDequeueCachedContainer()is kept deliberately. It runs once per dequeue rather than once per layout cycle, so it is not the cost here, and it still covers a container collapsed by an application or anItemContainerStyle— removing it would be an actual behaviour change.Measured impact 📊
Work removed (exact, deterministic). This is the honest measure for this change:
VisibilityDP writes over the pool, per layout cycleCacheLimit)CacheLimitis roughly two viewports' worth of containers, clamped to [10, 1024] per template — about 30 in the benchmark list.UpdateCompleted()runs once per scroll step, so this is per scroll step, not per session.Memory. Managed bytes allocated per scroll step on the UI thread (
GC.GetAllocatedBytesForCurrentThread, median of 7 rounds), measured in alternating order — before, after, before, after — so that phase order cannot masquerade as an effect. 2,000-itemListView, 150 scroll steps per round:TextBlockin templateTextBlocksThe first two workloads reproduce to ~2 B between passes, so their few-byte deltas are real but negligible. The bound-text workload's own run-to-run jitter is ±130 B, which is larger than its delta, so nothing is claimed there.
This is not an allocation win, and it is not presented as one. The write being removed lands on a detached element, so the expected allocation effect was approximately zero, and that is what the measurement shows. The case for the change is the removed work and the removed dead code, not the byte count.
CPU time is deliberately not reported. It is below this machine's measurement floor for a change of this size, and I can demonstrate that rather than assert it: with the same instrument (
QueryThreadCycleTimeon the UI thread), reversing the order of the two phases flipped the sign of the apparent result on a sibling change, and within a single phase the spread reached 97 % (2.81 M vs 5.55 M cycles/iter on the same workload, same build). Any timing column produced here would be measuring machine state, not the change. Wall-clock is worse and is not reported either.Validation.
Given_ListViewBase+Given_ItemsControl(Skia Desktop,net10.0-desktop) were run against this branch and against the unmodified base, and the results are identical. After the rebase ontomaster(01f8a9f195): 158 tests, 151 passed, 6 failed, 1 inconclusive, 11 skipped, identical per test on both sides. The 6 failures are therefore pre-existing on this base and unrelated to this change (fractional-pixel size asserts and a theme-colour assert). Built withUnoFastDevBuilddropped so analyzers andEnforceCodeStyleInBuildwere active: 0 warnings, 0 errors.Scope note: this shows no observable change across that suite. It is not a proof that the write is unreachable in every state — it is dead because pooled containers are unparented, and that is the invariant this relies on.
The branch previously carried copies of three prerequisite perf commits (#24519, #24523, #24525). They were dropped on rebase: #24519 is merged, and the other two are reviewed in their own PRs. The PR also fixes a dangling
<see cref>inGiven_DependencyObjectCollectionthat came in with #24519.No new tests are added: this removes work that produces no observable effect, so there is no new behaviour to assert. The existing suites plus the baseline comparison are the evidence.
Measured with a headless Skia app (
Uno.UI.Runtime.Skia.Headless) project-referencing the framework, with Fluent resources merged. Not BenchmarkDotNet — this repo has no BenchmarkDotNet harness, and the workload runs on the dispatcher thread, which is where the allocation counter is read.Internal tracking: unoplatform/uno-private#2365 (list virtualization and scrolling audit, finding #2).
PR Checklist ✅
Screenshots Compare Test Runresults — pending CI🤖 Generated with Claude Code
https://claude.ai/code/session_012QzKQawubFcPPX9JSoZLkX