Closed Bug 2041154 Opened 1 month ago Closed 1 month ago

Prototype a fast path to inform APZ-aware registration to APZ

Categories

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

task

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: hiro, Assigned: hiro)

References

(Blocks 3 open bugs)

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:1500

Attachments

(8 files, 2 obsolete files)

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
48 bytes, text/x-phabricator-request
Details | Review

It may have impacts on temu.com (bug 2031963).

When a touchstart JS handler dynamically registers a non-passive
touchmove (or similar APZ-aware) listener, APZ doesn't learn about
eApzAwareListeners until the next painted WebRender transaction has
been scene-swapped on the compositor -- ~70 ms after the listener
add on temu.com. The first touchmove arrives at APZ well before
that, the cached touchstart hit-test is reused, and the block stays
committed to async-scroll.

Add a direct content -> APZ IPC (NotifyApzAwareListenerAdded) carrying
the nearest scroll container's ViewID. APZCTreeManager records the
(LayersId, ScrollId) pair under mMapLock; WRHitTester ORs in
eApzAwareListeners when a hit-test result's target APZC equals that
pair or descends from it within the same layers id.

EventListenerManager::ProcessApzAwareEventListenerAdd resolves the
ScrollId via FindIDFor (not FindOrCreateIDFor): if no ViewID has
been assigned yet, or the element has no primary frame / scroll
container ancestor, fall back to the existing SchedulePaint path so
the regular display-list rebuild propagates the flag.

Fast-path entries are kept until the layer tree is removed
(NotifyLayerTreeRemoved). Clearing them in PrepareNodeForLayer would
race against a paint that was in flight when the listener was added.

Add MOZ_LOG=apz.fastpath logging on both sides to trace the flow.

Assignee: nobody → hikezoe.birchill
Status: NEW → ASSIGNED

In a subsequent change the information will be used.

With uploaded patches now the fast-path works independently from bug 1839095 (though some of patches have been migrated from bug 1839095, and the mochitest in D302255 is same as the one in bug 1839095).

No longer depends on: 1839095

Here is a try run: https://treeherder.mozilla.org/jobs?repo=try&revision=0137f84408b8604356e8cce54b1503fe6bfc3237

Botond, would you mind trying it to see whether the temu case is affected by these patches or not? Thanks!

(Note that the try run has just started, so building hasn't yet finished)

Flags: needinfo?(botond)

Today I opened the temu link in bug 2031963 on a local built with the patches here in this bug. I could see the dialog in question and dragging images doesn't cause any scrolling in RDM. So I think this fast-path route has impacts on the site.

Blocks: 2031963
Attachment #9588281 - Attachment description: WIP: Bug 2041154 - Fast-path notify APZ on non-passive APZ-aware listener registration. → Bug 2041154 - Fast-path notify APZ on non-passive APZ-aware listener registration. r?botond
Attachment #9589291 - Attachment description: WIP: Bug 2041154 - Wait for a content response on the first touch-move if needed. → Bug 2041154 - Wait for a content response on the first touch-move if needed. r?botond
User Story: (updated)

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

Here is a try run: https://treeherder.mozilla.org/jobs?repo=try&revision=0137f84408b8604356e8cce54b1503fe6bfc3237

Botond, would you mind trying it to see whether the temu case is affected by these patches or not? Thanks!

I tested in GeckoView Example, and I can confirm that a 2026-05-24 nightly build is affected by bug 2031963 (scrolling of the page happens while trying to drag the images), but the build from the linked Try push is unaffected!

Flags: needinfo?(botond)
Blocks: 2042628
Regressed by: 2043349
No longer regressed by: 2043349
Regressions: 2043349
Status: RESOLVED → REOPENED
Flags: needinfo?(hikezoe.birchill)
Resolution: FIXED → ---
Target Milestone: 153 Branch → ---
Pushed by amarc@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/940d4836920e https://hg.mozilla.org/integration/autoland/rev/f4f0298cb163 Revert "Bug 2041154 - Wait for a content response on the first touch-move if needed. r=botond" for causing bug 2043349
See Also: → 2043764

TargetConfirmationFlags.mDispatchToContent is not specific to
eApzAwareListeners, it can have other values. The four tests are to make
sure that the newly apprived eApzAwareListeners flag via the fast-path
doesn't prevent scrolling unexpectedly or does prevent scrolling
properly.

  • helper_bug2043349-static.html: static non-passive touchmove with
    preventDefault. Initial hit-test has eApzAwareListeners only.
    preventDefault is honored, no scrolling.
  • helper_bug2043349-irregular.html: clip-path:polygon irregular area
    with no APZ-aware listener. Initial hit-test has eIrregularArea
    only. scrolling proceeds.
  • helper_bug2043349-irregular-dynamic.html: irregular area plus a
    non-passive touchmove with preventDefault added by the touchstart
    handler. Initial hit-test has eIrregularArea; eApzAwareListeners is
    added via the fast path. preventDefault is honored, no
    scrolling.
  • helper_bug2043349-irregular-static.html: irregular area plus a
    static non-passive touchmove with preventDefault. Initial hit-test
    has both eApzAwareListeners and eIrregularArea.
    preventDefault is honored, no scrolling.

D302255 introduced a wait for a content response on the first
touch-move whenever the touch block dispatches to content, to give
a freshly-registered APZ-aware listener a chance to preventDefault().
That condition is too broad: it also fires on blocks whose
eApzAwareListeners flag came from the original hit-test, causing
scroll lag on Android.

Flags: needinfo?(hikezoe.birchill)
Regressions: 2043753
Flags: needinfo?(hikezoe.birchill)
Flags: needinfo?(hikezoe.birchill)
Blocks: 2044829

Comment on attachment 9591724 [details]
Bug 2041154 - Only wait for content response on first touch-move when the APZ-aware listener was just discovered via the fast path. r?botond

Revision D303520 was moved to bug 2044829. Setting attachment 9591724 [details] to obsolete.

Attachment #9591724 - Attachment is obsolete: true

Comment on attachment 9591725 [details]
Bug 2041154 - Narrow the APZ-aware listener fast-path IPC to non-passive touchmove listeners only. r?botond

Revision D303521 was moved to bug 2044829. Setting attachment 9591725 [details] to obsolete.

Attachment #9591725 - Attachment is obsolete: true
Pushed by hikezoe.birchill@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e9ef82decbb3 https://hg.mozilla.org/integration/autoland/rev/f952dfe00ca6 Add mFirstMoveSeen to TouchCounter. r=botond https://github.com/mozilla-firefox/firefox/commit/4fadd6573742 https://hg.mozilla.org/integration/autoland/rev/23ca22e2ea76 Propagate the initial touch move information to InputQueue from APZCTreeManager. r=botond https://github.com/mozilla-firefox/firefox/commit/f1ed0b7d9aa1 https://hg.mozilla.org/integration/autoland/rev/404f97262394 Encapsulate the long-tap touchmove content-response condition in a TouchBlockState method. r=botond https://github.com/mozilla-firefox/firefox/commit/f7b7a2394baa https://hg.mozilla.org/integration/autoland/rev/dc308925a994 Fast-path notify APZ on non-passive APZ-aware listener registration. r=botond https://github.com/mozilla-firefox/firefox/commit/10072211789a https://hg.mozilla.org/integration/autoland/rev/0c2e63fb7cdd Wait for a content response on the first touch-move if needed. r=botond https://github.com/mozilla-firefox/firefox/commit/b99ea692a938 https://hg.mozilla.org/integration/autoland/rev/9d076f1c3d5a Add mochitests for first touch-move content-response wait across the four eApzAwareListeners / eIrregularArea dispatch-to-content cases. r=botond https://github.com/mozilla-firefox/firefox/commit/5aa21e186af9 https://hg.mozilla.org/integration/autoland/rev/f28fdce40ca2 Factor out the utility function for fast fling. r=botond https://github.com/mozilla-firefox/firefox/commit/0e8e1f40989c https://hg.mozilla.org/integration/autoland/rev/4adabd48fd0a Do not wait the additional content response for touchmove during fast-fling. r=botond
Pushed by hikezoe.birchill@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/aedfae2a7a54 https://hg.mozilla.org/integration/autoland/rev/7184efcc320a Add mFirstMoveSeen to TouchCounter. r=botond https://github.com/mozilla-firefox/firefox/commit/8008521c09ec https://hg.mozilla.org/integration/autoland/rev/8e5e3b355053 Propagate the initial touch move information to InputQueue from APZCTreeManager. r=botond https://github.com/mozilla-firefox/firefox/commit/b038350254bd https://hg.mozilla.org/integration/autoland/rev/9f61d8a7373e Encapsulate the long-tap touchmove content-response condition in a TouchBlockState method. r=botond https://github.com/mozilla-firefox/firefox/commit/a7cf5ef9044c https://hg.mozilla.org/integration/autoland/rev/147e8a2919a0 Fast-path notify APZ on non-passive APZ-aware listener registration. r=botond https://github.com/mozilla-firefox/firefox/commit/656c61951aae https://hg.mozilla.org/integration/autoland/rev/4bd9b34883f1 Wait for a content response on the first touch-move if needed. r=botond https://github.com/mozilla-firefox/firefox/commit/5e16117b69bf https://hg.mozilla.org/integration/autoland/rev/81168254915c Add mochitests for first touch-move content-response wait across the four eApzAwareListeners / eIrregularArea dispatch-to-content cases. r=botond https://github.com/mozilla-firefox/firefox/commit/4e66d86bb046 https://hg.mozilla.org/integration/autoland/rev/e70158e76862 Factor out the utility function for fast fling. r=botond https://github.com/mozilla-firefox/firefox/commit/da66f8e44a54 https://hg.mozilla.org/integration/autoland/rev/22ef2c2275f5 Do not wait the additional content response for touchmove during fast-fling. r=botond
Blocks: 1839095
See Also: 2031963
Blocks: 2052759
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: