Repository navigation
perf(scrollviewer): Drive fling and wheel motion per frame - #24739
Conversation
|
Claude finished @MartinZikmund's task in 6m 51s —— View job Review complete
Verdict: fix-first (no blocking correctness bugs found; two non-blocking findings posted inline). Findings (2, both minor/moderate, both on
What held up well under review:
|
68b21a3 to
1b10269
Compare
|
Claude finished @MartinZikmund's task in 4m 12s —— View job Review complete
Verdict: fix-first — one new blocking-on-principle finding, everything else clean. Findings this pass: 1 (moderate).
What held up well in the new commits:
Still open from the earlier review (files unchanged by this update, so not re-flagged inline to avoid duplicates):
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Motion can drop release deltas and final notifications, while precision-wheel and platform-parity goals remain incomplete.
Review effort: Balanced
Findings: 4
Open (4)
What changed in this PR
Reworks legacy ScrollViewer motion around frame-driven wheel decay, fitted touch velocity, and platform-specific fling simulations. It also updates animated ChangeView behavior and adds regression coverage.
Changes:
- Adds frame-driven wheel and fling simulations.
- Removes touch-delta quantization and revises animated scrolling.
- Adds unit and runtime tests for motion behavior and lifecycle cleanup.
Six unresolved correctness and parity issues were identified.
| File | Description |
|---|---|
IDirectManipulationHandler.cs |
Adds inertia-interruption notification. |
DirectManipulation.cs |
Enables unquantized deltas and interruption handling. |
ScrollVelocityTracker.cs |
Adds least-squares velocity estimation. |
ScrollFlingSimulation.cs |
Adds platform-selected fling curves. |
ScrollDecaySimulation.cs |
Adds wheel impulse decay. |
ScrollContentPresenter.Managed.cs |
Integrates frame-driven motion and animation changes. |
ScrollContentPresenter.cs |
Routes wheel input into decay simulations. |
GestureRecognizer.Manipulation.InertiaProcessor.cs |
Removes ineffective finalizer cleanup. |
GestureRecognizer.Manipulation.cs |
Exposes input timestamps and unquantized updates. |
GestureRecognizer.cs |
Adds direct-manipulation delta configuration. |
Given_ScrollVelocityTracker.cs |
Tests velocity fitting behavior. |
Given_ScrollViewer.cs |
Adds scrolling and lifecycle regressions tests. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
f0b130a to
5e602f8
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 3
Open (8)
Compositor.GetDefaultEasingFunction()is very likely calling a non-existent static API (and… · NewOnInertiaInterruptedstops the drivers but never publishes a non-intermediate final offset. Given… · New This branch explicitly relies onOnCompletedto publish final offsets, but it clears… · New The decision to publish the final offsets is coupled to_touchInertiabeing non-null at the… · New Android fling duration and curve do not match platform behavior Preserve fractional horizontal precision-wheel deltas Apply final drag delta before starting the fling Publish final offset when press interrupts fling
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 4
Open (9)
This early-return leavesunhandledDeltaunchanged for inertial updates. When this presenter has… · New This branch explicitly relies onOnCompletedto publish final offsets, but it clears…OnInertiaInterruptedstops the drivers but never publishes a non-intermediate final offset. Given…Compositor.GetDefaultEasingFunction()is very likely calling a non-existent static API (and… The decision to publish the final offsets is coupled to_touchInertiabeing non-null at the… Android fling duration and curve do not match platform behavior Preserve fractional horizontal precision-wheel deltas Apply final drag delta before starting the fling Publish final offset when press interrupts fling
|
Claude finished @MartinZikmund's task in 5m 39s —— View job Review complete
Verdict: fix-first2 new findings this pass, both confirmed by independent derivation (not just repeating bot output):
Investigated and ruled out (not re-flagged):
|
|
Claude finished @MartinZikmund's task in 6m 13s —— View job Review complete
Verdict: fix-first. 3 new findings posted inline, all moderate severity — no crashes or data loss, but each works against a correctness/parity goal this PR explicitly sets out to achieve. Previously-flagged issues — confirmed resolved, not re-flagged:
New findings this pass (3, all unaddressed from Copilot's automated pass — confirmed independently):
Cross-cutting: no SOLID/layering issues, no banned |
WinUI's ScrollViewer animates ChangeView through DirectManipulation, so the curve is not in the XAML sources. Measured on WinUI 1.8 (throwaway oracle, 90 runs at 100% and 250% scale): 1.4ms per physical pixel within [175, 475]ms, along a curve a quartic ease-out fits as well as any. A completed animation publishes its exact target as the final offset. IsScrollAnimationInProgress covers the zoom animation too, which arranges the ScrollViewer when it ends so the offset recompute runs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Easing is checked per frame from the animation's first moving frame, so a slow first frame does not count against it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
CalendarPanel scrolls to an offset taken from its own estimated bounds, ahead of the extent the ScrollViewer was arranged with, like ListView's layout compensation: route it through ChangeViewForLayoutAdjustment so the request-time intent clamp does not cut it to the stale range. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Wrapping a [TestMethod] in #if breaks test discovery: exclude NativeWinUI with PlatformCondition and keep #if inside the bodies instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
- Only along the axes the gesture moves this content: the velocity fit runs on the raw pointer, which drifts across a railed axis (whose recognizer velocity is zeroed) or one this presenter cannot scroll. - The release is a velocity sample too, as in Android's VelocityTracker: a finger that rested before lifting sends no move while still, so only the release shows the gap. The tracker then reports zero rather than no data, which fell back to the recognizer's stale fast velocity. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
A Set that takes over a running scroll animation (wheel decay, touch, another ChangeView) stopped it, and its Stopped handler published a final ViewChanged in the middle of the motion that replaced it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
WinUI's ScrollViewer.IsInManipulation covers a touch manipulation and the DirectManipulation inertia, snap and animated view changes that follow it. Uno drives those from the presenter and never set IsInDirectManipulation, so FlipView's FixOffset timer, which waits while IsInManipulation is true, could fire mid-snap and pull the view back to the previous item. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
The landing and the room check used position + velocity / lambda, which each frame preserves in theory but not in floating point: five 4px detents came to rest on 19.999999999999996, and the next ones on 79.99999999999999 with an 80px scrollable height, short of the end. Keep the target as the sum of the impulses instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
IsScrollAnimationInProgress read the animation's wall-clock Remaining, which hits zero before a late last frame applies and publishes the final offsets. FlipView's offset fix could then run mid-snap and scroll back. Track the running animation until it stops instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
The offset fix armed by sizing could still be pending when the flick started. Postponed to the end of the manipulation, it suppresses the snap's selection change and scrolls back, exactly as WinUI's FixOffset does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy
The release repeats the last move's position, so fitting it as a sample shrinks the fling velocity and can even reverse it. Like Android, only its time is used, to detect a finger that rested before lifting. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HAeXvsKrnYPF97TrJye7CZ
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HAeXvsKrnYPF97TrJye7CZ
bfc9946 to
1e8e0e7
Compare
|
Claude finished @MartinZikmund's task in 13s —— View job Re-review (synchronize)Verdict: ship. No new findings, no inline comments. New since the last round:
Still open, optional:
Not code-related:
I made no code changes and did not build or run tests. This was a code-only check. |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24739/wasm-skia-net9/index.html |
|
The build 238789 found UI Test snapshots differences: Details
|


GitHub Issue: closes #23985
PR Type:
🐞 Bugfix
What changed? 🚀
Legacy ScrollViewer motion rework:
Unquantized direct-manipulation deltas: slow touch drags no longer move in ≥2 px jumps.
Fling launch velocity from a least-squares
ScrollVelocityTracker; closed-form fling curves matching the host platform:OverScroller's actual spline (SPLINE_POSITIONBézier,getSplineFlingDuration/getSplineFlingDistance), solved exactly so the fling leaves at its launch velocity. On Android (and Android browsers) the physical coefficient uses 160 logical px per inch, since Uno's logical pixel is a dp there; elsewhere a 1/96 in DIP.UIScrollView's deceleration.The release's own movement is applied before the fling starts (the recognizer commits it without an
Updatedevent).Wheel/touchpad motion driven per frame; each notch adds to the motion instead of restarting a 1 s ease (curve itself replaced in fix(scrollviewer): Scroll by wheel like WinUI #24740). A notch during an animated
ChangeViewcontinues from where the content is drawn, a notch too fine to move a pixel no longer chains to a parent, and unloading mid-decay publishes the final offset.Animated
ChangeViewmatches WinUI'sScrollViewer, measured on WinUI 1.8 with a throwaway oracle app (its animation lives in DirectManipulation, not in the XAML sources): 1.4 ms per physical pixel within [175, 475] ms (fit over 90 runs at 100 % and 250 % scale, rms 5.7 ms), on a curve a quartic ease-out fits as well as any tested one. The finalViewChangedreports the exact target.CI fix — offset intent clamped at request time, as WinUI does (
SetVerticalOffsetPrivate/AdjustTargetVerticalOffset, with the target zoom). The intent used to keep the raw request, soChangeView(null, 10000)on an incrementally loading list kept re-seating the offset to each new end and loading batch after batch until it reached 10000. That madeGiven_ListViewBase.When_Incremental_Load_Defaultfail on the desktop legs. The bug is latent on master; this PR's timing exposed it. The oracle confirms WinUI keeps the request-time clamp when the extent grows, and drops aChangeViewissued before layout. ListView's own layout compensation keeps the raw intent (its extent runs ahead of the ScrollViewer's), and Hot Reload's offset restore waits for the layout to fit the saved offset.A fling launches only from the gesture's own motion. It doesn't move along an axis the drag was railed to (or one this presenter can't scroll); before, a near-vertical flick drifted 283 px sideways. A finger that rested before lifting no longer flings at its earlier drag speed. As in Android's VelocityTracker, the release is not fitted as a sample: it repeats the last move's position, and fitting it shrank the velocity or even reversed a short flick (a flick after several the other way could coast back the original way). Only its time counts: a release more than 40 ms after the last move reports zero velocity. Synthetic flicks at -2 px/ms released 2/6/12 ms after the last move gave -1.75/-1.11/-0.35 before and -2.00 after; a short 3-move flick gave +0.21 (reversed) before and -2.75 after. Confirmed on a Galaxy Z Fold7.
The wheel decay lands exactly on the sum of its notches: it projected
position + velocity / λ, which drifts in floating point, so five 4 px notches came to rest on 19.999999999999996 and the end of an 80 px extent on 79.99999999999999 (When_Nested_ScrollViewers_WheelChangedfailed on the desktop legs, masked by retries). fix(scrollviewer): Scroll by wheel like WinUI #24740's wheel curve already keeps an exact target.A scroll animation replaced by another motion (wheel, touch, another ChangeView) no longer reports a final
ViewChangedin the middle of that motion.ScrollViewer.IsInManipulationcovers the presenter-driven touch manipulation, fling, snap and animated scrolls, as WinUI's DirectManipulation state does. FlipView'sFixOffsetwaits on it; before, it could fire mid-snap and pull the view back to the previous item.CalendarView's scroll-into-view uses the panel's own estimated extent, so it keeps the raw intent like ListView's layout compensation.
Evidence (Win32 119 Hz, probe medians of 3 interleaved pairs, with the layers below): ScrollViewer wheel-burst newFps 90 → 120, judder 3.0 → 0.7 px; touchpad 89 → 120; repeated presents ~35 → 0. iPhone 13 Pro 120 Hz touch-drag max step 48 → 9 px after the frame-clock fixes.
When_Incremental_Load_Defaultwith the process pinned to one core, to mimic CI agents: about 50 % failures before, 5/5 runs green after (withWhen_Incremental_Load_ShouldStop).Tests (Unit):
Given_ScrollVelocityTrackercovers release timing: a release shortly after the last move keeps the motion's slope and direction, a late one reports zero.Tests (Runtime): wheel notches land on whole pixels, railed flick stays on its axis, rested finger doesn't fling, one final ViewChanged when the wheel takes over an animation, fling distance, unload mid-fling, slow drag, 5 notches → one final ViewChanged, OverScroller spline (against AOSP's own
SPLINE_POSITIONloop), release delta, ChangeView past the extent (WinUI-verified), fine wheel delta not chaining, wheel during an animated ChangeView, unload mid-decay, ChangeView easing and duration, final offset. The new ones fail on the source before their fix (the short-hop duration and final-offset tests are parity checks that also pass there).Measured with the scroll-smoothness probe from #24711 (
sample=Scrolling/ScrollSmoothnessTester&scrollprobe=...). newFps = presented frames showing a newly recorded frame per second; judder = RMS residual of the offset against a local quadratic through neighbouring presented frames.Local runs (Skia Win32, 250 % scale):
Given_ScrollViewer,Given_ScrollViewer_Zoom,Given_ItemsRepeater*all green;Given_ListViewBasefailures are the pre-existing 250 %-scale ones, identical on the base commit.Uno.UI.UnitTests: only the 12 known timezone-dependentGregorian_FixedDatefailures.Given_FlipView.When_TouchFlick_Then_FlipOneItemwas flaky on master too (CI hid it with retries). With retries off and one core it failed about 20% of iterations on master. It had two causes:Remaining, which reaches zero before a late last frame publishes the final offsets.IsInManipulationnow holds until the animation has stopped (When_ChangeView_Animated_Then_In_Motion_Until_Final_ViewChanged).FixOffsettick was still pending. That tick postpones itself to the end of the manipulation, then suppresses the snap's selection change and scrolls back. WinUI'sFlipView_Partial.cppbehaves the same way, so the test now waits for the pending fix first.With both changes the test passes 60/60 and 40/40 iterations with retries off on one core. Measured with #25153, which adds
--runtime-tests-iterations/--runtime-tests-attemptsto the runner.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_01Usdq5JJfVkzKcYtwkKCRUy