invalid pointer id thrown when calling releasePointerCapture
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox86 | --- | fixed |
People
(Reporter: adrian, Assigned: edgar)
References
Details
Attachments
(3 files, 1 obsolete file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Steps to reproduce:
The following doesn't work in firefox 67 on a surface pro
element.addEventListener('pointerdown', event => {
element.setPointerCapture(event.pointerId);
});
element.addEventListener('pointerup', event => {
element.releasePointerCapture(event.pointerId);
});
reproducible in mozilla's own example at https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
Actual results:
Invalid pointer id thrown
Expected results:
its should have release the pointer capture successfully, it works in chrome
Comment 1•5 years ago
|
||
I can't reproduce the issue and confirm the bug with the information provided. Can you help me confirm it? We need clear and simple steps of reproduction along with actual and expected results to be verified.
Thank you for your contribution!
Comment 2•5 years ago
|
||
I do not understand the issue to confirm it, but I setting its component to (DevTools) Debugger. Please set it to a more appropriate one if this isn't correct. Thank you.
Comment 3•5 years ago
|
||
Routing this to DOM.
I'm not sure how to test this given it sounds like a windows surface pro issue.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 4•5 years ago
|
||
I could confirm this issue since I have a Surface Pro 2, but I do not know how to read/use the description.
I can confirm as well using FF 72.0.1 64bit on Ubuntu Mate 18.04 bionic (running env MOS_USE_XINPUT2=1 firefox
to enable touch screen input)
Using mouse (which has pointerId
0 gives no console error)
In some scripted scenarios this behavior might fail to detect a click/tap where other browsers don't have this problem.
(In reply to myself from comment #5)
I can confirm as well using FF 72.0.1 64bit on Ubuntu Mate 18.04 bionic (running
env MOZ_USE_XINPUT2=1 firefox
to enable touch screen input)Using mouse (which has
pointerId
0 gives no console error)In some scripted scenarios this behavior might fail to detect a click/tap where other browsers don't have this problem.
A typo needs to be addressed: env MOZ_USE_XINPUT2=1 firefox
Also, it must be said that a pointer release is inherent when working with touch (which differs from mouse and pen); one might want to work around this reported bug by checking the pointer type first
if ( event.pointerType !== "touch" )
element.releasePointerCapture( event.pointerId );
Furthermore: when calling element.releasePointerCapture( 0 );
in pointerup
for both mouse and touch: no error is displayed.
Comment 7•5 years ago
|
||
Just happened to me as well on Mozilla Nightly (78.0a1) on Android (console displayed through ADB).
I found this, I don't know if that's of any help : https://github.com/jquery/PEP/issues/275
I am using PEP.js in my app for compatibility with my other firefox for android browser (which I didn't test yet).
The thing is that they quote the spec :
The spec draft at W3C says "Immediately after firing the pointerup or pointercancel events, a user agent must run the steps as if the releasePointerCapture() method has been called with an argument equal to the pointerId property of the pointerup or pointercancel event just dispatched."
https://w3c.github.io/pointerevents/#implicit-release-of-pointer-capture
Maybe it's just happening too soon in firefox?
Anyway, that also means that I don't need to care about releasing the capture myself, since it is automatically done on pointer up.
Comment 8•4 years ago
|
||
This issue is still occurring on Firefox 79 on Windows 10 1903. Pointer events generated from a trackpad or mouse work fine, but when using touch or pen cause a "Uncaught DOMException: Invalid pointer id." when releasing pointer capture.
The theory in comment #7 seems relevant.
I took the example from the MDN setPointerCapture page and added some logging statements: https://jsfiddle.net/1a67p2hL/1/
To repro:
Use a Windows device with a touchscreen or stylus, e.g. Lenovo Thinkpad X1 Yoga Gen 3.
Load https://jsfiddle.net/1a67p2hL/1/
Click Run
Use the mouse and click and drag on the "Slide me" div in the demo window. Note that it slides around and stops on mouseup as expected, and logs "Capturing pointer 1" and "Releasing pointer 1".
Use the touchscreen or stylus to click and drag on the "Slide me" div in the demo window. Note that it slides around as expected and logs "Capturing pointer 2291" "Releasing pointer 2291", but on pointerup crashes with an InvalidPointerId exception.
This affects among other things drawing notes on https://keep.google.com and drawings on https://canvas.apps.chrome.
Comment 9•4 years ago
|
||
I tested relying on implicit release of pointer capture instead of explicit releasePointerCapture calls, and it seems to work fine for my use case in Chrome 84, Firefox 79, Edge 85 (Chromium-based Edge), Edge 44 (old EdgeHTML version), and Safari 13.1.
To be clear, the workaround for this bug is to skip calling releasePointerCapture and instead let the pointer capture be released by the browser on pointerup/pointercancel, which is in the spec and seems to be implemented correctly across browsers.
The bug here is that calling releasePointerCapture in a pointerup/pointercancel handler throws an error only in Firefox. The other tested browsers do not throw an error. It may have to do with the timing of the implicit release and pointer event handler.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 10•4 years ago
|
||
Removing the active pointer in PreHandleEvent is too early, so calling
setPointerCapture or releasePointerCapture in pointerup event handler would
throw error. Defer the removing to PostHandeEvent to make active pointer
available in pointerup event handler.
Assignee | ||
Comment 11•4 years ago
|
||
Depends on D101667
Updated•4 years ago
|
Assignee | ||
Comment 12•4 years ago
|
||
Geckodriver doesn't support touch input yet, so convert new added the touch tests
into mochitest, these mochitest wpt could be removed once we could pass the
corresponding tests in wpt.
Depends on D101667
Assignee | ||
Comment 13•4 years ago
•
|
||
Assignee | ||
Comment 14•4 years ago
|
||
Comment 15•4 years ago
|
||
Comment 17•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/f974e2d15f99
https://hg.mozilla.org/mozilla-central/rev/fe36e0858eb2
Description
•