Touchevent order is confusing when one finger lifts and another touches down in the same WM_TOUCH
Categories
(Core :: Widget: Win32, defect)
Tracking
()
People
(Reporter: canalun, Unassigned)
References
Details
nsWindow::OnTouch splits one WM_TOUCH into two inputs and dispatches them in this order:
- MULTITOUCH_START (or MOVE) with the DOWN and MOVE contacts
- MULTITOUCH_END with the UP contacts
(https://searchfox.org/firefox-main/rev/dcafde486e11b7a7776137b92fec2a6f56744eab/widget/windows/nsWindow.cpp#6929-6936)
If finger A lifts and finger B touches down in the same WM_TOUCH, the contacts are [A: UP, B: DOWN], and we dispatch MULTITOUCH_START[B] first followed by MULTITOUCH_END[A].
But this behavior can make consumers such as TouchCounter confused. For example, the below will happen for TouchCounter.
Input Count
(A is down) 1
MULTITOUCH_START[B] 1 (A is already gone from the list)
MULTITOUCH_END[A] 0 (A is subtracted again)
^ **The count becomes 0 while B is still down.
Some parts assume it's the end of the end of the touch sequence when the counter gets 0. As far as I know, for example...
- Touchscreen swipe-to-nav seems to have crashed with MOZ_RELEASE_ASSERT. Bug 2088553 is trying to work around it in nsIWidget::DispatchTouchInput.
- APZCTreeManager also uses TouchCounter. When the count becomes 0, it clears mTouchBlockHitResult, so the rest of B's moves will be ignored by APZ. B probably can't scroll the page. (Not confirmed on a device.)
FYI, I've found that this order was questioned in bug 726615 comment 31, when this code was written:
I think this is fine, but you might want to reverse the order of the two blocks here, so the NS_TOUCH_END event is dispatched first. Then PresShell will remove that point from its tracking list and won't be expecting to see it in the next START or MOVE event. (Otherwise the START event could trigger PresShell's EvictTouchPoint, which would generate its own NS_TOUCH_END event before yours is dispatched. Though this only matters in practice if Windows ever sends a DOWN for one input and an UP for another in the same message.)
Comment 1•22 days ago
|
||
(In reply to Kanaru Sato [:canalun] from comment #0)
FYI, I've found that this order was questioned in bug 726615 comment 31, when this code was written:
I think this is fine, but you might want to reverse the order of the two blocks here, so the `t. Then PresShell will remove that point from its tracking list and won't be expecting to see it in the next START or MOVE event. (Otherwise the START event could trigger PresShell's EvictTouchPoint, which would generate its own NS_TOUCH_END event before yours is dispatched. Though this only matters in practice if Windows ever sends a DOWN for one input and an UP for another in the same message.)
I believe NS_TOUCH_END event is dispatched first would be also problematic. (Note that Claude also told me the approach). The order of dispatching touchInput and touchEndInput should be done in the right order when TOUCHEVENTF_UP came, when TOUCHEVENTF_DOWN | TOUCHEVENTF_MOVE) came.
| Reporter | ||
Comment 2•22 days ago
|
||
That's true. Events should be dispatched in the order, i.e., first in, first out.
I think it should be investigated if WM_TOUCH has any information of order when it has multiple TOUCHINPUTs.
Updated•21 days ago
|
Description
•