Closed Bug 2070448 Opened 2 months ago Closed 2 months ago

Scrolling (two finger swipe) by using the Touchpad on macOS sporadically stops working

Categories

(Core :: Panning and Zooming, defect)

Unspecified
macOS
defect

Tracking

()

RESOLVED DUPLICATE of bug 2067573

People

(Reporter: whimboo, Unassigned)

References

Details

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:157.0) Gecko/20100101 Firefox/157.0 ID:20260907092617

For the past couple of days I've been experiencing an intermittent issue with two-finger scrolling on my MacBook's touchpad.

At seemingly random times, scrolling stops working across all open Firefox tabs. Switching to another application with scrollable content shows that the touchpad continues to work normally, but returning to Firefox, scrolling is still broken. The issue eventually resolves itself without any obvious trigger.

One interesting observation is that, just before scrolling starts working again, Firefox performs a much larger scroll than expected, as if it is catching up on previously queued or delayed scroll events. This makes it appear as though the scroll events are being buffered somewhere rather than lost.

So far I haven't been able to identify a reliable way to reproduce the problem or determine what causes it to start or stop. It would be good to know which kinds of logs or a GeckoProfile could help to further investigate this problem.

Flags: needinfo?(echen)

Scrolling is handled by APZ, so :hiro would know better. :)

Flags: needinfo?(echen) → needinfo?(hikezoe.birchill)

CCing Botond since I would say it's in fact a case where the profiler records scroll positions is helpful, specifically

Firefox performs a much larger scroll than expected

this part.

Component: DOM: Events → Panning and Zooming
OS: Unspecified → macOS
See Also: → 2067573

This is a shot in the dark, but did you by any chance end up with WebDriver's apz.content_response_timeout: 60000 pref in your production profile?

Flags: needinfo?(hskupin)

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

This is a shot in the dark, but did you by any chance end up with WebDriver's apz.content_response_timeout: 60000 pref in your production profile?

Yes, that pref has indeed this custom value set. I clearly haven't done that myself but recently I tried to dynamically enable the Remote Agent and due to bug 2067187 we were setting this value but missed to remove it when disabling it again. Julian fixed it about 2 weeks ago.

Flags: needinfo?(hskupin)

What effect does that value actually have? I mean in the latest try builds for async events I can see as well that in a lot of tests are failing because we miss events. Could that be the same underlying cause? See bug 2067192 comment 4. Is such a high value required?

We need to read through those bugs why we *needed the long value.

Though 6000ms looks too long to me, regardless of whether it's long or not, I would say we need to cancel the timeout task when the corresponding target APZC gets destroyed.

Flags: needinfo?(hikezoe.birchill)

Note that the current value is even higher - 60000 is set at the moment.

I asked Claude to do that analysis:

The chain is long and nothing about it was ever WebDriver-specific:

  1. Bug 1177018 (2015) raised it from the production default to 15000 in testing/profiles/prefs_general.js, as one of six fixes for test_layerization.html. The specific reason is bug 1177018 comment 18, issue (2): on slow infra it took >300 ms to dispatch a wheel event to content, wait for a paint, and send SetConfirmedTargetAPZC back, so APZ timed out and scrolled the tentative target instead of the confirmed one — the test then never saw a scroll event.
  2. Bug 1208200 raised 15000 → 60000, commit message: "Increase the content response timeout to 1 minute because B2G emulator is slow." The measurement behind it is bug 1210465 comment 3 and comment 4: on the Firefox OS ICS emulator the content response took 18.5 s in one log and just under 50 s in another (comment 8: 28 s just to get the touchstart into the child process). Botond's reaction in comment 9 was "Wow - and I thought 15 seconds was an eternity to begin with!"
  3. Bug 1319024 copied the whole mochitest pref block, comment included, into marionette_driver/geckoinstance.py; bug 1344748 moved it into Marionette's recommended prefs; bug 1693803 moved it to the shared remote/shared/RecommendedPreferences.sys.mjs:105, where it now applies to every Marionette/WebDriver classic/BiDi/CDP session. The comment there still says "in tests" and still cites bug 1176798, bug 1177018, bug 1210465.

So the 60 s value is a 2015 workaround for a Gonk emulator that no longer exists, inherited by WebDriver by copy-paste — and via bug 2067187 it leaked into your production profile.

