Closed Bug 1556703 Opened 5 years ago Closed 4 years ago

invalid pointer id thrown when calling releasePointerCapture

Categories

(Core :: DOM: Events, defect, P3)

67 Branch
defect

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: adrian, Assigned: edgar)

References

Details

Attachments

(3 files, 1 obsolete file)

Attached image Screenshot (4).png

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

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!

Flags: needinfo?(adrian)

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.

Component: Untriaged → Debugger
Product: Firefox → DevTools

Routing this to DOM.
I'm not sure how to test this given it sounds like a windows surface pro issue.

Component: Debugger → DOM: Core & HTML
Product: DevTools → Core
Blocks: 822898
Component: DOM: Core & HTML → DOM: Events
Priority: -- → P3
Flags: needinfo?(adrian)

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.

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.

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.

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: nobody → echen
Severity: normal → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true

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.

Depends on D101667

Attachment #9196958 - Attachment is obsolete: true

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

Pushed by echen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f974e2d15f99 Part 1: Update active pointer state properly; r=smaug https://hg.mozilla.org/integration/autoland/rev/fe36e0858eb2 Part 2: Convert new added WPT into mochitest test; r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27235 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: