Closed Bug 1588438 Opened 5 years ago Closed 5 years ago

TouchEvent.changedTouches empty for emulated touchstart events in capture mode

Categories

(DevTools :: Responsive Design Mode, defect, P3)

66 Branch
Desktop
Unspecified
defect

Tracking

(firefox72 fixed)

RESOLVED FIXED
Firefox 72
Tracking Status
firefox72 --- fixed

People

(Reporter: ossman, Assigned: mtigley)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files)

Attached file changedtouches.html (deleted) —

User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0

Steps to reproduce:

  1. window.addEventListener('touchstart', foo, { capture: true });
  2. Try to examine TouchEvent.changedTouches[0]

Actual results:

Crash!

TypeError: event.changedTouches[0] is undefined

Expected results:

No crash.

Note that this concerns the emulator, not real touch events. It also only happens for capture listeners.

Also not in the test file that doing "console.log(event);" makes the problem go away. Something similar can also be seen by doing "console.log(event.changedTouches.length)" just before the crash and then enable "Pause on exceptions". The console will then clearly have printed "0", yet the debugger shows event.changedTouches to have a length of 1.

I.e. it really looks like there is a race here where the JavaScript is executed before the event object is properly set up.

This was noticed with noVNC, so it happens in real world code.

Hi Pierre!
We can not test because we don´t have the proper environment.
Beyond this, could you try to reproduce it in the latest Nightly version and let us know the results?.
You can download Nightly from here: https://nightly.mozilla.org/.
I'll add a product and component so the corresponding team can take a look at this

Component: Untriaged → Panning and Zooming
Flags: needinfo?(ossman)
Product: Firefox → Core

Ehm... You should be able to test this on any Linux machine. Probably any Windows or macOS machine as well.

Still, I did a test with nightly and it has the same bug.

Flags: needinfo?(ossman)

(In reply to Pierre Ossman from comment #1)

Note that this concerns the emulator, not real touch events.

What do you mean by "emulator" here? Are you referring to Tools -> Web Developer -> Responsive Design Mode?

I guess so, I can reproduce the issue in RDM.

(Note: I can only reproduce it with WebRender disabled. With WebRender enabled, I can't get the event handler to fire at all, which is probably an unrelated issue with RDM being broken with WebRender.)

Moving to the RDM component for triage, though based on a quick look, RDM does populate the changedTouches field, so perhaps the issue is at the DOM bindings level?

Component: Panning and Zooming → Responsive Design Mode
Product: Core → DevTools

I am able to reproduce this issue on RDM with macOS after refreshing the page when the above example is loaded.

RDM's touch simulator uses deprecated web API's when creating the touch events it's trying to simulate. See: https://searchfox.org/mozilla-central/source/devtools/server/actors/emulation/touch-simulator.js#331 .

A good first step is to refactor the use of these deprecated API's and replace them with their appropriate equivalents:

Assignee: nobody → mtigley
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P3
Hardware: Unspecified → Desktop

It seems like the refactoring in Comment 9 fixes this issue (yay!) and also Bug 1549220. I'll clean-up this patch and get it ready for a review.

Blocks: 1590301
Pushed by mtigley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/10ed362716f0 Refactor deprecated touch event APIs. r=ochameau
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 72
Regressions: 1608003
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: