Closed Bug 2000834 Opened 1 year ago Closed 4 months ago

www.assembly.ca.gov - Scrolling is slow/sluggish

Categories

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

Firefox 147
ARM
Android
defect

Tracking

()

VERIFIED FIXED
Performance Impact medium
Webcompat Priority P3
Webcompat Score 1
Tracking Status
firefox145 --- wontfix
firefox146 --- wontfix
firefox147 --- wontfix
firefox154 --- verified

People

(Reporter: ctanase, Assigned: dshin)

References

()

Details

(Keywords: webcompat:needs-diagnosis, webcompat:site-report)

User Story

diagnosis-team:apz
user-impact-score:0

Attachments

(1 file, 1 obsolete file)

Environment:
Operating system: Android 14 (Pixel 5)
Firefox version: Firefox Mobile 145/147

Steps to reproduce:

  1. Navigate to: https://www.assembly.ca.gov/
  2. Wait for the page to load completely (refresh the page if stuck)
  3. Scroll the page.

Expected Behavior:
The scroll is smooth.

Actual Behavior:
The scroll is slow/sluggish.

Notes:

  • Reproduces regardless of the status of ETP
  • Reproduces in firefox-nightly, and firefox-release
  • Does not reproduce in chrome

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

User Story: (updated)
Webcompat Score: --- → 1
Component: Site Reports → Performance: General
Product: Web Compatibility → Core

The severity field is not set for this bug.
:bas.schouten, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(bas)

Including a profile, this is indeed a disaster. But it doesn't look like we're particularly busy, it feels like an event handling issue to me. Botond, do you have any idea on this? Or should this go to the front-end folks?

https://share.firefox.dev/3MyVo4T

The Performance Impact Calculator has determined this bug's performance impact to be medium. If you'd like to request re-triage, you can reset the Performance Impact flag to "?" or needinfo the triage sheriff.

Platforms: Android
Impact on site: Renders site effectively unusable
[x] Able to reproduce locally

Performance Impact: --- → medium
Component: Performance: General → Panning and Zooming
Flags: needinfo?(bas) → needinfo?(botond)

(In reply to Calin Tanase from comment #0)

Firefox version: Firefox Mobile 145/147

Note the behaviour is different in 145 vs. 147.

In 145, the site is basically unusable/unscrollable. This was at least mitigated in bug 1988486 / bug 1989868, and as a result in 147 the scrolling on the site is "merely" slow.

(In reply to Bas Schouten (:bas.schouten) from comment #3)

it feels like an event handling issue to me. Botond, do you have any idea on this? Or should this go to the front-end folks?

Agree it's very likely an event handling issue. Our investigation of bug 1988486 has shown the site is doing something pretty wonky (setting window.onscroll = scroll; or some such).

==> APZ is the right component for at least an initial investigation. Will add to our WebCompat diagnosis queue.

Flags: needinfo?(botond)
User Story: (updated)
User Story: (updated)

(In reply to Botond Ballo [:botond] from comment #4)

(In reply to Calin Tanase from comment #0)
==> APZ is the right component for at least an initial investigation. Will add to our WebCompat diagnosis queue.

I can explain what's going on there.

  1. window.onscroll = scroll is equivalent with window.scrollTo(window.scrollX, window.scrollY).
  2. Thus given that in one of the event handler, the scrollY is 100px
  3. In the meantime APZ can scroll further, say 102px
  4. The absolute scroll position update scrollY=100px reaches to APZ
  5. APZ updates the scroll offset to 100px
  6. APZ tries to scroll from the offset=100px again, then it goes to 102px again

I think this kind of things keep happening.

An approach to fix this jitter scrolling is to defer querying window.scrollXY values to APZ. But this approach has a side-effect if there's a scroll linked animation. Well our scroll-linked effect machinery may handle it gracefully, I am not sure.

Another approach is just to disable APZ for the container.

User Story: (updated)

The severity field is not set for this bug.
:botond, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(botond)

Diagnosing this bug has been tracked by 2026 H1 APZ WebCompat Work, so P2:S3. The priority might be changed after the diagnosis.

Severity: -- → S3
Flags: needinfo?(botond)
Priority: -- → P2
Webcompat Priority: --- → P3

Investigating this as part of the burndown. Less familiar with this side of the codebase, but :hiro's diagnosis seems right, though on my android phone, rather than the scroll oscillating, but it just seems to stop often.

Looking at the log:

[GPU 16044: Main Thread]: D/apz.controller 747a411100(root scrollId=21): got a touch-start in state NOTHING
[GPU 16044: Main Thread]: D/apz.controller 747a411100(root scrollId=21): changing from state NOTHING to TOUCHING
...
[GPU 16044: Main Thread]: D/apz.inputqueue received new touch event (type=1) in block 7343120d00
[GPU 16044: Main Thread]: D/apz.inputqueue dropping event due to block 7343120d00 being in mini-slop
[GPU 16044: Main Thread]: D/apz.inputqueue processing input from block 7343120d00; preventDefault 0 shouldDropEvents 0 target 747a411100
[GPU 16044: Main Thread]: D/apz.controller 747a411100(root scrollId=21): got a touch-move in state TOUCHING
... 
[GPU 16044: Main Thread]: D/apz.controller 747a411100(root scrollId=21): got a touch-move in state TOUCHING
[GPU 16044: Main Thread]: D/apz.controller 747a411100(root scrollId=21): changing from state TOUCHING to PANNING
...

... But then:

[GPU 16044: WRSceneBuilder#5]: D/apz.controller 7481f75700 smooth scrolling to (0,776.25)
[GPU 16044: WRSceneBuilder#5]: D/apz.controller 7481f75700(root scrollId=4): running CancelAnimation(0x0) in state PANNING
[GPU 16044: WRSceneBuilder#5]: D/apz.controller 7481f75700(root scrollId=4): changing from state PANNING to NOTHING
[GPU 16044: WRSceneBuilder#5]: D/apz.controller 7481f75700(root scrollId=4): changing from state NOTHING to SMOOTH_SCROLL
...
[GPU 16044: Main Thread]: D/apz.controller 7481f75700(root scrollId=4): got a touch-move in state SMOOTH_SCROLL
[GPU 16044: Main Thread]: D/apz.controller 7481f75700(root scrollId=4): running CancelAnimation(0x0) in state SMOOTH_SCROLL
[GPU 16044: Main Thread]: D/apz.controller 7481f75700(root scrollId=4): changing from state SMOOTH_SCROLL to NOTHING
[GPU 16044: Main Thread]: D/apz.controller 7481f75700(root scrollId=4): got a touch-start in state NOTHING
[GPU 16044: Main Thread]: D/apz.controller 7481f75700(root scrollId=4): changing from state NOTHING to TOUCHING

Which then cycles. I imagine smooth scroll happens because the values are out-of-sync as :hiro described - As a result, we start panning but keep clobbering that action with panning, which then the further touch movement cancels, and so on.

I also see:

[GPU 16044: Main Thread]: D/apz.controller 7481f75700 taking overscroll during panning

Which doesn't make sense to me because I'm definitely not at the end of the viewport scroll...

Assignee: nobody → dshin
See Also: → 2009679

FWIW: The problem-inducing window.onscroll = scroll call is in a resize handler, and is set only if the width of the document is less than 1023px - resizing on desktop to trigger this causes the same issue.

Okay I think in this specific case, Chrome does just drop the scroll call via the onscroll.

A relevant code is;

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/scroll/scrollable_area.cc;l=526-529;drc=9c91b2494d4bf0a2d33b5985f7d1af79e72146f2

  if (ScrollOffsetIsNoop(offset)) {
    CancelProgrammaticScrollAnimation();
    return false;
  }

Presumably we can simply take the same approach.

Note about bug 2009679, bug 2009679 is slightly different from this bug, see bug 2025232 comment 2.

Hm, I think your observation is right, but the programmatic scroll request is ignored elsewhere: See bug 2025232 comment 4.

One more thing to add: The resize event triggers on Fenix but not in responsive mode, because scrolling causes the URL bar to start hiding itself, and that triggers the resize event.

I had a further diagnosis why window.onscroll = scroll; with scroll-behavior: smooth; is sluggish on Firefox. There are a couple of reasons;

  1. each APZC (an APZC is corresponding to a scroll container) has only one animation instance so that a new smooth scroll operation clobbers the existing wheel scroll animation triggered by user, Chrome rather has two independent animators, one is for programatic scroll operations, the other is probably for user's operations
  2. bug 1740164, once after we've done 1), this will not be matter since there will exist an APZ animation though, as of now we don't yet transmogrify scrollTo into scrollByCSSPixels
  3. for 2) we might want to use pure relative for scrollByCSSPixel since I have posted a patch to remove relative smooth scroll position update in bug 2028680
Depends on: 1740164

Downgrading the priority since I believe we've finished diagnosis.

Priority: P2 → P3

(In reply to Hiroyuki Ikezoe (:hiro) from comment #13)

  1. bug 1740164, once after we've done 1), this will not be matter since there will exist an APZ animation though, as of now we don't yet transmogrify scrollTo into scrollByCSSPixels
  2. for 2) we might want to use pure relative for scrollByCSSPixel since I have posted a patch to remove relative smooth scroll position update in bug 2028680

Those two won't work. The transmogrified smooth relative scroll operation ends up being a smooth absolute scroll operation via ScrollContainerFrame::ApzSmoothScrollTo.

So I did rather use a smooth pure-relative scroll update for this kind of zero delta change, I confirmed it works. I will file a bug.

No longer depends on: 1740164
Depends on: 2035957

When scrollTo() or similar script APIs are called with the layout viewport
already at the destination, ApzSmoothScrollTo previously sent a NewSmoothScroll
update regardless. In APZ, receiving any smooth scroll update cancels any
ongoing animation — including user-triggered ones — which is undesirable when
the script scroll is effectively a no-op.

To fix this, introduce ScrollPositionUpdate::NewZeroDeltaLayoutScroll, a
dedicated factory for zero-delta pure-relative scroll updates targeting the
layout viewport with ScrollTriggeredByScript::Yes baked in. When the layout
viewport is already at the requested destination and the scroll was script-
triggered, ApzSmoothScrollTo emits one of these instead of a NewSmoothScroll.

In AsyncPanZoomController::NotifyMainThreadTransaction, zero-delta pure-relative
smooth scroll updates that are script-triggered are handled as follows: if no
script-triggered animation is currently running, the update is skipped as a
true no-op; if a script-triggered animation is running, CancelAnimation() is
called explicitly before skipping, stopping the animation without starting a
new one to the same destination.

NewZeroDeltaLayoutScroll is kept separate from the existing NewPureRelativeScroll
(which always targets the visual viewport, per the FIXME in bug 1984224) to
prevent future callers from accidentally passing ViewportType::Layout with a
non-zero delta, which APZ does not handle correctly.

Comment on attachment 9575292 [details]
WIP: Bug 2000834 - Ignore zero delta smooth script scroll operation if there's no user triggered animation.

Revision D297520 was moved to bug 2035957. Setting attachment 9575292 [details] to obsolete.

Attachment #9575292 - Attachment is obsolete: true

Now bug 2035957 has landed, so I think this bug was fixed by the change.

Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED

Verified, the issue no longer reproduces.

Tested with:

  • Browser / Version: Fenix 154.0-candidate build 1
  • Operating System: Android 11
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: