Closed Bug 1606832 Opened 5 years ago Closed 9 days ago

Pen input(~wacom tablet) recognized as mouse in firefox

Categories

(Core :: Widget: Gtk, enhancement, P2)

71 Branch
enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1501744

People

(Reporter: matus.majchrak, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36

Steps to reproduce:

OS: Linux(Fedora)
Hi, when working with tablet and pen as input device under linux, the browser does not not recognize it as pressure sensitive pointing device, and treat it as a primary mouse input.

Actual results:

All the pointerEvents done with the pen have these properties:
PointerType==mouse
isPrimary==true
pressure==0.5(if pressed)

In other apps(Krita, Gimp...) the pen works fine, pressure is detected accordingly.

Expected results:

PointerEvents triggered by pressure sensitive pen should correctly report the pressure values(and other values like tilt, etc).

Hello, we do not have any graphic tablets available so we can't check the issue ourselves, from what i can understand there is a plugin from Wacom that covers browser functionality, you could try using that and then return with any insight you might gather. Also, does the pen input work well in other browsers?

Flags: needinfo?(matus.majchrak)

hi thanks for your feedback. There was a plugin for wacom tablets - but it relies on npapi which is not supported anymore. It does not work in Chrome in linux either. My understanding was, that as X11 seems to be able to recognize pen events, with pressure values, etc that it should be just propagated to browsers(and any other application) via standard input api. Not sure what is the interface between Firefox and lower level input api, if gtk or something gets in the way... I am obviously just guessing, I did not have time to look into the source code. Is there any other way how to test pointerEvents api(incl pressure sensitivity) in Firefox on Linux?

Flags: needinfo?(matus.majchrak)

I'm setting the component so that someone specialized on the matter can join in and help us out.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

Which Fedora is that?
Thanks.

Type: defect → enhancement
Flags: needinfo?(matus.majchrak)
Priority: -- → P3

Fedora 30

Flags: needinfo?(matus.majchrak)

I can reproduce this issue on both Firefox 77 and Chrome 81 on Lubuntu 19.10 (LxQt DE, Openbox WM).

Steps:

  1. Go to https://patrickhlauke.github.io/touch/tracker/tracker-force-pressure.html
  2. Move the pen around. Tap the pen on the tablet.

What happens:

  • Both the mouse and the pen shows up as "pointer (mouse)".
  • The pressure jumps from 0.0 to 0.5 when pressing the pen.

What should happen (i.e. what happens on a Windows machine):

  • The mouse shows up as "pointer (mouse)", the pen shows up as an additional circle "pointer (pen)".
  • The pressure smoothly changes when pressing the pen.

What you need:

  • A Wacom tablet that is working correctly. You can test the pressure in Gimp, Inkscape, Xournal, and others. You may need to first enable pressure in each of those tools.

Further thoughts:
Both Chrome and Firefox have the same behavior on Linux. It's possible the issue lies outside the browsers, maybe the X configuration should report each device as a separate pointer (MPX), then the browser would be able to use them. I don't know, I don't understand how it works.

TLDR: Pressure works for me by setting the environment variable MOZ_USE_XINPUT2=1.

I am new to firefox but I had the same issue and digged a little bit through the source code. The issue appears to be caused by the following code (toolkit/xre/nsAppRunner.cpp):

#  if defined(MOZ_WIDGET_GTK) && defined(MOZ_X11)
  // Disable XInput2 multidevice support due to focus bugginess.
  // See bugs 1182700, 1170342.
  // gdk_disable_multidevice() affects Gdk X11 backend only,
  // the multidevice support is always enabled on Wayland backend.
  const char* useXI2 = PR_GetEnv("MOZ_USE_XINPUT2");
  if (!useXI2 || (*useXI2 == '0')) gdk_disable_multidevice();
#  endif

On my machine, calling gdk_disable_multidevice() (see https://valadoc.org/gdk-3.0/Gdk.disable_multidevice.html) causes all mouse events to be caused by the Core Pointer device (obtained with gdk_event_get_source_device()) which does not seem to support pressure.
Without calling this function, events are caused either by Tablet Monitor Pen stylus or Logitech MX Master 3000 depending on which device I use.

Hence, we can set the environment variable MOZ_USE_XINPUT2=1 to avoid the function being called. But I am not sure if there are any downsides to setting that.

Having the same issues with Firefox 79.0 using a Wacom Intuos. Sadly setting MOZ_USE_XINPUT2=1 did not solve it for me.

Got the same issue in Chrome though, so might be something else.
I'd be happy to help get this to work if someone has more experience tracking this issue down.

(In reply to antifermion from comment #7)

TLDR: Pressure works for me by setting the environment variable MOZ_USE_XINPUT2=1.

On my system if I set that variable I will get pressure input but it will still show up as a mouse. Also I don't get tilt input either.

I can confirm the issue on my system: Debian GNU/Linux with Firefox Nightly and Wacom Intuos 3.
The tablet works correctly in graphics applications and is listed by xinput:

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ 2.4G Mouse Mouse                          id=10   [slave  pointer  (2)]
⎜   ↳ 2.4G Mouse Consumer Control               id=11   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos3 6x11 Pad pad                id=16   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos3 6x11 Pen stylus             id=17   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos3 6x11 Pen eraser             id=19   [slave  pointer  (2)]
⎜   ↳ Wacom Intuos3 6x11 Pen cursor             id=20   [slave  pointer  (2)]

In both Firefox and Chromium, onpointerdown event from the tablet shows:

pointerId: 0
pointerType: mouse
pressure: 0.5
tiltX: 0
tiltY: 0

Changing MOZ_USE_XINPUT2 to 1 does enable correct pressure readings, but the device is still reported as mouse with ID 0 and no tilt input.

I can confirm this issue on Fedora 35 KDE with Firefox 96.0.3.
It seems to the be same issue which Xournalpp suffers (https://github.com/xournalpp/xournalpp/issues/2273).

Testing with https://patrickhlauke.github.io/touch/tracker/tracker-force-pressure.html I can confirm that the workaround unset GDK_CORE_DEVICE_EVENTS && firefox works for me.

Regarding Fedora, here's the root issue: https://bugzilla.redhat.com/show_bug.cgi?id=1226465#c47

Confirming that this bug does exist on Ubuntu 20.04 as well. Setting MOZ_USE_XINPUT2 to 1 also enables pressure sensitivity. I used the testing link provided to verify. However, as others have noted, the device is still recognized as a mouse. For an online drawing app I'm using, this is enough to thwart it and prevent pressure sensitivity, even though the info is available.

What's distinct about the Ubuntu case is that Chrome is working just fine-- it both identifies the device as a pen and determines the pressure. So if there's an issue that is preventing both Chrome and Firefox from working on Fedora, it doesn't exist on Ubuntu.

Severity: normal → S3

I'm on Firefox 106.0.3 on Ubuntu 22.10. Testing with https://patrickhlauke.github.io/touch/tracker/tracker-force-pressure.html shows that the pen is recognized as a pressure-sensitive mouse.

(In reply to miromarszal from comment #14)

I'm on Firefox 106.0.3 on Ubuntu 22.10. Testing with https://patrickhlauke.github.io/touch/tracker/tracker-force-pressure.html shows that the pen is recognized as a pressure-sensitive mouse.

I think that's Wayland, right?

Flags: needinfo?(miroslaw.marszalek)

(In reply to Martin Stránský [:stransky] (ni? me) from comment #15)

(In reply to miromarszal from comment #14)

I'm on Firefox 106.0.3 on Ubuntu 22.10. Testing with https://patrickhlauke.github.io/touch/tracker/tracker-force-pressure.html shows that the pen is recognized as a pressure-sensitive mouse.

I think that's Wayland, right?

Yep, that's on Wayland. Maybe it's worth to mention that touch input is recognized correctly. Just checked on X, and there everything is recognized as mouse, even the touchscreen.

Flags: needinfo?(miroslaw.marszalek)
Summary: Pen input(~wacom tablet) recognized as mouse in firefox → [X11] Pen input(~wacom tablet) recognized as mouse in firefox

I think changing this bug to [X11] is incorrect, because:

(In reply to miromarszal from comment #14)

I'm on Firefox 106.0.3 on Ubuntu 22.10. Testing with https://patrickhlauke.github.io/touch/tracker/tracker-force-pressure.html shows that the pen is recognized as a pressure-sensitive mouse.

According to that report, the pen is still being incorrectly reported as a mouse, because it should be reported as a pen. (And that report was on Wayland.)

In fact, that tracker-force-pressure demo page can correctly display three kinds of devices: mouse, pen, touch. It can display the pressure, but I'm not sure if it can show the pen tilt. I don't have any tablet with tilt support, so I can't check.

For comparison, here's Google Chrome 107.0.5304.87 on KDE/Plasma on X11 on Manjaro Linux: https://i.imgur.com/Nt1rOGL.png It correctly displays the two devices (mouse and pen) and correctly shows the pen pressure. (I don't have any touch input, so I can't show that.)

(In reply to Denilson Figueiredo de Sá from comment #17)

I think changing this bug to [X11] is incorrect, because:

Okay. Unfortunately I don't have any such hardware so I can't do anything here.

Summary: [X11] Pen input(~wacom tablet) recognized as mouse in firefox → Pen input(~wacom tablet) recognized as mouse in firefox

(In reply to Martin Stránský [:stransky] (ni? me) from comment #18)

Okay. Unfortunately I don't have any such hardware so I can't do anything here.

I'm happy to help out, but I'd need instructions. Any benchmarks a relatively uninitiated user could run?

(In reply to miromarszal from comment #19)

(In reply to Martin Stránský [:stransky] (ni? me) from comment #18)

Okay. Unfortunately I don't have any such hardware so I can't do anything here.

I'm happy to help out, but I'd need instructions. Any benchmarks a relatively uninitiated user could run?

I'd also be happy to help as i can if you need benchmarks on drawing tables (i own a wacom ctl-472).

Can confirm that the bug persists on 109.0.1 on wayland(, using Xencelabs medium tablet).
According to the pointerdown checker page, its a pressure sensitive mouse.

Also, the pointer pressure seems to work fine, from 0.0 to 1.0.

I can confirm this bug on Firefox for Android. I am using a Lenovo Precision Pen 2 (MPP 2.0) on a Xiaomi Pad 6 android tablet.

In Firefox, they are wrongly detected; all pen taps are detected as "pointer (touch)" events.

In Chrome they are correctly detected; all pen taps are detected as "pointer (pen)" events.

This makes it so palm rejection does not work for any drawing or whiteboard apps, ruining one of the best features of having a pen. After taking some notes or drawings, there will be dots where the palm rejection should have worked if only "pointer (pen)" inputs were taken.

It is likely true that all styluses on all android tablets on firefox (including USI 2.0, MPP, etc.) also do not work with the correct input type.

TL;DR: Can confirm it still exists on Firefox as of 2024-01-25, 14:10 CET
For me on Firefox Developer Edition 123.0b2 on Ubuntu 22.04 LTS with KDE5.27+Wayland my Wacom Intuos is recognized as a pressure-sensitive mouse (my tablet doesn't support tilt, so I can't test for that) and in Ungoogled Chromium 120.0.6099.224 it is recognized as a pressure-sensitive pen.

Priority: P3 → P2

Exists for me as well, Firefox(Normal and Developer Edition) Version 124.0.1, on Debian 12, Plasma 5.27.5+X11. Same behaviour as described above, works fine in chromium based browsers such as Brave.

https://patrickhlauke.github.io/touch/pen-tracker/ → Doesn't work on Firefox

The reason is a condition ( e.pointerType == 'pen' ) && e.isPrimary: https://github.com/patrickhlauke/touch/blob/dd2f8f3c14a14b7889034af6bcbbafeb1b303abb/pen-tracker/index.html#L145

If I relax that condition to ignore the filter by pointer type, then it works fine. Well, almost fine, because now the code can't isolate pen events from mouse or touch events, so it triggers when it shouldn't. Firefox shouldn't report pen events as mouse.

Looks like there's a bug for it even with a patch - Bug 1501744.

See Also: → 1501744
Flags: needinfo?(stransky)

It doesn't on Debian and X11.

I use a minimal testing script:
document.body.onpointerdown = e => console.log(e);
and check relevant properties of the event, which remain the same for both mouse and pen, i.e.:

  • pointerId: 0
  • pointerType: mouse
  • pressure: 0.5
  • tiltX: 0
  • tiltY: 0

Chromium reports pointer ID 3 of type "pen" with proper pressure and tilt readings.

Pete, can you try again with MOZ_USE_XINPUT2=1 as an environment variable. For some reason, that variable is required to make Firefox detect the pen pressure.

Is there any downside of using that variable? Frankly I don't know (I've never looked at the Mozilla source-code), but I haven't seen any downside and I've been using it for a while. Should it become the default?

See Bug 1207700 for the MOZ_USE_XINPUT2 reference.

Flags: needinfo?(stransky)
See Also: → 1207700

I found a tablet so I can test it now. The build above works for me under Wayland or on X11 with MOZ_USE_XINPUT2=1.

Flags: needinfo?(stransky)

Using the build above with MOZ_USE_XINPUT2=1 I get correct pressure readings and pointerType (pen), but pointer ID is 0 (same as mouse) and there's no tilt input.

Status: UNCONFIRMED → RESOLVED
Closed: 9 days ago
Duplicate of bug: 1501744
Flags: needinfo?(stransky)
Resolution: --- → DUPLICATE
See Also: 1501744
You need to log in before you can comment on or make changes to this bug.