Skip to content

fix(itemsrepeater): Extent origin reset, default-layout cache, WinUI rounding - #25078

Merged
MartinZikmund merged 5 commits into
masterfrom
dev/mazi/repeater-side-fixes
Oct 9, 2026
Merged

MartinZikmund merged 5 commits into
masterfrom
dev/mazi/repeater-side-fixes

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #25076

PR Type:

🐞 Bugfix

What changed? 🚀

Three ItemsRepeater fixes split out of the LinedFlowLayout port (#23691), because LinedFlowLayout doesn't need any of them:

  • StackLayout extent origin (Uno-only workaround): the held origin is now versioned, so it gets dropped when Orientation or Spacing changes, and it is reset when the layout state is (un)initialized for a context. Before, an outdated origin could offset the whole list.
  • Default-layout cache growth: ViewportManagerWithPlatformFeatures.RegisterCacheBuildWork no longer requires Layout != null, which matches WinUI 2.5.1. A repeater on its default StackLayout now builds its cache buffer.
  • Rounding: FlowLayout.GetAverageLineInfo, FlowLayoutAlgorithm.LayoutRound and StackLayout's average element size use MidpointRounding.AwayFromZero, matching C++ round().

Each fix is followed by its own test commit (Given_ItemsRepeater_FastScroll extent-origin tests, Given_ItemsRepeater.When_No_Layout_Set_Then_Default_StackLayout_Grows_Cache). The rounding fix has no dedicated test.

Validation (Skia desktop, runtime tests): all 46 tests in Given_ItemsRepeater, Given_ItemsRepeater_FastScroll and LayoutTests pass. With the source fixes reverted to master:

  • When_No_Layout_Set_Then_Default_StackLayout_Grows_Cache and When_LayoutStateReusedForNewContext_Then_ExtentOriginIsReset fail, so these two are proven fixes.
  • With the internal version asserts removed, When_OrientationChanges_… still passes on master, as do When_ItemsSourceReplaced_… and When_ScrollingForward_…. The Orientation/Spacing version counter is therefore defensive hardening: no visible symptom is reproduced yet. The other two act as regression guards.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_011swjKyeQhuwHxAJW5R1vk8

MartinZikmund and others added 5 commits October 7, 2026 14:37
The origin StackLayout holds across measure passes outlived changes to
Orientation and Spacing, and a layout state reused for a new context,
offsetting the list by the stale value. Version the held origin and
reset it on context (un)initialization.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011swjKyeQhuwHxAJW5R1vk8
ViewportManagerWithPlatformFeatures skipped cache build work when
Layout was null, so a repeater on its default StackLayout never
realized beyond the viewport. WinUI 2.5.1 has no such check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011swjKyeQhuwHxAJW5R1vk8
The ported layouts use C round(), which rounds halves away from zero;
Math.Round defaults to banker's rounding, so x.5 averages and layout
rounding landed one unit short half the time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011swjKyeQhuwHxAJW5R1vk8
Copilot AI balanced review requested due to automatic review settings October 7, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 19s —— View job


Review of #25078

Verdict: ship. I found 0 blocking issues and posted no inline comments.

I reviewed the diff by inspection only. I did not build the code or run any tests. The pass/fail results in the PR description are the author's own and I haven't confirmed them.

Review notes

  • Cache growth fix is a root-cause fix. It removes the Layout != null precondition to match WinUI. I checked the rest of ViewportManagerWithPlatformFeatures: the only other m_owner.Layout use is null-safe (Layout?.LayoutId), so a null layout can't cause a new NRE.
  • Extent-origin reset is a root-cause fix. Resetting in InitializeForContext and UninitializeForContext addresses a stale origin carried across contexts, and the PR shows a test that fails on master.
  • Version counter on Orientation/Spacing changes is defensive hardening, and the PR description says so. The uint.MaxValue sentinel can collide with the counter only after about 4 billion property changes, which is not a concern.
  • Rounding with MidpointRounding.AwayFromZero matches C++ round() and is applied consistently at all call sites. The PR description notes there is no dedicated test. A small unit-level check of a .5 midpoint, such as an average line size of 2.5 expected to give 3, would be cheap to add. It is optional.
  • Style and conventions: tabs and braces are fine, #if HAS_UNO guards the Uno-only changes in the shared .mux.cs files, and the commits follow Conventional Commits. I saw no skipped or ignored tests.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 237883 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 1191

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • DisplayInformation.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • DropDownButtonPage.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
  • skia-windows-screenshots: 1191 changed over 2474

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonWithIconTest.png-dark
    • AutoSizedPathCentered.png-dark
    • AutoSuggestBox_BitmapIcon.png-dark
    • BackGesture.png-dark
    • Basics_Automated.png-dark
    • BorderCenteredwithmargins.png-dark
    • BorderCenteredwithmargins.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
    • BorderTopwithmargins.png-dark
    • BorderTopwithmargins.png
    • Border_AntiAlias.png-dark
    • Border_AntiAlias.png
    • Border_Simple.png-dark
    • Border_Simple.png
    • Buttons.png-dark
    • Buttons.png
    • Capture with overlap.png-dark
    • Capture with overlap.png
    • ColorAnimationUsingKeyFrames_Fill.png-dark

@MartinZikmund MartinZikmund added 7.1 PRs only. For issues, use the Release field. and removed 7.1 PRs only. For issues, use the Release field. labels Oct 9, 2026
@MartinZikmund
MartinZikmund merged commit 738a2f6 into master Oct 9, 2026
56 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/repeater-side-fixes branch October 9, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ItemsRepeater: stale StackLayout extent origin, no cache growth without a Layout, rounding differs from WinUI

3 participants