Repository navigation
Description
Current behavior
The existing runtime test suite for ItemsRepeater in src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Repeater/Given_ItemsRepeater.cs covers a handful of virtualization scenarios (When_ItemSignificantlyTaller_Then_VirtualizeProperly, When_NestedIRSlowlyChangeViewport_Then_MaterializedNeededItems, etc.), but does not cover the class of problems that are visible to users when ItemsRepeater hosts items with very high size variance and the user scrolls quickly:
-
Fast-scroll jumps with variable-height items: when the user rapidly navigates (e.g.
ChangeViewto far-apart offsets) through a list where a few items are significantly taller than the running average, newly realized items can end up visually overlapping, appearing above the viewport, or positioned at the wrongActualOffset.Y. This is a direct consequence ofStackLayout.GetAnchorForRealizationRect/GetExtentusing average-size estimation and the (Uno-specific) clamp of the extent origin to0blocking the correction pass. See fix: StackLayout.GetExtent clamps extent origin to 0, breaking ItemsRepeater's negative-offset correction #23042 (fix: StackLayout.GetExtent clamps extent origin to 0). -
Scroll-to-top after variable-height realization: after scrolling down through a list with tall items and scrolling back up, users can observe that the first item is not flush at offset
0— some content is inaccessible.ScrollableHeight/ExtentHeightend up inconsistent with the real positions because the clamp and the missing anchor provider onScrollViewercombine to lose track of the true layout extent. -
Anchor maintenance across a measure pass that expands items in place: when a realized item grows (e.g. late-loading content replaces a short placeholder),
ItemsRepeater/ScrollViewershould keep the currently-visible items visually stable. Today nothing pins them — the visible content jumps.
We do not have targeted regression tests for any of the three scenarios above, so regressions in virtualization can ship undetected.
Expected behavior
Runtime tests under Uno.UI.RuntimeTests exercise and assert the following invariants on Skia Desktop and WebAssembly (and ideally on WinUI for parity):
Test A — When_FastScrollWithHighVarianceItems_Then_NoOverlap
- Sources: 200 items, heights drawn from
{ 40, 40, 40, 1200, 40, 40, 40, ... }(every 10th item is ~30× taller). - Container:
ScrollViewer(classic) hostingItemsRepeater+StackLayout(Orientation=Vertical). Viewport height = 600. - Sequence:
ChangeView(null, 5000, null, disableAnimation: true)→WaitForIdle→ChangeView(null, 0, ...)→WaitForIdle→ChangeView(null, 12000, ...)→WaitForIdle→ChangeView(null, 300, ...)→WaitForIdle. - Assertions (for each final state):
- No two materialized repeater children have overlapping
ActualOffset.Y..ActualOffset.Y+ActualHeightranges. - Every materialized child's
ActualOffset.Yis>= 0OR (if the extent origin legitimately shifted negative) itsTransformToVisual(repeater).Yis consistent withrealizedBounds. - The child with
DataContext == Source[expectedIndexAtOffset]is materialized and roughly centered in the viewport. - Screenshot assertion on a couple of known-color items to confirm visual placement.
- No two materialized repeater children have overlapping
Test B — When_ScrollToTop_AfterVariableScrolling_Then_FirstItemFlushAtZero
- Same SUT as Test A.
- Sequence: scroll to the end (
Scroller.ScrollableHeight), then scroll back to0,WaitForIdle. - Assertions:
Source[0]is materialized.- The repeater child bound to
Source[0]hasTransformToVisual(ScrollViewer).Y == 0(within 0.5px tolerance). Scroller.VerticalOffset == 0.- Screenshot of the top-left pixel corresponds to
Source[0]'s background color.
Test C — When_RealizedItemGrows_Then_VisibleAnchorStable
- 50 items, all 60px tall initially. Container:
ScrollViewer+ItemsRepeater+StackLayout. Viewport = 400px. - Scroll to
VerticalOffset = 1200,WaitForIdle. Capture the visible top item'sDataContextand itsTransformToVisual(ScrollViewer).Y. - Programmatically replace an off-screen earlier item's height (index
5, well above the viewport) with1500px. Invalidate measure,WaitForIdle. - Assertions:
- The previously-visible top item's
DataContextis still visible. - Its
TransformToVisual(ScrollViewer).Yhas changed by less than 2px. Scroller.VerticalOffsethas shifted by approximately the grown delta to compensate.
- The previously-visible top item's
- This test validates the
IScrollAnchorProvidercontract end-to-end on classicScrollViewer(currently broken — see feat: Implement IScrollAnchorProvider on classic ScrollViewer (CurrentAnchor, RegisterAnchorCandidate, anchor-tracking across layout) #23043feat: Implement IScrollAnchorProvider on classic ScrollViewer).
Test D — Extension of existing When_ItemSignificantlyTaller_Then_VirtualizeProperly
- After the existing sequence, scroll back to
VerticalOffset == 0and assert:- Source[0]'s realized element has
TransformToVisual(ScrollViewer).Y == 0. Source[0]visually occupies the top pixels (screenshot color check).ExtentHeightis greater than or equal to the sum of heights of all known items.
- Source[0]'s realized element has
Implementation notes
- Place under
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Repeater/Given_ItemsRepeater_FastScroll.cs(new file) or extendGiven_ItemsRepeater.cs. The existingSUThelper in that file (used byWhen_ItemSignificantlyTaller_Then_VirtualizeProperlyat line ~413) is reusable. - Use
TestServices.WindowHelper.WaitForIdle()andTestServices.WindowHelper.WaitForLoaded(...)consistently. - Guard the tests with
#if !__SKIA__ [Ignore("Fails due to async native scrolling.")]matching the existing convention while native-platform scroll determinism remains an open item. - For the screenshot assertions, use
UITestHelper.ScreenShot+ImageAssert.HasColorAtas elsewhere in the file.
Why this matters
Real-world chat/feed UIs — conversations, timeline feeds, dashboards with KPI + markdown cards — trivially produce the high-variance height profile (short status lines interleaved with tall code blocks / media). The current test suite passes while such UIs visibly break. These tests must land before or alongside the fixes tracked in #23042 (fix: StackLayout...) and #23043 (feat: Implement IScrollAnchorProvider...) so the fixes are verifiable and regression-protected.
References
src/Uno.UI/UI/Xaml/Controls/Repeater/StackLayout.cs:125-211—GetAnchorForRealizationRectandGetExtent.src/Uno.UI/UI/Xaml/Controls/Repeater/ViewportManagerWithPlatformFeatures.cs:213-260—SetLayoutExtent,m_expectedViewportShift/m_unshiftableShift.- WinUI reference for parity:
src/controls/dev/Repeater/StackLayout.cpp::GetExtentandViewportManagerWithPlatformFeatures.cpp::SetLayoutExtent/OnLayoutUpdated.
Activity
fix(scrollviewer): Preserve offset intent across virtualization exten…
fix(scrollviewer): Restore WinUI parity for ItemsRepeater scroll beha…
fix(scrollviewer): Preserve offset intent across virtualization exten…
fix(scrollviewer): Preserve offset intent across virtualization exten…
fix(scrollviewer): Clamp offset intent to the request-time extent (fixes
fix(scrollviewer): Clamp offset intent to the request-time extent (fixes
fix(scrollviewer): Clamp offset intent to the request-time extent (fixes
fix(scrollviewer): Clamp offset intent to the request-time extent (fixes
test(itemsrepeater): Link the disabled tests to tracking issues
test(itemsrepeater): Link the disabled tests to tracking issues
test(itemsrepeater): Link the disabled tests to tracking issues
test(itemsrepeater): Link the disabled tests to tracking issues
test(itemsrepeater): Link the disabled tests to tracking issues
test(itemsrepeater): Link the disabled tests to tracking issues