Closed Bug 1692708 Opened 4 years ago Closed 4 years ago

Smooth scroll animations are reset when scrollTop is changed

Categories

(Core :: Panning and Zooming, defect, P3)

defect

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: mstange, Assigned: hiro)

References

Details

Attachments

(9 files, 1 obsolete file)

60.70 KB, image/png
Details
79.86 KB, image/png
Details
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

When scrollTop is set, smooth scroll animations are interrupted. This disturbs the user experience on pages that lazily load content and adjust the scroll position in response, like Slack. In fact, Slack is giving Firefox a slow path due to this bug. See bug 1692705 for more details.

Steps to reproduce:

  1. Load attachment 9203072 [details].
  2. Switch to the setting document.scrollingElement.scrollTop option with the radio button.
  3. Using the pageup/pagedown keys, or using an external mouse with discrete mousewheel "notches", scroll up and down.

Expected results:
The smooth scroll animation should complete undisturbed.

Actual results:
The smooth scroll animation is interrupted. In addition, the page is reset to an earlier scroll position, discarding the async scroll offset from the smooth scroll. The latter is bug 1692705, the former is this bug.

I think this aspect is a behavior we've had for a long time, and is not new with APZ.

Thanks for the reports (bug 1692705, bug 1692707, and this one), Markus!

I've marked them as P3 for now, but given the impact on Slack, I'm going to push to prioritize these (likely shortly after Proton).

Severity: -- → S3
Priority: -- → P3
Blocks: 1646410

Updated Assignee. Part of Jira Epic FFXP-370

Assignee: nobody → tnikkel

Without specifying the value, even if synthesizeNativeWheel causes wheel inputs,
it will be converted to an instant scroll rather than smooth. In fact on Mac
mouse wheeling causes this type of events that is that the events'
hasPreciseScrollingDeltas flag is false.

Depends on D129590

synthesizeKey() just invokes a corresponding command. In "KEY_ArrowDown" case
it's nsISelectionController::ScrollLine [1] which is actually
PresShell::ScrollLine which calls nsIScrollable::ScrollBy, that's not what we
wanted to test for bug 1692707. To exercise APZ's keyboard scrolling we need to
use synthesizeNativeKey instead.

[1] https://searchfox.org/mozilla-central/rev/126f016b59513988fae56c2b3f69c1cd23fe6ca1/dom/base/nsGlobalWindowCommands.cpp#363-364

Depends on D129592

Depends on: 1739541
Attachment #9247910 - Attachment description: Bug 1692708 - Transmogrify ScrollToCSSPixels to ScrollByCSSPixels if there's any on-going APZ animation and there's no on-going async scroll. r?botond → Bug 1692708 - Transmogrify ScrollToCSSPixels to ScrollByCSSPixels if there's any on-going APZ animation and there's no on-going async scroll by script. r?botond
Blocks: 1740164
See Also: → 1740164

This test has a pattern something like;

  1. Call synthesizeKey to scroll an element
  2. Wait a scroll event
  3. Test something
  4. (Re)set the scroll position to (0, 0) by calling Element.scrollTop and
    Element.scrollLeft

With the new transmogrification the step 4) will not reset the scroll position
if there's an on-going scroll animation in APZ triggered by the synthesizeKey.
To avoid the situation where there's an on-going animation, we simply set the
minimum possible smooth scroll animation parameters to minimize the animation
duration thus the animation will immediately end in the first sampling, so at
the step 2) the test can ensure there's no animation.

Depends on D129593

This test has the same pattern as window_bug1369072.html does.

Call synthesizeKey, wait a scroll event, test something and reset the scrolled
position by calling scrollTo.
We'd set the same preference values in the previous commit.

Depends on D130852

Attachment #9250156 - Attachment description: Bug 1692708 - Make window_bug1369072.html work with the new relative transmogrification. r?botond → Bug 1692708 - Add cancelScrollAnimation and use it in window_bug1369072.html and browser_scroll.js. r?botond
Attachment #9250157 - Attachment is obsolete: true

I did disable helper_relative_scroll_smoothness.html with native-key on Mac's on chaos mode runs (e.g. TV runs) since it fairly fails.

For the record, the failure happens because there appear flat scroll position changes which should have been fixed in bug 1692707. A failure log is;

scroll offset should be strictly monotonically increasing previous offset: 0.01666259765625, offset: 0.01666259765625

I am assuming on chaos mode we somehow sample same scroll position because we miss keyboard input event handling or some such on heavy load state.

Pushed by hikezoe.birchill@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5d8fb911d61e Await promiseApzFlushedRepaints() before calling window.scrollTo(). r=tnikkel https://hg.mozilla.org/integration/autoland/rev/9256faddf559 Specify MOUSESCROLL_SCROLL_LINES in synthesizeNativeWheel if apz.test.mac.synth_wheel_input is true. r=tnikkel https://hg.mozilla.org/integration/autoland/rev/d4b0e298abed Run helper_relative_scroll_smoothness.html with mouse wheel events. r=botond https://hg.mozilla.org/integration/autoland/rev/8beac9395793 Run helper_relative_scroll_smoothness.html with native key events both on Windows and Mac. r=botond https://hg.mozilla.org/integration/autoland/rev/b31c1668258d Add cancelScrollAnimation and use it in window_bug1369072.html and browser_scroll.js. r=botond https://hg.mozilla.org/integration/autoland/rev/f26b5d17b34b Transmogrify ScrollToCSSPixels to ScrollByCSSPixels if there's any on-going APZ animation and there's no on-going async scroll by script. r=botond https://hg.mozilla.org/integration/autoland/rev/361c96f8f312 Add scrollTo and scrollTop test cases in helper_relative_scroll_smoothness.html. r=botond
Assignee: tnikkel → hikezoe.birchill
See Also: → 1779404
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: