**Steps to reproduce** 1. Ensure smooth scrolling is enabled 2. Load https://bugzilla.mozilla.org/attachment.cgi?id=9445987. This is a page which listens for `wheel` events, calls `preventDefault()` on them, and scrolls using `scrollBy()` instead (originally posted in bug 1932985). 3. Scroll down with the mousewheel, with multiple ticks in succession **Expected results** The page scrolls at a normal speed, comparable to the speed it would scroll at if the `wheel` events were handled natively by the browser (module system settings affecting scrolling speed). **Actual results** The page scrolls very slowly. **Diagnosis** In this scenario (smooth scrolling + wheel ticks in quick succession), when a subsequent wheel event is received, the smooth scroll animation from the previous wheel tick is still ongoing. To scroll by the full delta of both wheel events, the destination of the ongoing animation needs to be extended by the delta of the new event. The animation is running on the compositor, and the scrolling for a new wheel event happens via `window.scrollBy()`, so it's sent to the compositor as a scroll update during a main thread transaction. We do have logic to "extend the destination of the existing animation" [here](https://searchfox.org/mozilla-central/rev/0b189f017bc9d48b62012205c5b9f8a8b560497b/gfx/layers/apz/src/AsyncPanZoomController.cpp#5783-5801), but it requires that the scroll update type be **relative** (or "pure relative"). However, we do not have `window.scrollBy()` hooked up to produce relative scroll updates in the case of smooth scrolling. (The operation [calls](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollContainerFrame.cpp#4973) `ScrollToWithOrigin()` with `ScrollOrigin::Relative`, but in the [smooth scroll case](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollContainerFrame.cpp#2495) we use [`ScrollPositionUpdate::NewSmoothScroll`](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollContainerFrame.cpp#7935) which hardcodes [`ScrollUpdateType::Absolute`](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollPositionUpdate.cpp#70) regardless of origin.)
Bug 1944697 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
**Steps to reproduce** 1. Ensure smooth scrolling is enabled 2. Load https://bugzilla.mozilla.org/attachment.cgi?id=9445987. This is a page which listens for `wheel` events, calls `preventDefault()` on them, and scrolls using `scrollBy()` instead (originally posted in bug 1932985). 3. Scroll down with the mousewheel, with multiple ticks in succession **Expected results** The page scrolls at a normal speed, comparable to the speed it would scroll at if the `wheel` events were handled natively by the browser (modulo system settings affecting scrolling speed). **Actual results** The page scrolls very slowly. **Diagnosis** In this scenario (smooth scrolling + wheel ticks in quick succession), when a subsequent wheel event is received, the smooth scroll animation from the previous wheel tick is still ongoing. To scroll by the full delta of both wheel events, the destination of the ongoing animation needs to be extended by the delta of the new event. The animation is running on the compositor, and the scrolling for a new wheel event happens via `window.scrollBy()`, so it's sent to the compositor as a scroll update during a main thread transaction. We do have logic to "extend the destination of the existing animation" [here](https://searchfox.org/mozilla-central/rev/0b189f017bc9d48b62012205c5b9f8a8b560497b/gfx/layers/apz/src/AsyncPanZoomController.cpp#5783-5801), but it requires that the scroll update type be **relative** (or "pure relative"). However, we do not have `window.scrollBy()` hooked up to produce relative scroll updates in the case of smooth scrolling. (The operation [calls](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollContainerFrame.cpp#4973) `ScrollToWithOrigin()` with `ScrollOrigin::Relative`, but in the [smooth scroll case](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollContainerFrame.cpp#2495) we use [`ScrollPositionUpdate::NewSmoothScroll`](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollContainerFrame.cpp#7935) which hardcodes [`ScrollUpdateType::Absolute`](https://searchfox.org/mozilla-central/rev/d55e89d48a8053ce45a74b0ec92c0ff6a9dcc43d/layout/generic/ScrollPositionUpdate.cpp#70) regardless of origin.)