Repository navigation
Description
Summary
The ItemsRepeater / StackLayout / FlowLayoutAlgorithm / ViewportManagerWithPlatformFeatures sources under src/Uno.UI/UI/Xaml/Controls/Repeater/ are drifting from WinUI. The header of ViewportManagerWithPlatformFeatures.cs records the port as being from WinUI commit 1cf9f1c. The upstream microsoft-ui-xaml tree has since had at least three syncs touching these files (67723ef, 69097129a, 256bdcd0c) and numerous bug fixes / refactors.
During the investigation for the companion issues (fast-scroll rendering regressions and anchor-provider gaps) several Uno-local "workarounds" were found that either:
- Solve a symptom by breaking the upstream correction mechanism (for example the
Math.Max(0, firstRealizedMajor)clamp inStackLayout.cs:186-189, tracked separately in fix: StackLayout.GetExtent clamps extent origin to 0, breaking ItemsRepeater's negative-offset correction #23042). - Duplicate logic that already matches upstream but are marked with misleading
// Uno workaround [BEGIN/END]comments (for example theanchorIndexclamp inStackLayout.cs:150-154— the code is functionally identical to WinUI'sStackLayout.cpp:160-161, the "workaround" label is spurious).
A clean resync will close these gaps, reduce long-term maintenance load, and let the upstream comments speak for themselves rather than being diluted by workaround markers that no longer reflect reality.
Scope
Refresh the following files to WinUI HEAD of the microsoft-ui-xaml tree (or latest upstream at time of execution):
StackLayout.cs— fromStackLayout.cpp+StackLayout.h+StackLayoutState.cpp/.h.FlowLayout.cs— fromFlowLayout.cpp+FlowLayout.h.FlowLayoutAlgorithm.cs— fromFlowLayoutAlgorithm.cpp+FlowLayoutAlgorithm.h.FlowLayoutState.cs— fromFlowLayoutState.cpp/.h.ViewportManagerWithPlatformFeatures.cs— fromViewportManagerWithPlatformFeatures.cpp/.h.ItemsRepeater.cs(partial set) — fromItemsRepeater.cpp/.handItemsRepeater.common.cpp/.h.ItemsRepeaterScrollHost.cs— fromItemsRepeaterScrollHost.cpp/.h.ViewManager.cs— fromViewManager.cpp/.h.ElementManager.cs— fromElementManager.cpp/.h.VirtualizingLayoutContext.cs/LayoutContext.cs/LayoutContextAdapter.cs— from matching.cpp/.h.UniformGridLayout.cs— fromUniformGridLayout.cpp/.h.
Exclude for now (separate evaluation / larger effort):
LinedFlowLayout.*— not currently present in Uno; new WinUI feature, may land as its own issue.SelectionModel*/IndexPath*— if present in Uno, out of scope for this pass.
Approach
- Capture baseline — run the full Repeater runtime test suite (
Given_ItemsRepeater,Given_StackLayout, etc.) on Skia Desktop and WebAssembly, record the green list. Merge the runtime tests from test: Add runtime tests for ItemsRepeater fast-scroll and scroll-to-top with high-variance item heights #23041 first so they are part of the baseline. - Use the
/winui-portskill per file. Preserve only legitimately Uno-specific paths:#if !UNO_HAS_ENHANCED_LIFECYCLEperf guards.- Platform-specific dispatcher hooks (
m_cacheBuildActionviaDispatcherQueue). EffectiveViewportChangedsubscription guard on emptyItemsSourceView.
- Drop misleading "Uno workaround" comments where the code matches WinUI. Verify by diff.
- Drop the
Math.Max(0, firstRealizedMajor)clamp (already tracked by fix: StackLayout.GetExtent clamps extent origin to 0, breaking ItemsRepeater's negative-offset correction #23042; this issue simply shouldn't reintroduce it during the resync). - Port companion fixes from upstream — notably any fixes to:
- Anchor tracking during
BringIntoView. - Cache buffer inflation timing.
SetPendingViewportShift/SetExpectedViewportShifthelper extraction (WinUI now uses helper methods; Uno inlines).ResetLayoutExtent/ResetVisibleWindow/ResetLastLayoutRealizationWindow— these exist in current WinUI and are cleaner than the inline resets in Uno.
- Anchor tracking during
- Keep the Uno
LayoutId()indirection and tracing helpers compatible. The C++ tracing macros expand to no-ops in most Uno builds; preserve the call shape so log lines stay consistent if someone wires verbose tracing locally. - Update the port header comments at the top of each file to reference the new upstream commit(s) consumed.
Acceptance criteria
- All runtime tests that were green before the resync remain green on Skia Desktop and WebAssembly.
- Runtime tests added by test: Add runtime tests for ItemsRepeater fast-scroll and scroll-to-top with high-variance item heights #23041 pass.
- No Uno-local
// Uno workaround [BEGIN/END]block survives unless it has a live justification (document each one with a comment pointing to a specific Uno bug or platform limitation that still applies). - Each ported file's port-header comment is updated to the new upstream commit.
git diff master..this-branchshows removal (not addition) of custom logic inGetAnchorForRealizationRectandGetExtentrelative to upstream parity.- Manual verification of a representative sample page (variable-height ItemsRepeater inside ScrollViewer) matches WinUI visual behavior.
Non-goals
- Fixing the
IScrollAnchorProvidergap on classicScrollViewer— tracked by feat: Implement IScrollAnchorProvider on classic ScrollViewer (CurrentAnchor, RegisterAnchorCandidate, anchor-tracking across layout) #23043. - Removing the
Math.Max(0)clamp — tracked by fix: StackLayout.GetExtent clamps extent origin to 0, breaking ItemsRepeater's negative-offset correction #23042 (but the resync should naturally not reintroduce it). - Porting
LinedFlowLayout— separate feature.
Risk / rollback
A bad resync can regress subtle behaviors (nested repeaters, BringIntoView animation, cache-building timing). Mitigations:
- Land as a single reviewable PR, not squashed with other fixes.
- Baseline the runtime-test matrix before and after.
- Capture before/after screenshots on the SamplesApp ItemsRepeater pages (
ItemsRepeaterSample,ItemsRepeaterIndexPath, etc.). - If a regression lands and can't be root-caused in review, revert the whole file to the pre-resync version and split the port into smaller chunks.
Related
- test: Add runtime tests for ItemsRepeater fast-scroll and scroll-to-top with high-variance item heights #23041 (runtime tests — land first so regressions during the resync are caught).
- fix: StackLayout.GetExtent clamps extent origin to 0, breaking ItemsRepeater's negative-offset correction #23042 (
fix: StackLayout.GetExtent clamps extent origin to 0) — should not be reintroduced by this resync. - feat: Implement IScrollAnchorProvider on classic ScrollViewer (CurrentAnchor, RegisterAnchorCandidate, anchor-tracking across layout) #23043 (
feat: Implement IScrollAnchorProvider on classic ScrollViewer) — independent feature work.
References
- Uno files live under
src/Uno.UI/UI/Xaml/Controls/Repeater/. - Port header sample:
src/Uno.UI/UI/Xaml/Controls/Repeater/ViewportManagerWithPlatformFeatures.cs:3—// ItemsRepeater.h, ItemsRepeater.cpp, commit 1cf9f1c. - Port tooling:
/winui-portClaude Code skill.
Activity
github-actions commentedon Aug 13, 2026
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
github-actions commentedon Aug 24, 2026
This issue was closed because it had no activity for 10 days after being marked as stale. If you believe this is still relevant, feel free to reopen it or open a new issue with updated context.