Skip to content

Remove the dead visibility pass over the ListView recycle pool #24528

Closed

Description

@MartinZikmund

What would you like to be added? 💡

VirtualizingPanelGenerator.UpdateVisibilities() sets Visibility.Collapsed on every container in the recycle pool, once per layout cycle, for containers that are no longer in the visual tree. Since commit 8fef29fc610 ("remove containers from the visual tree when recycled even if cached"), RecycleViewForItem() removes a recycled container from Panel.Children before it is cached — so setting Visibility on it has no visual effect.

The pass should be removed, along with its single call site in VirtualizingPanelLayout.UpdateCompleted().

Why is this needed? 🤔

It runs on every scroll step, walking the whole recycle pool (CacheLimit is roughly two viewports' worth of containers, clamped to [10, 1024] per template) and performing a DependencyProperty write per container. On a still-live element each write also drives hit-test and opacity updates, so it is not free.

The method's own doc comment explains the original motivation — batching visibility toggles "significantly improves scrolling performance in WebAssembly" — which dates from when pooled containers stayed attached to the panel and Visibility drove real DOM visibility. That architecture is gone, so the pass now does work that cannot be observed.

The paired Visibility = Visible assignment in TryDequeueCachedContainer() is deliberately kept: it costs one write per dequeue rather than per layout cycle, and it still guards a container collapsed by an application or an ItemContainerStyle, so removing it would be a behaviour change.

Renderer 🎨

  • Skia
  • Native

For which platforms 📱💻🖥️

All Skia targets — VirtualizingPanelGenerator.managed.cs is the managed virtualizing panel used by Skia (Desktop, WASM, Skia-on-mobile).

Anything else we need to know? 💬

Identified by a source audit of the list-virtualization scroll path, which noted that the pass "is provably a no-op on a detached element under the current architecture" and can be deleted with no behaviour change while recycled containers remain unparented.

Validation: the Given_ListViewBase and Given_ItemsControl runtime suites (169 tests, Skia Desktop) produce an identical result with and without the removal — the same 7 tests fail on both sides, so those failures are pre-existing on this base and unrelated. Note this shows no observable change across that suite rather than proving the pass unreachable in every state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions