New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard input gets jumbled when typing fast #2486
Comments
I will also add: I would tend to think that this has something to do with "stalling in the mainloop" or how busy the rest of the system is / what resources are available to ibus, because:
|
I'm happy to test possible solutions for this. I am experiencing this bug with my Lenovo Yoga 260 with i3 processor. |
I need to get time to evaluate this issue since it's a bit complicated. |
If some onlookers are able to read C code (I can't) and would like to check the "Could it be that it is using a stack (LIFO) queue somewhere instead of a FIFO?" hypothesis, maybe these can be areas to have a look at: (I'm just blind-guessing here... but it would be fun if it turned out to be simply something like that) |
I also thought GQueue of the key events but seems it does not help to fix this issue. This is the stack of nested _process_key_event() in another _process_key_event():
E.g. if a key press and release happens very quickly, g_main_context_iteration() in the "KeyPress" _process_key_event() can call another "KeyRelease" _process_key_event() instead of the callback of _process_key_event_reply_done(). So even if FIFO is used, the reverse order cannot be changed until g_main_context_dispatch() can call gdk_event_source_dispatch() besides g_idle_dispatch() for GDBusProxy. Replacing g_main_context_dispatch() with g_usleep() cannot call _process_key_event_reply_done(). The possible solutions are: I'm trying Regarding to |
I don't know if this additional "easy way to trigger the issue" is helpful at this point, but in case it is: I discovered today that one of the remaining affected applications is Epiphany. With version 44.1 on Intel graphics and Xorg (didn't test Wayland, but I think it would be less likely to exhibit the issue than on Xorg), if I go to GMail and try to write an email there by typing rapidly (more than 50-70 words per minute?), the email's text contents will be garbled; in fact, it's nearly impossible for me to type an email with it unless I force myself to type very slowly. |
I discussed it with Company on But as mentioned in the GTK issue, using |
As I noted, IBUS_ENABLE_SYNC_MODE=1 has a problem with D-Bus specification: Regarding to #2, currently it's impossible as the D-Bus specification: If an IBus engine calls ibus_enigne_commit_text() during waiting for the return of ibus_input_context_process_key_event(), the commit-text D-Bus signal cannot be reached before ibus_input_context_process_key_event() returns.
So my possible idea is: #1. Use g_main_context_push_thread_default() and g_main_context_pop_thread_default() and try to restrict g_main_context_dispatch(). I think If g_dbus_proxy_call() can call with a specific GMainContext and g_main_context_iteration() can wait for the callback of DBus methods only to avoid the nested main loops. My understanding is Mutter uses g_main_context_push_thread_default(). |
FYI Ubuntu 22.10 with GNOME 43 and ibus 1.5.27, jumbled characters: https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1996652 |
While the user types a search query, we restart our search engines for every key stroke. This is desirable for quick results. But unlike other engines, starting the simple engine multiple times in rapid succession can put some stress on system resources. Depending on the hardware and windowing system, this may result in user perception of poor performance and even aggravate race condition bugs, such as ibus/ibus#2486. Previously, we've dealt with this by setting the delay directly in the search entry. But that was a bad solution because it draged down the responsiveness of other search engines. So, save resources by starting the simple engine IO thread one second later, as long as it's not stopped/restated in the meantime.
While the user types a search query, we restart our search engines for every key stroke. This is desirable for quick results. But unlike other engines, starting the simple engine multiple times in rapid succession can put some stress on system resources. Depending on the hardware and windowing system, this may result in user perception of poor performance and even aggravate race condition bugs, such as ibus/ibus#2486. Previously, we've dealt with this by setting the delay directly in the search entry. But that was a bad solution because it draged down the responsiveness of other search engines. So, save resources by starting the simple engine IO thread one second later, as long as it's not stopped/restated in the meantime.
While the user types a search query, we restart our search engines for every key stroke. This is desirable for quick results. But unlike other engines, starting the simple engine multiple times in rapid succession can put some stress on system resources. Depending on the hardware and windowing system, this may result in user perception of poor performance and even aggravate race condition bugs, such as ibus/ibus#2486. Previously, we've dealt with this by setting the delay directly in the search entry. But that was a bad solution because it draged down the responsiveness of other search engines. So, save resources by starting the simple engine IO thread one second later, as long as it's not stopped/restated in the meantime. Bump glib minimum version to use "once" source helpers.
The synchronous "ProcessKeyEvent" D-Bus method cannot receive "CommitText" and "ForwardKeyEvent" D-Bus signals during calling the method. To resolve the issue, now ibus_input_context_set_post_process_key_event() and ibus_input_context_post_process_key_event() are added newly. ibus_input_context_post_process_key_event() retries "CommitText" and "ForwardKeyEvent" D-Bus signals during calling the "ProcessKeyEvent" D-Bus method and ibus-daemon does not handle those signals. BUG=ibus#2486
I created a tentative patch. If you could test it, it would be great. |
I applied #2532 and uploaded ibus to an Ubuntu PPA to make testing easier for Ubuntu users. |
So far one Ubuntu user has reported improved performance due to the patch. |
I applied the patch. I have two laptops that have been susceptible to this bug. I patched one of them. I then tried it, but it seemed it was still there. Then I rebooted that laptop and tried again, and have so far been unable to reproduce it in a certain fashion. I was typing as fast as I could to try and make the thing happen, and it did happen, but I think it was probably my fingers. :-) Even the unpatched laptop, however, seemed harder to make it happen, so I think other updates may have been masking the bug too. It still happens in a certain way on the unpatched laptop, but not as often as I remember it in the past. It was fairly painful in the past. Okay, I'm sorry! I have one laptop with an i5 processor and the other with the i3. Unfortunately, the I3 processor, now that it is upgraded to the patch still shows the behavior. Sorry for the mistake above. I'm sure about these results. You don't even have to type that fast to see it. |
@frohro Did you apply the patch to ibus/client/gtk4 ? The GTK4 files are symlink of GTK2. |
I went to the PPA that @gunnarhj made, added it, did sudo apt update, and sudo apt upgrade. Rob |
And I forgot that (of course). Have now uploaded corrections to the PPA (wait for the builds to finish and the packages to be published before updating). https://launchpad.net/~gunnarhj/+archive/ubuntu/ibus/+packages |
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-x11 too. Fixes: ibus@a73ea2c BUG=ibus#2486
Revised the patches; #2532 |
@fujiwarat: Thanks! The PPA has been updated with the latest versions of the two patches, and I can confirm that the x11 compose issue in gtk3 apps is no longer present. |
@fujiwarat I presume you mean this COPR? As I'm on Fedora 38, I'll really be looking forward to that so I can easily test on all my machines :) |
I delay to update the copr repo since I try to migrate the similar fix to ibus-wayland and refactor the codes for Plasma Wayland. |
The synchronous "ProcessKeyEvent" D-Bus method cannot receive "CommitText" and "ForwardKeyEvent" D-Bus signals during calling the method. To resolve the issue, now ibus_input_context_set_post_process_key_event() and ibus_input_context_post_process_key_event() are added newly. ibus_input_context_post_process_key_event() retries "CommitText" and "ForwardKeyEvent" D-Bus signals during calling the "ProcessKeyEvent" D-Bus method and ibus-daemon does not handle those signals. "Since: 1.5.00" is added in header files to available APIs before 1.5.29 is released. Will think later how to convert the version comments together when the new version 1.5.29 is committed. BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-x11 too. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
https://copr.fedorainfracloud.org/coprs/fujiwara/ibus/ provides ibus-1.5.28-13.1 for this issue. |
@nekohayo Did you have a chance to test my copr repository above? |
Sorry for the delay and thank you for your patience (and package!) @fujiwarat ; I was away from home for a few days, and it took me longer than I anticipated to get back to my computer. I wanted to test this specific computer because it is the most affected and reproduces the bug easily. I can confirm that the package from your COPR solves the issue compared to the mainline Fedora package. Awesome! So this version exhibits the bug:
...but this one doesn't:
My methodology to test this now was to use the Xorg/X11 GNOME 44 session (because this will happen much more easily there than under Wayland), launch the Epiphany web browser (version 44.5 from the Fedora repositories), Just to be sure, I then downgraded the package back to the standard Fedora version and the issue reappeared; re-upgraded to your COPR, and the issue vanished again. Thank you very much! |
Thank you all for your tests. |
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
The synchronous "ProcessKeyEvent" D-Bus method cannot receive "CommitText" and "ForwardKeyEvent" D-Bus signals during calling the method. To resolve the issue, now ibus_input_context_set_post_process_key_event() and ibus_input_context_post_process_key_event() are added newly. ibus_input_context_post_process_key_event() retries "CommitText" and "ForwardKeyEvent" D-Bus signals during calling the "ProcessKeyEvent" D-Bus method and ibus-daemon does not handle those signals. "Since: 1.5.00" is added in header files to available APIs before 1.5.29 is released. Will think later how to convert the version comments together when the new version 1.5.29 is committed. BUG=#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@3670faf BUG=ibus#2486
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-wayland too. Also fix to send the correct keycode to ibus-hangul. Fixes: ibus@38f09c6 BUG=ibus#2486
I was experiencing this in Debian Bookworm, and asked them to backport this patch. They did, but I still experience the bug on 1.5.29 in x11. gir1.2-ibus-1.0/stable-backports,now 1.5.29 Was this patch intended to completely fix the out of order letters, or make it less common? I do think it's about 30% improved from before, but it still happens quite a lot. Mainly I see it in nautilus, when I'm trying to search for a file by name in my (large) homedir. I start typing in a fresh nautilus window, and of course after the first letter probably half of the contents would match. so that search immediately runs up the cpu and memory, and as I add letters it narrows the search. It might be smart to not begin those searches unless there's at least 3 or 4 letters or the user hits enter. Slowness aside though, out of order input is an ibus problem isn't it? |
@BillyCroan: I see that some binary packages ( |
Yes. that seems to have fixed it. Thank you guys!!! Only my own typos futz up the input now. I can type full speed and there might be a delay before the letters appear, or the search actuates in nautilus. But when it does it's exactly what I typed. Works Great! Thank you @gunnarhj ! |
Environment
Which application and version?:
Pretty much any GTK4 application with a GtkEntry or GtkSearchEntry. The problem is reproducible using the
gtk4-demo-application
.Issue description:
Mostly what the title says... but please see https://gitlab.gnome.org/GNOME/gtk/-/issues/5347 for details, as it was partially investigated there with @jtojnar & @fujiwarat
Steps to reproduce:
Type fast in any GTK4 application's text entry widget, especially when the application is doing some live processing (ex: searching) as a result of your typing. You could use the
gtk4-demo-application
for testing this, but you may need to use faster typing speeds; see also the ticket linked above for some way to do this programmatically. Note that Nautilus will be much less affected than other apps, because I have implemented some performance mitigation in its GtkSearchEntry that makes the issue less likely to occur.Additional info:
Can you reproduce your problem when you restart ibus-daemon?: Yes (the problem is permanent)
Do you see any errors when you run ibus-daemon with the verbose option? (Run
ibus-daemon --xim --verbose &
and look at the output when you encounter your problem.)I'm not sure how to do that when the current session already has an ibus-daemon, without messing up my session?
Can you reproduce your problem with a new user account instead of the current your account?: I haven't been able to try/test that.
The text was updated successfully, but these errors were encountered: