Repository navigation
Conversation
…bKit wheel input WebKit can drop a scrollTop write made while wheel input drives the scroll, so a prepend's anchor write lost that way throws the reader by the whole prepend (TanStack#1398). Hold the anchor for two frames and write it from the second. Size corrections are written as before. Measured with the issue's repro in Playwright WebKit 26.0: no jump in 18 runs, against about 1 run in 4 before. Real Safari and trackpad momentum are not measured.
🦋 Changeset detectedLatest commit: 462bdac The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
View your CI Pipeline Execution ↗ for commit 9572c54
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
|
Tried #1400 in MindRoom Chat on macOS Playwright WebKit against our variable-height timeline specs (same room/thread tests, comparing our wheel hold vs #1400):
The difference vs the gist repro looks like variable-height rows: as you scroll up into unmeasured rows, I agree on avoiding a public option and on not letting a never-pausing wheel park at |
|
Thanks for testing it that fast @basnijholt, and nice that the prepend specs pass. Hmm, couldn't reproduce the dropped scroll though. Took your gist, removed the prepend limit and sent 300 wheel ticks (30k px) in Playwright WebKit, then counted how far the visible rows actually moved on screen. #1400 loses 0px, continuous and in bursts, also with the estimate at 40 and at 300 to make the resize corrections bigger. main loses 100-500px, that's the prepend jump. How do your specs measure the drop? If it's wheel distance vs Also tried your idea, hold everything on WebKit and flush with the 2 frame write near the edge. No stuck state, but every edge flush costs about one wheel tick, 300-1000px over the same 30k, plus a few frames with a visible jump. So in the gist it's worse than #1400. Could you check the drop against row positions on screen instead of |
|
Good question — our probe already tracks on-screen We figured out why you saw On macOS Playwright WebKit,
Same 60 Hz loop on Chromium What's happening per frame (traced on the gist, 0 prepends): Every synchronous That also explains the hold + edge-flush trade-off: at 30 Hz Standalone runnable repro against (Full disclosure: this investigation, repro, and reply were written by my AI agents.) |
A scrollTop write made while wheel input drives the scroll makes WebKit discard the distance of the next wheel event. A list whose rows are measured on the way up writes on most frames, so a wheel event per frame lost about a third of its distance; holding only a prepend's anchor did not help there. Hold every correction while wheel input runs and write it when the wheel has been quiet for 150ms. A hold also has to be written when the element reaches either edge, or wheel input that never pauses parks the reader there: two frames later, and not before the edge, where WebKit applies the write about two frames after the rows moved. Measured with the issue's repro in Playwright WebKit 26.0, one wheel event per frame: 0px lost of 7,000 without prepends (main: about 2,300), about 1,000px of 30,000 with five prepends (main: about 10,000), no frame with the rows out of place. Real Safari and trackpad momentum are not measured.
|
Yep, you're right @basnijholt, it was my cadence. Dropped the extra sleep and at 60 Hz main and the old version of this PR both lose about a third of the wheel distance on the gist, nice catch. Pushed a rework, so it now does what you proposed: every correction is held on WebKit while the wheel runs, no option, and written when the wheel rests or at the edge. Same gist at 60 Hz, 0px lost without prepends and about 1000px of 30k with five prepends, that's the edge write. One difference from your version. With a margin before the edge (tried one viewport and your 1200px) the rows show the whole hold away for about two frames at every prepend, WebKit applies the write that much later than the re-render while the element still moves. Does your probe catch that? Flushing exactly at Could you run your specs against it again? Details and numbers are in the PR description. |
Review follow-ups on the WebKit wheel hold: - The end needs no early write: the total size is exposed short by the hold, so the element and the layout reach the end together. - The write at the top ends the wheel hold early instead of passing a flag through the flush; the next wheel event starts it again. - Check the top again when the two frames have passed: the reader can have turned back, and a write away from the top shows the rows out of place. - The list's top is scrollMargin down the element; held rows were drawn over what is above the list. - jsdom and happy-dom name AppleWebKit in their user agent: leave them out, so a consumer's test sees the same writes as before.
Replace v1 #1400 2-frame prepend hold (_lastWheelAt, _anchorHoldFrame, _holdAnchorUnderWheel) in @tanstack/virtual-core@3.19.13 (cjs+esm) with piecyk's reworked #1400 implementation (commit 462bdacc1f9b68b3ee7e52ac05955a2d851f836c): - Exclude jsdom and HappyDOM in isWebKit() while keeping _resetIOSDetectionForTests() resetting _isWebKitResult - Track WebKit wheel activity with a 150ms _wheelTimer (gated in _canWriteScroll) and clean up _wheelTimer/_edgeFlushFrame on detach - Flush held corrections when the wheel rests or 2 frames after reaching the top of the list via _holdAtTop()/_flushHoldAtTop() (invoked from observeElementOffset and onWheel) - Preserve local PR 3 negative-hold clamp and heldBefore/notify(true) guards in _wheelTimer, _flushHoldAtTop, and onTailClosed, plus PR 4 anchorSkipLeading Assisted-by: MindRoom DevAgent:google/gemini-4-neon <https://github.com/mindroom-ai/mindroom>
|
Ran our full MindRoom Chat E2E suite against the reworked
This is a huge improvement — it completely eliminates the multi-thousand-px drops from the earlier On your question about the
We'd be happy to test this in real macOS Safari (trackpad momentum + top bounce) as well if that helps get (Full disclosure: these benchmarks, margin check, and reply were run and drafted by my AI agents.) |
🎯 Changes
Refs #1398. An alternative to #1399, still a draft until it's tried in real Safari.
In WebKit a
scrollTopwrite made while wheel input drives the scroll makes it discard the distance of the next wheel event. A list whose rows get measured on the way up writes on most frames, so with one wheel event per frame about a third of the distance is lost. A prepend's anchor write can also be undone whole, which is the jump from #1398. Thanks @basnijholt for finding the cadence part, my first version here only held the prepend anchor and missed it.Now every correction is held for 150ms after a wheel event, same hold path the iOS touch gesture uses, no new option:
The write at the top is there so a wheel that never pauses can't park the reader at
scrollTop0. It has to be exactly at the top. With a margin (tried one viewport and 1200px) WebKit applies the write about two frames after the rows moved, and they show the whole hold away for those frames. The end doesn't need it, the total size is exposed short by the hold so the element and the layout get there together.WebKit is told from the user agent, there's no feature to test for. Chromium, Firefox, jsdom and happy-dom are left out, so nothing changes there.
Issue's repro in Playwright WebKit 26.0, 100px wheel ticks, counting how far the rows moved on screen:
No frame with the rows out of place in any run. What's left is the write at the top, the element sits there for two frames per prepend and that costs about two ticks.
Not measured: real Safari, trackpad momentum, the bounce at the top, a list with a
scrollMargin(there the write lands while the element still moves). Playwright sends discrete wheel events.✅ Checklist
pnpm run test:pr. (Ran virtual-coretest:lib,test:types,test:eslintand the affected set from the pre-push hook, not the e2e matrix.)🚀 Release Impact
🤖 Generated with Claude Code