Support swipe-to-nav on touchscreen with the main thread (Windows)
Categories
(Core :: Panning and Zooming, enhancement, P2)
Tracking
()
| 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 | ||
Updated•1 month ago
|
| Assignee | ||
Comment 1•18 days ago
|
||
No behavior change.
| Assignee | ||
Comment 2•18 days ago
|
||
No behavior change. The part of DispatchTouchInput that updates the
touch swipe state with an input APZ has handled moves to
HandleTouchInputForSwipe().
| Assignee | ||
Comment 3•18 days ago
|
||
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.
| Assignee | ||
Comment 4•18 days ago
|
||
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.
| Assignee | ||
Comment 5•18 days ago
|
||
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.
| Assignee | ||
Comment 6•18 days ago
|
||
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 considers touchmove listeners as well when APZ processes the
touchstart event.
(https://searchfox.org/firefox-main/rev/fa1e90ea670c4234c61b65a05dc02032b9bcde03/dom/events/EventListenerManager.cpp#2271,2281-2284) - Content holds its response about preventDefault until the first
touchmove, when the touchstart is not prevented.
(https://searchfox.org/firefox-main/rev/fa1e90ea670c4234c61b65a05dc02032b9bcde03/gfx/layers/apz/util/APZEventState.cpp#297,299,303,329,341)
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.
| Assignee | ||
Comment 7•18 days ago
|
||
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.
| Assignee | ||
Comment 8•18 days ago
|
||
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...
- When a non-passive touchmove listener is not in APZ's hit-test
information yet, e.g. it is added in a touchstart passive listener.
APZ checks such listeners on the first touchmove (i.e., fast path). - After a long tap, because content sends its held response on the long
tap.
(content side reference: https://searchfox.org/firefox-main/rev/d9bd6be9a67efb1c2667ef91a89856f35eb7cf5e/gfx/layers/apz/util/APZEventState.cpp#203)
(APZ side reference: https://searchfox.org/firefox-main/rev/d9bd6be9a67efb1c2667ef91a89856f35eb7cf5e/gfx/layers/apz/src/InputQueue.cpp#229-236)
After the content response timeout, the widget does not wait on the
touchmove, because APZ has stopped waiting for the content response.
| Assignee | ||
Comment 9•18 days ago
|
||
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.
Updated•17 days ago
|
Comment 10•14 days ago
|
||
Comment 11•14 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/5348b74d8094
https://hg.mozilla.org/mozilla-central/rev/07487bac6f80
https://hg.mozilla.org/mozilla-central/rev/a54f53688d3a
https://hg.mozilla.org/mozilla-central/rev/7a86a3cd2ed4
https://hg.mozilla.org/mozilla-central/rev/eb65533efa8c
https://hg.mozilla.org/mozilla-central/rev/87514bc82827
https://hg.mozilla.org/mozilla-central/rev/57a06eb59bba
https://hg.mozilla.org/mozilla-central/rev/47803bb27822
https://hg.mozilla.org/mozilla-central/rev/ab5eaf433784
Updated•4 hours ago
|
Description
•