What the pref actually gates

InputQueue::MaybeRequestContentResponse (gfx/layers/apz/src/InputQueue.cpp:632) schedules MainThreadTimeout with this delay whenever a block's target isn't confirmed, touch-action info is missing, or a browser gesture response is needed (ScheduleMainThreadTimeout, line 785). Until the main thread answers, ProcessQueue() bails at !IsReadyForHandling() (line 1078) and the events sit in mQueuedInputs. MainThreadTimeout (line 862) is the only fallback: it calls TimeoutContentResponse() + SetConfirmedTargetApzc(..., eTimedOut) and then drains the queue.

That means the pref is not "how long a slow page may block scrolling" — it is "how long APZ stays completely dead if the response is lost". At 60 s that is a full minute of frozen scrolling followed by every queued event being applied at once, which is exactly the catch-up jump you described in comment 0. On macOS a two-finger swipe is a PanGestureInput; if it's a swipe-navigation candidate it additionally waits for the browser gesture response on the same timeout (line 528), giving another way to get stuck.

About the "no events" failures

Worth separating two things, because the pref only explains one of them:

  • The DOM events still get dispatched. nsIWidget::DispatchInputEvent (widget/nsIWidget.cpp:1326) only skips content dispatch when APZ returns eConsumeNoDefault; a block waiting for a content response returns eConsumeDoDefault (or eIgnore for a swipe candidate), so the wheel/pointer event reaches the page normally.
  • What is blocked is everything downstream of ProcessQueue(): no async scroll, therefore no scroll event, and no APZ handled-result callbacks (those fire only inside ProcessQueue, line 1127).

That is precisely the signature in bug 2067192 comment 0: scrollLeft: expected 60, got 0 and "expected at least 2, got 1" — the wheel arrived, the scroll never did. With the production timeout the fallback would fire in a fraction of a second and the test would scroll (possibly the tentative target); at 60 s nothing happens at all within the test's own timeout. So yes, the high pref plausibly turns bug 2067192's race from "occasionally wrong target" into "hard failure", and it is a good candidate for the macOS-only failures in comment 4 — though I have not verified that against the try log itself, so treat that last part as a hypothesis.

Note the pref is also still in testing/profiles/unittest-required/user.js:20, so wdspec CI gets it from two directions; changing only RecommendedPreferences.sys.mjs won't change CI behaviour.

Suggestion

Lowering the WebDriver value (or dropping the override entirely and letting the production default apply) is defensible on its own merits — the justification is a dead platform, and hiro already called 6000 ms too long in comment 6. But it would only mask bug 2067192: the root cause there is that the content response never arrives because the subframe isn't APZ-registered yet, and a shorter timeout just means APZ gives up sooner and scrolls the wrong target. The two fixes hiro pointed at — cancelling the timeout task when the target APZC is destroyed, plus the APZ-readiness design discussion with botond — are still needed.

I pushed a new try build for wdspec tests with async events enabled and the pref's value reduced to just 1s:
https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=90139&tier=1%2C2%2C3&searchStr=wdspec

For reference here the former try build with the current value:
https://treeherder.mozilla.org/jobs?repo=try&tier=1%2C2%2C3&revision=220aee4f5146acea98d86ac1651f5609dcd24b4d&searchStr=wdspec

See Also: → 2067192

(In reply to Henrik Skupin [:whimboo][⌚️UTC+2] from comment #9)

I pushed a new try build for wdspec tests with async events enabled and the pref's value reduced to just 1s:
https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=90139&tier=1%2C2%2C3&searchStr=wdspec

The failure rate doesn't seem to be that different. Botond, do you have any further idea? Please see as well comment 8 with a potential investigation. Thanks.

Flags: needinfo?(botond)

As discussed with Botond on Matrix it should be a different issue. Let me observe if I can see the reported behavior again over the next days. If not I'll close this bug early next week.

Flags: needinfo?(botond)

Behavior is actually similar to bug 2067573. So I'm going to dupe it.

The underlying investigation why event responses are getting dropped will happen on bug 2072785.

Status: NEW → RESOLVED
Closed: 2 months ago
Duplicate of bug: 2067573
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.