Open Bug 1098981 Opened 10 years ago Updated 2 years ago

[GTK] Firefox is missing characters in fast-typing applications

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

33 Branch
x86_64
Linux
defect

Tracking

()

UNCONFIRMED

People

(Reporter: coding, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: inputmethod, testcase, Whiteboard: tpi:+)

Attachments

(3 files)

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

Steps to reproduce:

I am using a barcode-reader with no inter-character delay. When I try to scan a barcode with a number of leading zeros Firefox often misses some zeros. If I scan into any other application (gedit, Chromium) this does not happen.

For testing supposes I wrote the following script using xdotool:
-------------------------
#!/bin/bash
sleep 5
for i in {1..30}
do
  SENTENCE1="0000000000"
  SENTENCE2="1234567890"

  xdotool type $SENTENCE1
  xdotool key "Return"

  xdotool type $SENTENCE2
  xdotool key "Return"
done
--------------------

In the initial 5-second-sleep I am placing the cursor to a simple HTML-Textarea, in this special case I used this one:
http://de.selfhtml.org/html/formulare/anzeige/textarea.htm


Actual results:

When the script has ended the following is displayed in the textarea:
-------------------------
000000000
1234567890
0000000000
1234567890
00000000
1234567890
00000000
1234567890
00000000
1234567890
0000000000
1234567890
0000000000
1234567890
00000000
1234567890
0000000000
1234567890
00000000
1234567890
000000000
1234567890
000000000
1234567890
00000000
1234567890
0000000000
1234567890
0000000
1234567890
000000000
1234567890
000000000
1234567890
0000000000
1234567890
00000000
1234567890
0000000000
1234567890
00000000
1234567890
0000000000
1234567890
000000000
1234567890
0000000000
1234567890
000000000
1234567890
00000000
1234567890
000000000
1234567890
00000000
1234567890
000000000
1234567890
000000000
1234567890
-----------------------


Expected results:

If I place the cursor in gedit, I get the following, expected Output:
-------------------
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
0000000000
1234567890
------------------------
Product: Firefox → Core
Karl, can you shed light on what's going on here or redirect to someone who can? :-)

(I'm wondering if this is related to the polling in bug 1097114 / bug 1077652)
Component: Untriaged → Widget: Gtk
Flags: needinfo?(karlt)
Keywords: testcase
I don't know what's happening here.  My best guess is that the key events generated by xdotool might all have the same timestamp, which might be leading to something (I don't know what) removing the intermediate KeyRelease events.  If that is happening, then Gecko's widget code will interpret the series of events as autorepeat, and skip events if Gecko cannot keep up.  However, the key events should have matching Press/Release pairs, and so this behavior is not expected.

Running a Nightly or debug build with NSPR_LOG_MODULES=WidgetFocus:5 in the environment would log enough to determine whether Gecko is getting all the release events.
Flags: needinfo?(karlt)
I don't know if it helps:

I am not able to reproduce this bug on an Android 4.4 platform.
I'm seeing the same behavior now in FF 43.0 with my YubiKey (usb one-time-password generator), but I recently upgraded Ubuntu from Feisty (very old) to Trusty.  It never happened in Feisty, even with FF 43.

However, in all other applications besides FF, no key presses are missed (tried Leafpad and LXTerminal and Midori browser).

Also, I notice that the YubiKey input comes out slow and jerky in FF, whereas in other applications, it comes out fast and smooth (one character at a time).  In FF, the characters show up as jerky clumps.

In Chromium, no characters are missed, but the fast input is jerky and appears in a few clumps instead of one character at a time.
Priority: -- → P4
Whiteboard: tpi:+
I'm seeing something very similar to Jason in Firefox 49.0 on Ubuntu 16.04: about half the time, Firefox misses at least one character (sometimes two or three) from my Yubikey input, leading to a frustrating experience because my login is rejected with "invalid two-factor code" (suggesting that there's something wrong with my Yubikey itself).

Like Jason, I haven't had any problems in Chromium.

As workaround, is there a different recommended mechanism for a device acting as a keyboard (which I believe is what the Yubikey does) to enter text into a field in Firefox more reliably?
For what it's worth, I've been able to work around this by using a password input instead of text--password does not seem to drop characters for some reason...

I have been experiencing this bug in Firefox 68.0.1+build1-0ubuntu0.18.04.1 .

We recently switched to an Integrated Library System (Koha) at my library that is a web app. I have experienced this behavior of dropping duplicate characters (I have seen this happen with barcodes that have multiple nines (99) and multiple zeros (000). This behavior exists across two different barcode scanners from two different manufacturers. I only get the scanning errors with Firefox. With gedit, libreoffice, or chromium, I do not get the error.

I'm including a link to a youtube video of the problem happening. There are two instances of Firefox dropping consecutive digits that are the same. The first scan if the ISBN of a book. When it fails, I immediately rescan getting the correct number and the search returns the desired results. The second set of scans if from the item's library barcode. Again, the second attempt is successful.

https://youtu.be/aG--09h2mcY

(In reply to RonH from comment #7)

I have been experiencing this bug in Firefox 68.0.1+build1-0ubuntu0.18.04.1 .

We recently switched to an Integrated Library System (Koha) at my library that is a web app. I have experienced this behavior of dropping duplicate characters (I have seen this happen with barcodes that have multiple nines (99) and multiple zeros (000). This behavior exists across two different barcode scanners from two different manufacturers. I only get the scanning errors with Firefox. With gedit, libreoffice, or chromium, I do not get the error.

I'm including a link to a youtube video of the problem happening. There are two instances of Firefox dropping consecutive digits that are the same. The first scan if the ISBN of a book. When it fails, I immediately rescan getting the correct number and the search returns the desired results. The second set of scans if from the item's library barcode. Again, the second attempt is successful.

https://youtu.be/aG--09h2mcY

Would you be able to use the steps from comment #2 to provide more debug info here? (see below)

(In reply to Karl Tomlinson (:karlt) from comment #2)

Running a Nightly or debug build with MOZ_LOG_MODULES=WidgetFocus:5 in the
environment would log enough to determine whether Gecko is getting all the
release events.

Flags: needinfo?(rhouk)

(In reply to :Gijs (he/him) from comment #8)

(In reply to RonH from comment #7)

I have been experiencing this bug in Firefox 68.0.1+build1-0ubuntu0.18.04.1 .

We recently switched to an Integrated Library System (Koha) at my library that is a web app. I have experienced this behavior of dropping duplicate characters (I have seen this happen with barcodes that have multiple nines (99) and multiple zeros (000). This behavior exists across two different barcode scanners from two different manufacturers. I only get the scanning errors with Firefox. With gedit, libreoffice, or chromium, I do not get the error.

I'm including a link to a youtube video of the problem happening. There are two instances of Firefox dropping consecutive digits that are the same. The first scan if the ISBN of a book. When it fails, I immediately rescan getting the correct number and the search returns the desired results. The second set of scans if from the item's library barcode. Again, the second attempt is successful.

https://youtu.be/aG--09h2mcY

Would you be able to use the steps from comment #2 to provide more debug info here? (see below)

(In reply to Karl Tomlinson (:karlt) from comment #2)

Running a Nightly or debug build with MOZ_LOG_MODULES=WidgetFocus:5 in the
environment would log enough to determine whether Gecko is getting all the
release events.

I would be happy to try this. I have downloaded a nightly, but I'm not entirely sure how to get the log file. In my terminal I've entered

"set NSPR_LOG_MODULES=WidgetFocus:5"

and then run firefox.

Could you provide some guidance on how I should do this? Thank you.

Flags: needinfo?(rhouk) → needinfo?(gijskruitbosch+bugs)

(In reply to RonH from comment #9)

I would be happy to try this. I have downloaded a nightly, but I'm not entirely sure how to get the log file. In my terminal I've entered

"set NSPR_LOG_MODULES=WidgetFocus:5"

and then run firefox.

You'd want to run firefox while the environment variable is set. You can do this from the commandline if you know the path to firefox, ie:

NSPR_LOG_MODULES=WidgetFocus:5 /some/path/to/firefox

in your terminal should work (just leave a space after the '5' and before the start of the path to firefox)

If that somehow doesn't work, you can also try just starting Firefox, and then:

  1. go to about:networking (you may need to click through the warning)
  2. go to the "Logging" section on the left
  3. In the "logging modules" field put "WidgetFocus:5" (without the quotes), and click 'set log modules'
  4. in the "current log file" field, put a path to a new file of your choice, click "set log file"

(Note: Firefox will generate more than one file based on the file path you specify, for parent/child processes, so it may be helpful to just create an empty directory to put the logfiles in, to make it easier to stick them all in an archive to attach here)

  1. check content is being written to the file(s) specified
  2. reproduce the issue.

Let me know if you get stuck on any of this.

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(rhouk)
Attached file Firefox nightly logs

Hello,

I am attaching the requested log files. I had to scan the barcode several times before the error occurred. Once the error occurred, I closed the browser. The error was the second "9" in the barcode 34199000915025 was dropped.

Please let me know if there is anything else I can help with.

Flags: needinfo?(rhouk) → needinfo?(gijskruitbosch+bugs)

Thanks! I'm not an expert in the relevant bits of Firefox - hopefully Karl or Martin can take a look and draw some conclusions from what's going on in https://bugzilla.mozilla.org/attachment.cgi?id=9086525 .

Flags: needinfo?(stransky)
Flags: needinfo?(karlt)
Flags: needinfo?(gijskruitbosch+bugs)

Two observations from the log:

One: There are many events logged that look consistent with a combination of two keys (e.g. Shift+x or similar):

[Parent 4982: Main Thread]: D/WidgetFocus OnKeyPressEvent [0x7f60c0de7400]
[Parent 4982: Main Thread]: D/WidgetFocus OnKeyPressEvent [0x7f60c0de7400]
[Parent 4982: Main Thread]: D/WidgetFocus OnKeyReleaseEvent [0x7f60c0de7400]
[Parent 4982: Main Thread]: D/WidgetFocus OnKeyReleaseEvent [0x7f60c0de7400]

Two: There are about 37 sequences each of about 40 OnKeyPressEvent without any intermediate OnKeyReleaseEvent.

That would be consistent with holding down a key for autorepeat, but it makes me wonder whether the barcode reader is not generating the KeyRelease events.

I would run xev to log what the barcode reader is producing.

Flags: needinfo?(karlt)

Hello Karl,

I am attaching another set of logs. Like last time and I had to do several scans before I got the error. The second 9 in the barcode 34199001755933 was dropped again (I've had other numbers in the past).

There is also an xinput log in the attachment as well recording info from the scanner. I used the command

input test-xi2 9 > xinput.log

to generate the log.

I wasn't sure what I was doing incorrectly with xev, I was able to attach it to my browsers window, but it didn't look like it was recording input from the scanner.

Flags: needinfo?(karlt)

I don't know what is happening, sorry.

The latest Firefox log looks very different from the last one. There are no obvious long autorepeat sequences, but there are some 4-key combinations. I can't explain why there are 2293 KeyRelease events for the 2288 KeyPress events.

The xinput.log seems to show that there are matching press/release pairs.

By default, Firefox behaves as if GDK_CORE_DEVICE_EVENTS=1 is in the environment. This can be reverted by putting MOZ_USE_XINPUT2=1 in the environment, to see whether that helps.

Flags: needinfo?(karlt)
Flags: needinfo?(stransky)
Priority: P4 → P3

I can confirm this. Been working with a barcode scanner today, took me a while to realize that it's only in Firefox where I'm loosing characters. I'm running 68.0.2+build1-0ubuntu0.18.04.1. First I tried:

  • Firefox and a web application with a little bit of (unobtrusive) JavaScript: I'm missing characters when scanning barcodes
  • tried with gedit and a Java-based IDE: no missing characters at all

Sample result when scanning the same barcode again and again:

6943_780_3118
6943478003118
6943478003118
69434780031_8
6943478003118
6943478003118
6943478003118
6943478003118
6943478003118
6943478003118
6943478003118
6943478003118
6943478003118
6943_78003118
6943478003118
6943478003118
6943_78003118
6943478003118
6943478003118
6943478003118
6943_78003118
6943478003118
69434780031_8
69434780031_8
6943478003118
6943478003118
6943_78003118
6943478003118
69434780031_8
69434780031_8

Didn't try other bar codes. As you can see, there is a double 0 (zero) and a double 1 in this code. Again and again I'm missing either one of those double-characters or the number 4 - which also exists twice, but with a different number in between.

For better readability I replaced the missing characters with underscores. Discovered this bug report, wrote a stupid little sample HTML page, no JavaScript, fresh Firefox instance, no other open tabs:

<html><body><form><textarea></textarea></form></body></html>

Same behavior, loosing characters. The same test with MOZ_USE_XINPUT2=1 works fine, experienced no issues when doing so.

Cheers,
Thomas

One more note: disabled all Add-ons, same behavior. And the effect is not limited to <textarea />, also my <input type="text" />-elements are missing characters.

Did another short test with xinput test. Got the following input in the text area...

694347800311
6943478003118

...while xinput showed the following:

key press   15 
key release 15 
key press   18 
key release 18 
key press   13 
key release 13 
key press   12 
key release 12 
key press   13 
key release 13 
key press   16 
key release 16 
key press   17 
key release 17 
key press   19 
key release 19 
key press   19 
key release 19 
key press   12 
key release 12 
key press   10 
key release 10 
key press   10 
key release 10 
key press   17 
key release 17 
key press   36 
key release 36 
key press   15 
key release 15 
key press   18 
key release 18 
key press   13 
key release 13 
key press   12 
key release 12 
key press   13 
key release 13 
key press   16 
key release 16 
key press   17 
key release 17 
key press   19 
key release 19 
key press   19 
key release 19 
key press   12 
key release 12 
key press   10 
key release 10 
key press   10 
key release 10 
key press   17 
key release 17 
key press   36 
key release 36 

That's the exact same sequence twice, with all press/release events in the right order - but Firefox misses a character during the first attempt. At least that's what it looks like to me.

Can you see whether this bug still reproduces with GTK_IM_MODULE=gtk-im-context-simple in the environment, please?

(In reply to Thomas from comment #16)

Same behavior, loosing characters. The same test with MOZ_USE_XINPUT2=1 works fine, experienced no issues when doing so.

If gedit is run with GDK_CORE_DEVICE_EVENTS=1 in the environment, does it reproduce?

(In reply to Karl Tomlinson (:karlt) from comment #19)

Can you see whether this bug still reproduces with GTK_IM_MODULE=gtk-im-context-simple in the environment, please?

It does not reproduce with GTK_IM_MODULE=gtk-im-context-simple

If gedit is run with GDK_CORE_DEVICE_EVENTS=1 in the environment, does it reproduce?

It does not, gedit with GDK_CORE_DEVICE_EVENTS=1 works fine.

Short summary:

  • NOK: firefox --safe-mode scan.html
  • OK: GTK_IM_MODULE=gtk-im-context-simple firefox --safe-mode scan.html
  • OK: MOZ_USE_XINPUT2=1 firefox --safe-mode scan.html
  • OK: gedit
  • OK: GDK_CORE_DEVICE_EVENTS=1 gedit

Thanks. It sounds like the IME is involved here, but somehow the interaction with the IME differs between gedit and Firefox.

Sounds like that we mark some key events of 0 as "repeated" and drop some repeated keys in content process to yield its main thread resource.

Do you reproduce it with URL bar or search bar? They are in the parent process so that any key events won't be dropped.

And also what keydown and keypress events are fined on the test suite when you input all 0 bar code? I guess repeat is checked and code values are same.

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900)(no pain of the broken bone, but the corset blocks me to concentrate) from comment #23)

Do you reproduce it with URL bar or search bar? They are in the parent process so that any key events won't be dropped.

I can reproduce it in the search bar, when generating the very same code multiple times (issues a search request every time) I'm easily able to see codes with missing numbers/characters.

And also what keydown and keypress events are fined on the test suite when you input all 0 bar code? I guess repeat is checked and code values are same.

Not really. Here some tests, all with --safe-mode:

Please let me know whether I should repeat the test with all zeros.

Hello,

I would also like to report that I have not been experiencing scanner errors since putting MOZ_USE_XINPUT2=1 in as an environment variable.

I've been experiencing the same thing. Firefox 68.0.1 on Gentoo. I actually bought a new keyboard for my laptop thinking the keys were starting to die. I also get some repeated characters from time to time which made me think it was the old problem I was having a few years ago that involved the kernel's priority for the keyboard. That's actually how I found this and realized this might well be the culprit.

(In reply to Thomas from comment #24)

Oh, I missed to check this result. According to this result, we handled some missing character inputs as IME composition (but failed of course since it's not actual composition).

Keywords: inputmethod

And it seems that we receive key events different order than the log in comment 18 because the key events whose key value is Process are handled in completely broken order (you can know which key causes the Process key events with the code value like Digit8).

Could somebody attach a log file of the main process? It can be logged with setting Current Log Modules: in about:networking to KeymapWrapperWidgets:5,nsGtkIMModuleWidgets:5,sync. But please be careful, the log file will contain any input from keyboard so that you shouldn't type anything your privacy like passwords (might be logged passwords if you input them with password manager).

Moving all open keyboard/IME handling bugs to DOM: UI Events & Focus Handling component.

Component: Widget: Gtk → DOM: UI Events & Focus Handling
Summary: Firefox is missing characters in fast-typing applications → [GTK] Firefox is missing characters in fast-typing applications
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: