Closed Bug 1811303 Opened 1 year ago Closed 1 year ago

Pen on graphical tablet not works correct in the new pdf-tool

Categories

(Firefox :: PDF Viewer, defect, P3)

Firefox 109
defect

Tracking

()

VERIFIED FIXED
113 Branch
Tracking Status
firefox109 --- wontfix
firefox110 --- wontfix
firefox111 --- wontfix
firefox112 --- verified
firefox113 --- verified

People

(Reporter: Hartmut.Mehnert, Assigned: calixte)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0

Steps to reproduce:

Enter a signature in a PDF document using a graphics tablet and the associated pen.

Actual results:

Unfortunately, my pen does not work properly with the graphics tablet when writing. If i writing, the document moves vertically and horizontally on the screen when the scrollbars are visible. Because of this, I can't write the way I want. This problem does not occur with the mouse and the left button pressed, the document does not move while writing.
In other programs and also PDF tools, I can draw and write perfectly with my tablet and the associated pen.
My tablet: Medion P82018 (MD86635)
My system: win 10 pro x64 22H2 19045.2486 with latest updates

Expected results:

The document must not move while writing with the pen.

The Bugbug bot thinks this bug should belong to the 'Firefox::PDF Viewer' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → PDF Viewer

Hy, thank you for the bug report!
I managed to reproduce this issue on Windows 10 x64 on:

  • Firefox 109.0;
  • Firefox 110.0b5;
  • Nightly 111.0a1;

Scrollbar interferes with the Draw function whilst using a tablet. I used a XP PEN Artist 12. Could not reproduce on Ubuntu. Could not test on macOS due to the incompatibility of the tablet with the device.
Setting as NEW so that the developers can have a look.
For more details, please see this recording.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Pen on grafical tablet not works correct in the new pdf-tool → Pen on graphical tablet not works correct in the new pdf-tool

The severity field is not set for this bug.
:calixte, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(cdenizet)
Severity: -- → S3
Flags: needinfo?(cdenizet)
Priority: -- → P3

I got a XP-PEN G640S V2 and I managed to reproduce the issue under Windows 11 and Windows 10.
It works as expected on mac 13.1 and on Fedora.
My feeling is that event propagation is not stopped and then the pointer event finally triggers a scroll.
The code we use to draw is:
https://github.com/mozilla/pdf.js/blob/master/src/display/editor/ink.js#L535-L563

:botond, could you have a look on this issue, please ?

Flags: needinfo?(botond)

stopPropagation() will prevent other JS listeners (e.g. on ancestor elemens) from processing the event, but default browser behaviours will still happen. If the pen is producing touch events, the scrolling might be occurring as the default behaviour of the touch events.

Does calling preventDefault() in addition to stopPropagation() help?

Flags: needinfo?(botond) → needinfo?(cdenizet)

It doesn't change anything.
It works correctly on Windows 11 when drawing on a touch screen.
Initially, I developed the pointer stuff in testing with a touch screen and I had to add:
https://github.com/mozilla/pdf.js/blob/534b22aec5eaa88d796a17b9732d82f3fcd25b3a/web/annotation_editor_layer_builder.css#L164
in order to something working correctly.
I just tested on the touch screen in removing the touch-action: none and there is scrolling then I added some preventDefault and the scrolling is still there. So the only way to prevent scrolling on the touch screen is to have touch-action: none.
As far as I know there are no pen-action in css.

I tested in Chrome with a pen (with a local server for serving pdf.js) and it works correctly. But if I remove touch-action: none from the css it doesn't anymore even with preventDefault.

Flags: needinfo?(cdenizet)

(In reply to Calixte Denizet (:calixte) from comment #6)

I just tested on the touch screen in removing the touch-action: none and there is scrolling then I added some preventDefault and the scrolling is still there. So the only way to prevent scrolling on the touch screen is to have touch-action: none.

I realized what the reason for this might be: event listeners need to be passive: false in order for preventDefault() to be respected.

But that can't be the whole story here: touch-action: none is considered to be a better way than a passive: false event listener that calls preventDefault(), for preventing scrolling caused by touch events. The fact that the canvas already uses touch-action: none, and yet you are seeing scrolling, suggests that the pen is triggering something other than touch events.

Kagami, are you familiar with how pen input works? In particular, do you know what kind of events it generates at the platform level (i.e. Widget***Event), and by what mechanism it causes scrolling?

Flags: needinfo?(krosylight)

Does setting dom.w3c_touch_events.enabled=1 fix your issue? If then it's bug 1755435.

Flags: needinfo?(krosylight)

Yes, it does fix the issue.

Thanks for the confirmation. The solution should be what's described in https://bugzilla.mozilla.org/show_bug.cgi?id=1755435#c11, but for now I have no such non-touch-but-only-pen Windows environment. It'll be very helpful if anyone with such device can take it, but if not I'll try at some point.

Depends on: 1755435

I just tested with this patch:

diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -1477,7 +1477,8 @@ nsresult WinUtils::WriteBitmap(nsIFile*
 uint32_t WinUtils::IsTouchDeviceSupportPresent() {
   int32_t touchCapabilities = ::GetSystemMetrics(SM_DIGITIZER);
   return (touchCapabilities & NID_READY) &&
-         (touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH));
+         (touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH |
+                               NID_EXTERNAL_PEN | NID_INTEGRATED_PEN));
 }

and it works as expected.

Assignee: nobody → cdenizet
Status: NEW → ASSIGNED

:saschanaz, I used this bug rather than bug 1755435, because if the patch fixes the issue described here, then it doesn't for the other one.

Pushed by cdenizet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fb3194cfa194
Make a pen usable to draw on a pdf on Windows r=saschanaz
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit auto_nag documentation.

The patch landed in nightly and beta is affected.
:calixte, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox112 to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(cdenizet)

From a pdf.js point of view I'd be in favor of uplifting the patch in beta.
:saschanaz, what do you think ?

Flags: needinfo?(cdenizet) → needinfo?(krosylight)

I'm all for it 👍

Flags: needinfo?(krosylight)

Comment on attachment 9324653 [details]
Bug 1811303 - Make a pen usable to draw on a pdf on Windows r=saschanaz

Beta/Release Uplift Approval Request

  • User impact if declined: Windows users won't be able to draw on a pdf in using a pen.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: See https://bugzilla.mozilla.org/show_bug.cgi?id=1811303#c0
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Small change and limited to users using a pen.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9324653 - Flags: approval-mozilla-beta?
Flags: qe-verify+

Windows users won't be able to draw on a pdf in using a pen.

(Only if their devices have no touchscreen, e.g. when using a digitizer tablet on a plain laptop. Touch-enabled devices are fine without it.)

Comment on attachment 9324653 [details]
Bug 1811303 - Make a pen usable to draw on a pdf on Windows r=saschanaz

Approved for 112.0b7

Attachment #9324653 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

Reproducible on a 2023-03-20 Nightly build on Windows 10 using XP-PEN Artist 12 graphical tablet.
Verified as fixed on Firefox 102.0b7(build ID: 20230326180212) and Nightly 113.0a1(build ID: 20230326214700) on Windows 10 and Windows 11.
Drawing with a pen and tablet using the 'Draw' function works properly now.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Regressions: 1834055
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: