[Wayland] keyup event is never triggered on firefox running on wayland
Categories
(Core :: Widget: Gtk, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox149 | --- | fixed |
People
(Reporter: holger.hees, Assigned: sinker)
References
(Blocks 1 open bug)
Details
Attachments
(10 files, 1 external file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Steps to reproduce:
Running the following code
<html>
<body onkeyup="console.info('up1')" onkeydown="console.info('down1')">
<form>
<input type="text" onkeyup="console.info('up2')" onkeydown="console.info('down2')">
</form>
</body>
</html>
or
https://w3c.github.io/uievents/tools/key-event-viewer.html
I'm running this on opensuse 16 and firefox 146.0.1
Actual results:
If I type some characters inside the input box, I don't get any keyup events for normal text characters like 'abcde...' but I get these events for 'backspace' or other special characters.
if I force firefox running on x11 emulation by setting 'export MOZ_ENABLE_WAYLAND=0' then everything works as excpected
Expected results:
Everytime, I type a text character like 'abcde...' inside a text input box, it should trigger a keyup event.
Comment 1•10 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
| Reporter | ||
Comment 2•10 months ago
|
||
| Reporter | ||
Comment 3•10 months ago
|
||
| Reporter | ||
Comment 4•10 months ago
|
||
or to make the bug description a bit more understandable...
Steps to reproduce:
- open https://w3c.github.io/uievents/tools/key-event-viewer.html
- Type abcd' inside the text input box
Actual results:
- you just get the events
keydown,beforeinputandinput, but nokeyupevent - check screenshot 'keyevents_wrong.png'
Expected results:
- if you press e.g. backspace or other special characters, you get the events as they should be.
- you get
keydown,beforeinput,inputandkeyup - check screenshot 'keyevents_correct.png'
| Reporter | ||
Comment 5•10 months ago
|
||
I tested the same on an ubuntu system with wayland enabled. There, everything was working as expected.
Any ideas, how to further narrow down?
Comment 6•10 months ago
|
||
You can ty to run firefox on terminal with MOZ_LOG=KeyboardHandler:4,sync env variable and check how the keys are processed on both X11 and Wayland.
| Reporter | ||
Comment 7•10 months ago
|
||
sure and thanks for taking care :-)
it looks like that only non character keys are processed correctly.
| Reporter | ||
Comment 8•10 months ago
|
||
| Reporter | ||
Comment 9•10 months ago
|
||
| Reporter | ||
Comment 10•10 months ago
|
||
| Reporter | ||
Comment 11•10 months ago
|
||
| Reporter | ||
Comment 12•10 months ago
|
||
the only difference between wayland and x11 is that the x11 session is started with export MOZ_ENABLE_WAYLAND=0
Comment 13•10 months ago
|
||
Would be great if anyone can look at it, the related code is here:
https://searchfox.org/firefox-main/rev/93aad2a6615f670b1279c229dd37f7397236131a/widget/gtk/nsGtkKeyUtils.cpp#1460
Updated•10 months ago
|
Comment 14•10 months ago
|
||
What is your Wayland compositor, and do you use an input method? If so, try stop your input method and see if it works.
| Reporter | ||
Comment 15•10 months ago
|
||
I'm running latest kde and using the default wayland compositor from their.
To summarize, I'm running the following environment
opensuse leap 16
default wayland 1.2.0
updated to latest kde 6.5.5
running default kde wayland compositor
| Reporter | ||
Comment 16•10 months ago
|
||
I mean wayland-utils 1.2.0 and libwayland 1.24.0
| Assignee | ||
Comment 17•10 months ago
|
||
Is the log in comment #9 complete? It looks like missing earlier events. Could you do it again? Thanks!
| Assignee | ||
Updated•10 months ago
|
| Reporter | ||
Comment 18•10 months ago
|
||
| Reporter | ||
Comment 19•10 months ago
|
||
| Reporter | ||
Comment 20•10 months ago
|
||
sure.
the steps are
- the cursor enters the window
- click into the input field
- type 'abcde'
- type 'backspace'
- the cursor leaves the window
| Assignee | ||
Comment 21•10 months ago
•
|
||
According to the log, Firefox doesn't receive any key events for these keys ("abcd"). It suggests that is intercepted by IM running wayland IM protocol. In this case, IME consumes key events, and Firefox won't receive key events.
Could you run firefox with the following env var?
MOZ_LOG="IMEHandler:4,KeyboardHandler:4,sync"
| Assignee | ||
Updated•10 months ago
|
| Reporter | ||
Comment 22•10 months ago
|
||
| Assignee | ||
Comment 23•10 months ago
•
|
||
I've analyzed the issue and identified the potential root cause.
Potential Root Cause:
On Wayland with text-input protocol, printable characters arrive via commit_string in OnCommitCompositionNative() without any associated GDK key events. The existing code path only dispatches keydown and keypress events in this scenario - there's no keyup because there's no GDK_KEY_RELEASE event to trigger it.
This differs from X11 where key events go through the normal GDK key event path, which naturally provides both GDK_KEY_PRESS and GDK_KEY_RELEASE events.
Fix:
I've prepared a patch that:
- Detects when a simple character commit arrives via Wayland text-input protocol (when
mIsKeySnoopedis true andmProcessingKeyEventis null) - Synthesizes and dispatches
keydown,keypress, andkeyupevents for characters that have a valid DOM keyCode - Uses a new
KeymapWrapper::InitKeyEventFromCommitString()helper to properly initialize the key event - Refactors the existing dead-key handling code to share the dispatch logic
I'll submit the patch for review shortly.
Comment 24•10 months ago
|
||
via
commit_string
That's why I asked if the reporter is using an input method or not. And I'm now wondering which one is used, perhaps ibus?
FYI with fcitx5 on Wayfire, I do get keyup events on each key release, even when the keydown event goes to the input method and does not reach Firefox.
| Reporter | ||
Comment 25•10 months ago
|
||
I'm using a normal keyboard connected via usb as my input method.
| Assignee | ||
Comment 26•9 months ago
|
||
When characters arrive via Wayland text-input protocol's commit_string without
GDK key events, synthesize keydown/keypress/keyup events so web applications
receive proper key events.
Also refactors dead key handling to share the key event dispatch logic via a
new DispatchKeyEventsForCommittedCharacter() helper method, and adds
KeymapWrapper::InitKeyEventFromCommitString() to initialize key events from
committed characters without a native GDK key event.
| Reporter | ||
Comment 28•9 months ago
|
||
| Reporter | ||
Comment 29•9 months ago
|
||
it works! :-)
Updated•9 months ago
|
Comment 30•9 months ago
|
||
Comment 31•9 months ago
|
||
| bugherder | ||
Description
•