Closed Bug 2035957 Opened 7 months ago Closed 4 months ago

Stop cancelling user-triggered APZ animation by zero delta smooth programmatic scroll operation

Categories

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

defect

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: hiro, Assigned: hiro)

References

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:0

Attachments

(1 file, 1 external file)

This change fixes bug 2000834.

Attaching file is the same file attached in bug 1989868 comment 0. If you scroll the example, scroll would not be smooth because of window.onscroll = scroll; with scroll-behavior: smooth.

This bug fixes the test case.

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.

Assignee: nobody → hikezoe.birchill
Status: NEW → ASSIGNED
User Story: (updated)

This will fix a webcompat issue (bug 2000834) tracked in H1 2026 WebCompat Epic.

Severity: -- → S3
Priority: -- → P2
Summary: Stop cancelling user-triggered APZ animation by zero delta smooth programatic scroll operation → Stop cancelling user-triggered APZ animation by zero delta smooth programmatic scroll operation

The following patch is waiting for review from an inactive reviewer:

ID Title Author Reviewer Status
D297520 Bug 2035957 - Ignore zero delta smooth script scroll operation if there's no user triggered animation. r?botond hiro botond: Back Jun 24, 2026

:hiro, could you please find another reviewer?

For more information, please visit BugBot documentation.

Flags: needinfo?(hikezoe.birchill)
Flags: needinfo?(hikezoe.birchill)
Pushed by hikezoe.birchill@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/c7dfce09cae1 https://hg.mozilla.org/integration/autoland/rev/9237d1d85c2b Ignore zero delta smooth script scroll operation if there's no user triggered animation. r=botond
Pushed by smolnar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e359ec43c276 https://hg.mozilla.org/integration/autoland/rev/7cf6a4af8bb4 Revert "Bug 2035957 - Ignore zero delta smooth script scroll operation if there's no user triggered animation. r=botond" for causing mochitest plain failures @ test_group_scroll_position_update.html
Pushed by hikezoe.birchill@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/c3d332f65346 https://hg.mozilla.org/integration/autoland/rev/d40d7c714b8f Ignore zero delta smooth script scroll operation if there's no user triggered animation. r=botond

Skip the test on Android.

Flags: needinfo?(hikezoe.birchill)
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch
QA Whiteboard: [qa-triage-done-c155/b154]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: