Closed Bug 1695574 Opened 3 years ago Closed 4 months ago

pointermove fails to fire on a touch screen

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P2)

Firefox 88
defect

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: ian, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome)

Attachments

(5 files)

Attached file broke.html

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15
Firefox for Android

Steps to reproduce:

In Firefox 77+, on a touch screen device or on desktop simulating touches:
Inside of a pointerdown handler, add a pointermove handler to the document. Also, in the the pointerdown handler, reappended the event target to its parent.

Note: Though this reappending is kinda weird, it's necessary when managing z-space in SVGs.

Actual results:

The pointermove handler is never called during subsequent pointermove / drag.

Expected results:

The pointermove handler should be called.
(Works in iOS and Chrome)

Thank you for this report!
Can you please add the steps on how to reproduce this issue?
Also, can you confirm that you can reproduce it on a physical Android device? (attach a video if possible).

Note that I clicked on it and then I tried to drag it down, but on Fenix, we have drag down to refresh on a page.

Flags: needinfo?(ian)

I'll try and provide a video later today.

Note: In the example, there's no need to drag down specifically. You can touch the button and move your finger up or sideways for example.

Flags: needinfo?(ian)

Hello Ian, can you please attach the video when you have time?
Thanks!

Flags: needinfo?(ian)
Flags: needinfo?(ian)

Sincere apologies!

I've added two videos. FWIW, the issue also reproduces on desktop with Responsive Design Mode enabled.

Component: Untriaged → DOM: Events
Product: Firefox → Core

Edgar: can you please help triaging this ticket?

Flags: needinfo?(echen)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: parity-chrome

Yeah, looks like something related to bug 1609529. But a bit different, in this case, the element is re-appended to the DOM tree.
I will take a closer look at some point.

Component: DOM: Events → DOM: UI Events & Focus Handling
Blocks: 822898
Severity: -- → S3
Priority: -- → P3
Blocks: pointerevent
No longer blocks: 822898
Flags: needinfo?(echen)
Summary: pointermove fails to fire → pointermove fails to fire on a touch screen

Could we try to prioritize this a bit?

Flags: needinfo?(htsai)

I just hit the same issue:

  • I'm trying to implement a "drag"-type interaction, initiated by a pointerdown event
  • I'm moving the target element around in the DOM before doing setPointerCapture
  • pointermove events are not delivered, even though setPointerCapture succeeds.
  • Issue only happens on Firefox mobile, alas.

My test case is not nearly as minimal, but it contains a strange clue: it implements a very similar interaction that does not trigger the bug. Details in the attachment.

Attached file 200-line test case
  • Issue only happens on Firefox mobile, alas.

...Or on desktop with touch simulation enabled, like the original reporter. Not just the mobile product.

Moving or removing the original pointerdown target element seems necessary.

With this patch, the bug doesn't happen.

diff --git a/simpler.html b/simpler.html
index 0b0c85e..9f22828 100644
--- a/simpler.html
+++ b/simpler.html
@@ -88,7 +88,8 @@
 
       function movePieceToDragGroup(dragGroup, i) {
         const piece = document.getElementById("piece-" + i);
-        dragGroup.appendChild(piece);
+        dragGroup.innerHTML += piece.outerHTML.replace('id="piece-', 'id="fake-dragging-piece-');
+        piece.style.visibility = "hidden";
       }
 
       function onDragMove(event) {
@@ -110,6 +111,7 @@
           }
           for (const i of pieceIds) {
             const piece = document.getElementById("piece-" + i);
+            piece.style.visibility = null;
             document.getElementById("board").appendChild(piece);
           }
           const e = document.getElementById("drag-group");

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #10)

Could we try to prioritize this a bit?

Sure! Will plan for it.

Flags: needinfo?(htsai)
Priority: P3 → P2

Odd, this is not reproducible if [the testcase is in an <iframe> with the touch simulator. If I unwrap the test from the <iframe>, I got the following events only pointerdown on the <button> and click on the <button>.

Hmm, and I disable e10s to get the dispatcher of eTouchStart and eTouchMove, I cannot reproduce this bug...

Oh, it seems that this is caused by this if condition. Indeed, it's not defined by the specs. The code was introduced at initial implementation of Pointer Events. And I don't find the comments for this check in the bug. Therefore, I guess that nobody knows about the reason why we considered as so.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED

Oh, no! Chrome's behavior is also really odd, we probably cannot follow it as-is.

Chrome dispatches pointerup immediately after pointerdown. Then, appending the target cause another pointerdown! Then, touchstart is fired which is not followed by touchmove events. Finally, pointerup and touchend are fired. I don't understand why pointerdown is retriggered...

Additionally, Chrome starts dispatching touchmove once the touch moves out from the target...

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #19)

Oh, no! Chrome's behavior is also really odd, we probably cannot follow it as-is.

Chrome dispatches pointerup immediately after pointerdown. Then, appending the target cause another pointerdown! Then, touchstart is fired which is not followed by touchmove events. Finally, pointerup and touchend are fired. I don't understand why pointerdown is retriggered...

Ah, this is caused by a bug of my test. The extra pointerdown and pointerup are not fired actually. However, the touchmove issue is odd.

As far as investigating the behavior of the other browsers, touch events are
dispatched the same target as the preceding pointerdown even after the target
is removed from the DOM tree. However, the following pointer events are
dispatched on the target as usual (i.e., the element under the pointer except
when the pointer is captured). However, our code stops handling touch events
if the preceding pointerdown removes the target and not dispatching
touchstart causes not dispatching the following touch events so that no
click event is fired.

This patch makes the touch event dispatching path work without frame and
keep handling even with an orphan event target.

Depends on D202377

See Also: → 1876213
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/0c3a2df68be4
Make `PresShell::EventHandler::HandleEventUsingCoordinates` keep handling touch events after preceding pointer event target is removed r=smaug,edgar,dom-core
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/45049 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
Upstream PR merged by moz-wptsync-bot
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: