Closed Bug 2085128 Opened 1 month ago Closed 14 days ago

Support swipe-to-nav on touchscreen with the main thread (Windows)

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: canalun, Assigned: canalun)

References

(Blocks 1 open bug)

Details

Attachments

(9 external files)

To fully support Bug 1443710, implement swipe-to-nav with the main thread, which is exactly what Bug 2085126 doesn't support.

Assignee: nobody → i.am.kanaru.sato
Blocks: 1443710
Priority: -- → P2
See Also: → 2085126

No behavior change. The part of DispatchTouchInput that updates the
touch swipe state with an input APZ has handled moves to
HandleTouchInputForSwipe().

When APZ cannot tell the swipable directions synchronously on touchstart,
it will need to tell the widget once it can. This adds
GeckoContentController::NotifyTouchSwipeResult and a callback that
InputQueue can call to reach it on the root controller. In the GPU
process, RemoteContentController forwards it to the parent process over
PAPZBridge, where ChromeProcessController receives it on the UI thread.

Nothing calls it yet, and ChromeProcessController does not pass it to the
widget yet.

If the target APZC is not confirmed on touchstart, for example when the
touch is in an irregular area that needs a hit test on the main thread,
APZ cannot compute the swipable directions. Instead of using the
tentative target, APZ now asks the widget to wait, and notifies it once
the target is confirmed.

While waiting, the widget passes inputs to APZ as usual, queues them, and
replays them when the result arrives. A new touch block starting during
WaitingForAPZ phase discards the queue. If that is a new touch gesture,
a new swipe gesture starts, and, if that is an added finger, the ongoing
swipe is rejected.

Note that timeout mechanics are added in subsequent patches.

Swipe also depends on touch-action. Treat it like the target, i.e., the
widget waits until both are known, and APZ notifies it when the last of
them arrives.

In practice, content sends touch-action before it confirms the target.
(https://searchfox.org/firefox-main/rev/fa1e90ea670c4234c61b65a05dc02032b9bcde03/dom/ipc/BrowserChild.cpp#1979,1983-1985)
That means APZ knows touch-action when it gets to know the target.
So, strictly speaking, touch-action is handled properly even without
this patch.

Note that timeout mechanics are added in subsequent patches.

If there is a non-passive touchstart or touchmove listener when APZ
handles the touchstart, the widget waits for the response from APZ.
APZ will send the result to the widget when it receives the content
reponse. APZ prevents swipe if the event is preventDefault-ed, by
sending SideBits::eNone.

Note that the wait on touchstart also covers the touchmove listener,
because...

APZ can also start waiting for a content response on the first
touchmove. That case is handled in a later patch.

Note that timeout mechanics are added in the next patch.

If the target, touch-action or the content response does not arrive
before APZ's content response timeout, notify the widget at that
point so that it stops waiting. In that case, swipe is acceptable, in
the same way as APZ proceeds scrolling when timeout happens.

The swipable directions are computed as APZ handles the
block after the timeout, i.e., with the target APZ has guessed, with
touch-action allowing any panning if it is unknown, and as if the block
were not prevented.
As a result, swipe is allowed in the direction in which APZ cannot scroll.

Note that if content prevents the block after the timeout, APZ drops
the rest of the block, but an ongoing swipe is not canceled. This
patch accepts that, because that doesn't seem harmful.

Note that TouchBlockState::TimeoutContentResponse doesn't tweak
mWaitingForBrowserGestureResponse as
PanGestureBlockState::TimeoutContentResponse does, because
the widget will give a reply about browser gesture response
when it processes the queue.

Regarding timer for browser gesture response, it is considered
unnecessary. This is because APZ will tell the widget swipable directions
regardless of whether APZ receives the content response or not, and
therefore the widget will always send the browser gesture response
to APZ. There might be room for optimization, but this patch doesn't
do that.

APZ can start waiting for a content response about preventDefault on
the first touchmove out of slop.
Note that it can happen even if APZ waited on the touchstart, considering
long tap (See TouchBlockState::NeedsContentResponseAfterLongTap()).
In these cases, the widget has to wait on that touchmove too, even if
it already knows the swipable directions, because preventDefault on
the touchmove can prevent swipe.

This case happens...

After the content response timeout, the widget does not wait on the
touchmove, because APZ has stopped waiting for the content response.

It's possible that APZ sends the result for a block and then, before it
reaches the widget, starts a new wait for the same block on its first
touchmove. When the widget replays its queue for the first result, it
reaches that touchmove and starts waiting again.

An example flow is like this:

  • the widget receives the touchstart and passes it to APZ
  • APZ can't confirm touch-action, so it sets this touchstart's
    mTouchSwipeNeedsToWait as true
  • the widget receives the result and starts to wait
  • APZ receives touch-action from content and send swipable directions
    to the widget -- *1
  • (the swipable directions are now in flight)
  • a new touchmove non-passive listener is set -- *2
  • the widget receives the touchmove and passes it to APZ
  • APZ now has an APZ-aware listener (*2), so it starts to wait for
    content response. And it has no mTouchSwipeResultCallback (*1).
    So APZ sets this touchmove's mTouchSwipeNeedsToWait as true
  • the widget receives the result and queues it
  • finally, the widget receives the swipable directions for the
    touchstart. So it starts to process the queue
  • while processing the queue, the queued touchmove changes the phase
    to WaitingForAPZ

This race is not likely to happen, but in this case, the remaining queued
inputs have to be moved to the new queue instead of processing them.

Couldn't write a test case to reproduce this race reliably.

Attachment #9677503 - Attachment description: Bug 2085128 - swipe-to-nav on touchscreen: Stop waiting and allow swipe when the main thread does not respond in time. r?hiro → Bug 2085128 - swipe-to-nav on touchscreen: Stop waiting and reject swipe when the main thread does not respond in time. r?hiro
See Also: → 2091199
Pushed by i.am.kanaru.sato@gmail.com: https://github.com/mozilla-firefox/firefox/commit/cab176a72691 https://hg.mozilla.org/integration/autoland/rev/5348b74d8094 swipe-to-nav on touchscreen: Extract TouchSwipeState into separate files. r=hiro https://github.com/mozilla-firefox/firefox/commit/f2b976ee16a9 https://hg.mozilla.org/integration/autoland/rev/07487bac6f80 swipe-to-nav on touchscreen: Split HandleTouchInputForSwipe out of DispatchTouchInput. r=hiro https://github.com/mozilla-firefox/firefox/commit/bbc22a061764 https://hg.mozilla.org/integration/autoland/rev/a54f53688d3a swipe-to-nav on touchscreen: Add a path for APZ to notify the widget of the swipable directions later. r=hiro https://github.com/mozilla-firefox/firefox/commit/1eab978bc577 https://hg.mozilla.org/integration/autoland/rev/7a86a3cd2ed4 swipe-to-nav on touchscreen: Wait for APZ when the target is not confirmed on touchstart. r=hiro https://github.com/mozilla-firefox/firefox/commit/1ee79b6e5951 https://hg.mozilla.org/integration/autoland/rev/eb65533efa8c swipe-to-nav on touchscreen: Wait for APZ when touch-action is not known on touchstart. r=hiro https://github.com/mozilla-firefox/firefox/commit/16d74a02f4d4 https://hg.mozilla.org/integration/autoland/rev/87514bc82827 swipe-to-nav on touchscreen: Wait for APZ when APZ starts to wait for a content response on touchstart. r=hiro https://github.com/mozilla-firefox/firefox/commit/37dd6e73cc41 https://hg.mozilla.org/integration/autoland/rev/57a06eb59bba swipe-to-nav on touchscreen: Stop waiting and reject swipe when the main thread does not respond in time. r=hiro https://github.com/mozilla-firefox/firefox/commit/6d0af1fde20e https://hg.mozilla.org/integration/autoland/rev/47803bb27822 swipe-to-nav on touchscreen: Wait when APZ starts waiting for a content response on the first touchmove. r=hiro https://github.com/mozilla-firefox/firefox/commit/e38e2d027027 https://hg.mozilla.org/integration/autoland/rev/ab5eaf433784 swipe-to-nav on touchscreen: Handle a touchmove that starts a new wait while a result is in flight. r=hiro
Regressions: 2092749
Regressions: 2093306
QA Whiteboard: [qa-triage-done-c163/b162]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: