Skip to content

fix(scrollviewer): Clamp offset intent to the request-time extent - #23719

Open
MartinZikmund wants to merge 3 commits into
masterfrom
dev/mazi/extent
Open

MartinZikmund wants to merge 3 commits into
masterfrom
dev/mazi/extent

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #23695

PR Type:

🐞 Bugfix

What changed? 🚀

ScrollViewer.ChangeView(...) to an offset beyond the current extent chased the virtualized extent as it grew, instead of clamping to the live extent the way native WinUI (and Uno 6.5/6.6) do. With content that grows during the scroll — an ItemsRepeater with incremental loading — the viewport stayed pinned to the moving bottom edge, so every "load more when the viewport reaches the end" consumer kept re-firing and over-fetched: 15 batches / 375 items where WinUI loads 3.

Root cause. 385b6146a9 introduced an offset "intent" to preserve a ChangeView target across the extent fluctuations that a virtualized StackLayout produces while realizing (#23041). The intent was stored raw, and RecomputeOffsetsFromIntent re-applied it as clamp(intent, 0, ScrollableHeight) on every arrange. As ScrollableHeight grew, the clamp grew with it, so a request for 10_000 kept pulling the offset down until the content actually reached 10_000.

WinUI bounds the request when it is made: ScrollViewer::AdjustTargetVerticalOffset clamps against ComputePixelExtentHeight() with no intervening layout pass, and ScrollContentPresenter::SetOffsetsWithExtents stores only the ValidateInputOffset-clamped value. Later extent growth can never carry the offset past what the caller could reach at request time.

The fix. Clamp in SetVerticalOffsetIntent / SetHorizontalOffsetIntent, and route every arm site through them — public ChangeView, both scrollbar handlers, and the ScrollContentPresenter IScrollInfo setters, which previously assigned the fields directly. Also skip arming on a NaN offset or NaN bound: WinUI's ValidateInputOffset rejects those outright, and either one would otherwise freeze the recompute or store the request unbounded.

The intent still survives a transient shrink, so the #23041 behavior this regressed out of is preserved. Only requests that exceed the request-time maximum change behavior.

Validation

Runtime — Skia Desktop. The new tests fail before and pass after. The end-to-end repeater test reproduces the issue's exact reported numbers pre-fix (15 batches, 375 items, VerticalOffset=10000).

Runtime — native WinUI (WinAppSDK). When_ChangeView_BeyondExtent_* and When_ChangeView_BeforeFirstLayout_* pass unmodified against native WinUI, confirming the clamped semantics are parity rather than a guess.

Worth calling out: When_ExtentShrinksThenGrowsBack_Then_RequestedOffset_Is_Restored is [PlatformCondition(Exclude, NativeWinUI)] because native WinUI was measured to not restore the offset (it lands at 100, not 200) — its DirectManipulation pipeline drops the request permanently. Uno's restore is a deliberate divergence covering the non-monotonic extent estimate of the virtualized StackLayout. The test documents that.

Regression sweep — Skia Desktop. Given_ScrollViewer + ScrollViewerTests + Repeater (92 tests) and Given_ListViewBase + Given_ScrollContentPresenter + Given_ItemsStackPanel + ListViewTests (152 tests). Failure sets with the fix stashed and applied are identical — zero new failures. (The 4 pre-existing failures on my machine are 150%-DPI rounding artifacts.)

PR Checklist ✅

The regressing commit is on master only and was never backported to release/stable/6.6, so no released version is affected.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XbEqMr6QpVhzH9acLwTgnP

Copilot AI lite review requested due to automatic review settings July 10, 2026 09:52
@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 8m 22s —— View job


PR Review — fix(scrollviewer): Clamp offset intent to the request-time extent

Todo List

  • Gather context (PR description, changed files)
  • Review ScrollViewer.cs changes
  • Review Given_ScrollViewer_OffsetIntent.cs tests
  • Post inline comments for findings
  • Post summary

Summary

Verdict: Ship (1 nit, no blocking issues)

Root cause & fix — correct

The fix is sound. TryClampOffsetIntent stores clamp(offset, 0, ScrollableHeight_at_request_time) once, and RecomputeOffsetsFromIntent re-clamps against the live extent on every layout pass. This correctly models WinUI's two-level separation:

  • m_Offset (request-time bound, written once) → _verticalOffsetIntent
  • m_ComputedOffset (live-extent re-coerce, recomputed every pass) → VerticalOffset

The "extent shrinks then grows back" invariant from #23041 is preserved because _verticalOffsetIntent survives the transient dip — RecomputeOffsetsFromIntent re-applies it once the extent recovers.

Call-site coverage — complete

All four arm sites now route through the clamping setters:

  • Public ChangeView (guarded by !_isInternalOffsetAdjustment) ✓
  • Vertical/horizontal scrollbar handlers ✓
  • ScrollContentPresenter.SetVerticalOffset / SetHorizontalOffset ✓

Internal paths (TrimOverscroll, ChangeViewInternal) remain protected by _isInternalOffsetAdjustment. No double-arm risk.

NaN guard — justified

TryClampOffsetIntent returning false on NaN (leaving the field untouched) is the right call: a NaN intent can never be satisfied by the recompute, and a NaN bound would make Math.Clamp return a bogus value. ClearOffsetIntents() is the explicit way to disarm.

Test coverage — thorough

Five tests covering:

  1. Vertical beyond-extent ChangeView with later content growth (the reported regression)
  2. Horizontal equivalent
  3. Pre-layout ChangeView (WinUI parity: offset stays at 0)
  4. Shrink-then-grow restoration (the test: Add runtime tests for ItemsRepeater fast-scroll and scroll-to-top with high-variance item heights #23041 invariant, NativeWinUI-excluded and documented)
  5. End-to-end incremental-loading ItemsRepeater (the original issue's exact repro shape)

The #23041 test is explicitly excluded from native WinUI and documents why (WinUI's DirectManipulation pipeline drops the request permanently; Uno deliberately differs). That's the right call.

One inline finding

#if __ANDROID__ || __IOS__ || __WASM__ wrapping [Ignore] — project convention is [PlatformCondition] (see inline comment). Not a test-discovery bug but inconsistent with the established pattern.

Minor observations (not blocking)

  • WaitForOffsetAsync uses Task.Delay(50) polling — justified by native WinUI's async ChangeView behaviour, and the comment says so. The 30-attempt ceiling (1.5 s) should be sufficient for CI; WaitForIdle() follows each break path.
  • batches.Should().BeLessThan(6) — conservative threshold for a scenario that should produce ≤ 2 batches with the fix (1 initial + at most 1 triggered when the clamped offset equals the initial scrollable height). The safety margin is fine.

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.

Pull request overview

This PR fixes a ScrollViewer regression where ChangeView(...) requests beyond the current extent could “chase” a growing virtualized extent (e.g., incremental-loading ItemsRepeater), diverging from native WinUI and causing repeated over-fetch. The fix clamps the stored offset intent to the request-time scrollable extent so later extent growth cannot pull the viewport further.

Changes:

  • Clamp stored vertical/horizontal offset intent at request time via SetVerticalOffsetIntent / SetHorizontalOffsetIntent (with NaN-guarding).
  • Route scrollbar-driven intent arming through the new clamping setters (and use them from ChangeView intent capture).
  • Add runtime tests covering beyond-extent ChangeView behavior, pre-first-layout clamping, extent shrink→grow restoration, and an end-to-end incremental-loading repeater scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs Stores offset intent clamped to request-time scrollable extent (and avoids NaN intent), preventing intent from chasing later extent growth.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/ScrollViewerTests/Given_ScrollViewer_OffsetIntent.cs Adds regression tests validating WinUI-parity clamping semantics and bounding incremental-loading behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 221692 has failed on Uno.UI - CI.

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 37s —— View job


PR Review — fix(scrollviewer): Clamp offset intent to the request-time extent

Todo List

  • Gather context (PR description, previous review comments)
  • Read changed files (ScrollViewer.cs, Given_ScrollViewer_OffsetIntent.cs)
  • Review ScrollViewer.cs changes for correctness and style
  • Review test file for coverage, conventions, and style
  • Post inline comments for findings
  • Post summary

Summary

Verdict: Fix-first (2 issues blocking CI, 0 blocking logic)

ScrollViewer.cs — correct

The core fix is sound. TryClampOffsetIntent correctly guards NaN (both offset and scrollable), and ScrollableHeight/ScrollableWidth are already clamped to ≥ 0 at assignment time (Math.Max(..., 0) on line 805/809), so Math.Clamp(offset, 0, scrollable) can never be called with min > max. All four arm sites (ChangeView, scrollbar handlers, ScrollContentPresenter IScrollInfo setters) correctly route through the new clamping setters. Internal paths (TrimOverscroll, RecomputeOffsetsFromIntent) remain guarded by _isInternalOffsetAdjustment. No double-arm risk, no NaN leak.

Given_ScrollViewer_OffsetIntent.cs — 2 issues

Issue 1 — Build-breaking (CS8019): Five unused using directives (System.Collections.Generic, System.Linq, Microsoft.UI.Xaml.Media, Windows.Foundation, Windows.UI). TreatWarningsAsErrors=true in Directory.Build.props:249 promotes CS8019 to an error; this is the likely cause of the CI failure from build 221692. One-click suggestion posted.

Issue 2 — Convention (already flagged in prior review, still present): #if __ANDROID__ || __IOS__ || __WASM__ wrapping [Ignore] instead of [PlatformCondition]. The rule is to express platform skips via [PlatformCondition] so the skip reason and platform set appear in test metadata. One-click suggestion posted (collapses the two attributes into one).

Test coverage — thorough

Five tests covering the regression, its horizontal counterpart, the pre-layout clamp, the #23041 shrink/grow invariant (correctly excluded from native WinUI with documented rationale), and an end-to-end incremental-loading ItemsRepeater scenario. The WaitForOffsetAsync polling pattern and the batches < 6 conservative threshold are both well-justified by the PR description.

@MartinZikmund
MartinZikmund enabled auto-merge July 13, 2026 13:24
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 221951 has failed on Uno.UI - CI.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 25s —— View job


PR Review — fix(scrollviewer): Clamp offset intent to the request-time extent

Todo List

  • Gather context (PR description, previous review comments)
  • Read current state of changed files
  • Review ScrollViewer.cs changes
  • Review Given_ScrollViewer_OffsetIntent.cs tests
  • Post inline comments for any findings
  • Post summary

Summary

Verdict: Ship (1 nit, no blocking issues)

Previously flagged issues — both resolved in 034c5240

The two CI-blocking findings from the last review pass are fixed:

  • ✅ Five unused using directives removed (CS8019 build-break)
  • ✅ #if __ANDROID__ || __IOS__ || __WASM__ + [Ignore] replaced with [PlatformCondition] on When_ChangeView_BeyondExtent_On_IncrementallyLoadingRepeater

ScrollViewer.cs — correct

TryClampOffsetIntent correctly guards NaN on both offset and scrollable, and ScrollableHeight/ScrollableWidth are always ≥ 0 at assignment time (Math.Max(..., 0) on lines 805/809), so Math.Clamp(offset, 0, scrollable) is called only when min ≤ max. All four arm sites (public ChangeView, scrollbar handlers, ScrollContentPresenter ISCP setters) route through the clamping setters. Internal paths (TrimOverscroll, RecomputeOffsetsFromIntent) remain guarded by _isInternalOffsetAdjustment. The #23041 shrink/grow invariant is preserved: the stored intent (bounded at request time, e.g. 200) survives a transient dip to 100 and is re-coerced correctly when the extent recovers.

Given_ScrollViewer_OffsetIntent.cs — 1 nit

One nit — platform exclusions on When_ExtentShrinksThenGrowsBack (inline comment posted).
The test uses WaitForOffsetAsync, the same polling helper that When_ChangeView_BeyondExtent_On_IncrementallyLoadingRepeater uses — and that test has explicit NativeAndroid | NativeIOS | NativeWasm exclusions for "async native scrolling". More significantly, the behavior under test is Uno-specific: RecomputeOffsetsFromIntent is the Uno-managed path that restores the offset when the extent grows back; on native platforms the layout cycle invokes native scroll internals rather than the managed UpdateDimensionProperties path, so restoration may not occur. Without these exclusions, the test could produce native-platform failures identical to the NativeWinUI case you already exclude.

Note: CI skips native runtime tests on PRs (f2808eab), so this won't block the current CI run — but it's worth fixing before native runs encounter it.

@MartinZikmund

Copy link
Copy Markdown
Member Author

Review comments addressed

Pushed commit 034c5240f1b0dbb778e680c1cac8c10f15650f2f to dev/mazi/extent. The four open threads reduce to two distinct issues (each reported by two bots), both in Given_ScrollViewer_OffsetIntent.cs. Both are now fixed.

Fixed (4)

file:line reviewer point what changed
Given_ScrollViewer_OffsetIntent.cs:16 (copilot) Unused usings will trip CS8019 under TreatWarningsAsErrors. Removed the five unused usings — System.Collections.Generic, System.Linq, Microsoft.UI.Xaml.Media, Windows.Foundation, Windows.UI. Kept System (Math.Abs), System.Collections.ObjectModel (ObservableCollection), System.Threading.Tasks, the three Microsoft.UI.Xaml*, Microsoft.VisualStudio.TestTools.UnitTesting, Private.Infrastructure, and Uno.UI.RuntimeTests.Helpers.
Given_ScrollViewer_OffsetIntent.cs:16 (github-actions) Same five unused usings; build-breaking. Same removal — landed on exactly the keep-list the bot proposed.
Given_ScrollViewer_OffsetIntent.cs:171 (github-actions) Prefer [PlatformCondition] over #if + [Ignore] so the skip reason/platforms show in test metadata. Dropped the #if __ANDROID__ || __IOS__ || __WASM__ / [Ignore] block and merged the native skips into the existing attribute: [PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.NativeWinUI | NativeAndroid | NativeIOS | NativeWasm)] // async native scrolling.
Given_ScrollViewer_OffsetIntent.cs:171 (github-actions) Same convention point (the additive one-line variant). Used the merged single-attribute form rather than adding a second [PlatformCondition], since a duplicate attribute would not compile. This covers both line-171 threads.

Notes on the second fix: the two suggested variants differed — one added a separate [PlatformCondition] alongside the existing NativeWinUI one, the other merged them. Only the merged form is valid (two [PlatformCondition] attributes on one method won't compile), so I used that. The switch from #if (which would also gate the Skia mobile/WASM heads) to the Native* flags is intentional and matches the test's stated reason — "async native scrolling" is a native-platform concern, and Skia scrolling is managed — consistent with .claude/rules/runtime-tests.md.

Changes were reviewed by inspection only; I did not build or run anything. Azure Pipelines CI will verify.

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 35s —— View job


PR Review — fix(scrollviewer): Clamp offset intent to the request-time extent

Todo List

  • Gather context (PR description, previous review comments)
  • Read current state of changed files
  • Review ScrollViewer.cs changes
  • Review Given_ScrollViewer_OffsetIntent.cs tests
  • Post inline comments for findings
  • Post summary

Summary

Verdict: Ship — no new findings.

All three previously flagged issues resolved

Commit Finding Status
034c5240 Five unused using directives (CS8019 build-break) ✅ Fixed
034c5240 #if __ANDROID__ || __IOS__ || __WASM__ + [Ignore] on the incremental-loading test ✅ Fixed
6343fcb8 When_ExtentShrinksThenGrowsBack missing NativeAndroid | NativeIOS | NativeWasm exclusions ✅ Fixed

ScrollViewer.cs — correct

TryClampOffsetIntent NaN-guards both offset and scrollable correctly, and ScrollableHeight/ScrollableWidth are always ≥ 0 at assignment time (Math.Max(..., 0)), so Math.Clamp(offset, 0, scrollable) is never called with min > max. All four arm sites route through the clamping setters; internal paths (TrimOverscroll, RecomputeOffsetsFromIntent) remain guarded by _isInternalOffsetAdjustment. The #23041 shrink/grow invariant is preserved: the stored intent survives the transient dip and is re-coerced when the extent recovers.

Given_ScrollViewer_OffsetIntent.cs — correct

Five tests cover the full behavioral envelope: the reported regression and its horizontal counterpart, the pre-layout zero-extent clamp (WinUI parity), the #23041 shrink/grow restoration (now correctly excluded from all native platforms including NativeAndroid | NativeIOS | NativeWasm), and the end-to-end incremental-loading ItemsRepeater scenario. The WaitForOffsetAsync polling pattern and the batches < 6 conservative threshold are both justified.

@MartinZikmund
MartinZikmund disabled auto-merge July 16, 2026 07:45
@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings August 22, 2026 09:47

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +241 to +244
batches.Should().BeLessThan(6,
$"a single beyond-extent ChangeView must clamp to the live extent and stop triggering incremental loads. "
+ $"Loaded {batches} batches ({source.Count} items); VerticalOffset={sut.VerticalOffset:F2}, "
+ $"ExtentHeight={sut.ExtentHeight:F2}.");
@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 17s —— View job


PR Review — fix(scrollviewer): Clamp offset intent to the request-time extent

Todo List

  • Gather context (PR description, previous review comments)
  • Read current state of changed files
  • Review ScrollViewer.cs changes
  • Review Given_ScrollViewer_OffsetIntent.cs tests
  • Post inline comments for findings
  • Post summary

Summary

Verdict: Ship — no new findings. All previously flagged issues are resolved.

All prior findings resolved

Commit Finding Status
77025c34 Five unused using directives (CS8019 build-break) ✅ Fixed
77025c34 #if __ANDROID__ || __IOS__ || __WASM__ + [Ignore] on the incremental-loading test ✅ Fixed (merged into single [PlatformCondition])
715885f7 When_ExtentShrinksThenGrowsBack missing NativeAndroid | NativeIOS | NativeWasm exclusions ✅ Fixed

ScrollViewer.cs — correct

TryClampOffsetIntent guards NaN on both offset and scrollable, and ScrollableHeight/ScrollableWidth are always ≥ 0 at assignment time (Math.Max(..., 0)), so Math.Clamp(offset, 0, scrollable) is never called with min > max. All four arm sites (public ChangeView, scrollbar handlers, ScrollContentPresenter ISCP setters) route through the clamping setters. Internal paths (TrimOverscroll, RecomputeOffsetsFromIntent) remain guarded by _isInternalOffsetAdjustment. The #23041 shrink/grow invariant is preserved: the stored intent survives the transient dip and is re-coerced when the extent recovers.

The pre-layout case (ChangeView(double.MaxValue) before first layout) is correctly handled: Math.Clamp(double.MaxValue, 0, 0) = 0, so the intent is stored as 0, and RecomputeOffsetsFromIntent never re-drives it once content arrives.

Given_ScrollViewer_OffsetIntent.cs — correct

Five tests cover the full behavioral envelope:

  1. When_ChangeView_BeyondExtent_Then_ExtentGrowth_Does_Not_Move_Offset — the primary regression
  2. When_ChangeView_BeyondExtent_Horizontal_Then_ExtentGrowth_Does_Not_Move_Offset — horizontal equivalent
  3. When_ChangeView_BeforeFirstLayout_Then_Offset_Stays_At_Top — zero-extent clamp (WinUI parity, confirmed against native WinUI)
  4. When_ExtentShrinksThenGrowsBack_Then_RequestedOffset_Is_Restored — #23041 invariant, now correctly excluded from NativeWinUI | NativeAndroid | NativeIOS | NativeWasm
  5. When_ChangeView_BeyondExtent_On_IncrementallyLoadingRepeater_Then_Loading_Is_Bounded — end-to-end regression repro, excluded from all native targets

The WaitForOffsetAsync polling helper (30 × 50 ms) and the conservative batches < 6 threshold are both justified.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund changed the base branch from master to feature/breakingchanges August 22, 2026 14:40
@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 46s —— View job


PR Review — fix(scrollviewer): Clamp offset intent to the request-time extent

Todo List

  • Gather context (PR description, previous review comments)
  • Read current state of changed files
  • Review ScrollViewer.cs changes
  • Review Given_ScrollViewer_OffsetIntent.cs tests
  • Post inline comments for any findings
  • Post summary

Summary

Verdict: Ship (1 nit, same as prior Copilot finding — still unaddressed)

All previously flagged issues remain resolved

Commit Finding Status
0b239c14 Five unused using directives (CS8019 build-break) ✅ Fixed
0b239c14 #if __ANDROID__ || __IOS__ || __WASM__ + [Ignore] on incremental-loading test ✅ Fixed
fb0d1d66 When_ExtentShrinksThenGrowsBack missing NativeAndroid | NativeIOS | NativeWasm exclusions ✅ Fixed

ScrollViewer.cs — correct

TryClampOffsetIntent guards NaN on both offset and scrollable, and ScrollableHeight/ScrollableWidth are always ≥ 0 at assignment time (Math.Max(..., 0)), so Math.Clamp(offset, 0, scrollable) is never called with min > max. All four arm sites (public ChangeView, scrollbar handlers, ScrollContentPresenter ISCP setters) route through the clamping setters. Internal paths (TrimOverscroll, RecomputeOffsetsFromIntent) remain guarded by _isInternalOffsetAdjustment. The #23041 shrink/grow invariant is preserved: the stored intent survives the transient dip and is re-coerced when the extent recovers.

Given_ScrollViewer_OffsetIntent.cs — 1 nit

One nit (inline comment posted, same concern Copilot raised): When_ChangeView_BeyondExtent_On_IncrementallyLoadingRepeater_Then_Loading_Is_Bounded at line 241 asserts only batches < 6. If ViewChanged never fires (scroll is a no-op, dispatch is lost), batches == 1 satisfies the upper bound and the test silently passes without exercising the load trigger. With the fix the expected stable count is 2 (initial + one triggered by the clamped scroll reaching ScrollableHeight), so a batches.Should().BeGreaterThan(1) guard is both correct and tight. Suggestion posted inline.

}
}

batches.Should().BeLessThan(6,

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.

Nit: missing lower-bound guard — test can silently pass without exercising the trigger.

batches < 6 is an upper bound only. If ViewChanged never fires (e.g. the scroll is a no-op, or the DispatcherQueue.TryEnqueue dispatch is lost), batches stays at 1 and 1 < 6 passes without the incremental-load path ever running.

With the fix in place the expected flow is: initial load (1 batch) → ChangeView scrolls to the clamped extent → ViewChanged fires because VerticalOffset == ScrollableHeight → one more batch (2 total) → new ScrollableHeight exceeds the clamped intent so the trigger no longer fires → stable. So a lower bound of 2 is both correct and tight.

Suggested change
batches.Should().BeLessThan(6,
batches.Should().BeGreaterThan(1,
$"the ChangeView must have scrolled to the live extent and triggered at least one incremental load. "
+ $"Loaded {batches} batches ({source.Count} items); VerticalOffset={sut.VerticalOffset:F2}, "
+ $"ExtentHeight={sut.ExtentHeight:F2}.");
batches.Should().BeLessThan(6,

(The suggestion replaces line 241 — add the BeGreaterThan assertion above the existing BeLessThan line.)

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 229491 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 170

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Focus_FocusVisual_Properties.png-dark
    • CalendarView_Theming.png-dark
    • ContextRequested.png-dark
    • ContentControl_Inheritance.png
    • DynamicFont.png
    • Examples.png
    • ImageBrush_Stretch.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Image_Margin_Large.png
    • DropDownButtonPage.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Attributed_text_FontSize_Changing.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
  • skia-windows-screenshots: 170 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Battery.png-dark
    • Contacts_Pick.png-dark
    • Contacts_Pick.png
    • GeolocatorPositionChanged.png-dark
    • GeolocatorPositionChanged.png
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • ElementLevelTheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • ExpanderColorValidationPage.png-dark
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • ImageBrush_Stretch.png
    • Examples.png
    • GetFocus.png-dark
    • GetFocus.png
    • Image_Placeholder.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 229491 has failed on Uno.UI - CI.

MartinZikmund and others added 3 commits August 29, 2026 12:10
 #23695)

ChangeView stored the caller's requested offset unclamped, and the
post-layout recompute re-applied it as clamp(intent, 0, ScrollableHeight)
on every arrange. A beyond-extent request therefore chased the extent as
virtualized content realized: the viewport stayed pinned to the moving
bottom edge, so incremental-loading consumers kept firing and over-fetched
(15 batches / 375 items where WinUI and Uno 6.5/6.6 load 3).

WinUI bounds the request when it is made: ScrollViewer::AdjustTargetVerticalOffset
clamps against ComputePixelExtentHeight with no intervening layout pass,
and ScrollContentPresenter::SetOffsetsWithExtents stores only the
ValidateInputOffset-clamped value. Later extent growth can never carry the
offset past what the caller could reach at request time.

Clamp in SetVerticalOffsetIntent/SetHorizontalOffsetIntent and route every
arm site through them (ChangeView, both scrollbar handlers, and the
ScrollContentPresenter ISCP setters, which previously assigned the fields
directly). Also skip arming on a NaN offset or NaN bound, which WinUI's
ValidateInputOffset rejects outright and which would otherwise freeze the
recompute or store the request unbounded.

The intent still survives a transient shrink, so the #23041 fix this
regressed out of is preserved.

Validated at runtime on Skia Desktop (fail-before/pass-after; the
end-to-end repeater test reproduces the reported 15 batches / 375 items /
VerticalOffset=10000 pre-fix) and against native WinUI, where the
beyond-extent and pre-first-layout tests pass unmodified. Regression sweep
over ScrollViewer/Repeater/ListViewBase/ScrollContentPresenter/ItemsStackPanel
shows an identical failure set before and after.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XbEqMr6QpVhzH9acLwTgnP
Remove five unused usings (CS8019 build-break under TreatWarningsAsErrors)
and replace the #if/[Ignore] native skip with a merged [PlatformCondition]
so the skip reason and platforms are visible in test metadata.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GKBgQoAmRmaFoXXZr93iLB
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 230988 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 219

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ContentControl_Inheritance.png
    • Attributed_text_FontSize_Changing.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CalendarView_Theming.png-dark
    • DynamicFont.png
    • Examples.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageBrush_Stretch.png
    • Buttons.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • DropDownButtonPage.png-dark
  • skia-windows-screenshots: 219 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Grid_ScrollViewer.png-dark
    • Grid_ScrollViewer.png
    • EllipseAlignment2542_2547.png-dark
    • EllipseAlignment2542_2547.png
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • DataTransferManager.png-dark
    • DataTransferManager.png
    • Grid_with_MinWidthColumns.png-dark
    • Grid_with_MinWidthColumns.png
    • Hyperlink_Button.png-dark
    • Hyperlink_Button.png
    • Hyperlink_CanExecute_False.png-dark
    • Hyperlink_CanExecute_False.png
    • Hyperlink_Disabled.png-dark
    • Hyperlink_Disabled.png
    • Basics Pivot Test.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 230988 has failed on Uno.UI - CI.

@MartinZikmund
MartinZikmund changed the base branch from feature/breakingchanges to master September 2, 2026 20:02
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231695 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Focus_FocusVisual_Properties.png-dark
    • ImageIconPage.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
  • skia-windows-screenshots: 2310 changed over 2402

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarToggleButtonTest.png
    • AppWindowFeatures.png-dark
    • AppWindowTitleBar Properties.png-dark
    • Arrange_Performance01.png
    • AutoBorderStretchwithbottommargin.png
    • AutoSuggestBoxChosenSuggestion.png-dark
    • BackGesture.png-dark
    • Basics Pivot Test.png
    • BeginTime_MultipleAnimations.png
    • BenchmarkDotNet.png-dark
    • BorderRightwithmargins.png-dark
    • BorderRightwithmargins.png
    • Border_CornerRadius_Alignments.png
    • Border_CornerRadius_Binding.png-dark
    • Border_Simple_No_Background.png
    • Border_Simple_No_Background_With_Content_Border_With_Background.png-dark
    • Brushes_ImplicitConvert.png
    • ButtonClippingTestsControl.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 231695 has failed on Uno.UI - CI.

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Request-time bounding is the right direction, but the new clamp misses WinUI's target-zoom behavior for a combined ChangeView request. Also, retain the explicit compatibility note already in the test: restoring the old intent after an extent shrinks and regrows is an intentional Uno-specific behavior, not native WinUI parity.

// realization shrink that a virtualized StackLayout's extent estimate produces (#23041).
internal void SetVerticalOffsetIntent(double offset)
{
if (TryClampOffsetIntent(offset, ScrollableHeight, out var clamped))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P2] Clamp combined ChangeView requests using the target zoom

ChangeView arms this intent before applying its zoomFactor, so ScrollableHeight/Width still describe the old zoom. With unzoomed extent 400, viewport 200, current zoom 1, ChangeView(null, 400, 2, true) stores an intent of 200 even though 400 is valid in the target zoom's 600-pixel scrollable range. RecomputeOffsetsFromIntent can subsequently pull the offset back to 200.

WinUI's AdjustTargetVerticalOffset explicitly computes unzoomed extent * targetZoomFactor before clamping (and the horizontal path does likewise): https://github.com/microsoft/microsoft-ui-xaml/blob/439bda90582f7892ca595a193f55dbfc6ae2010c/dxaml/xcp/dxaml/lib/ScrollViewer_Partial.cpp#L12230-L12264 . Thread the effective target zoom into intent capture, and add combined zoom/offset regression coverage.

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.

Regression: ScrollViewer.ChangeView beyond the extent chases the growing virtualized extent (breaks WinUI parity; over-fetches incremental loading)

7 participants