Desktop briefly becomes unresponsive when typing on 2 keyboards at the same time

Bug #1777708 reported by Mikkel Munch Mortensen on 2018-06-19
170
This bug affects 35 people
Affects Status Importance Assigned to Milestone
GNOME Shell
Unknown
Unknown
gnome-shell (Ubuntu)
Undecided
Unassigned

Bug Description

I'm running Ubuntu 18.04 and Gnome 3.28.1 with all the latest updates from the repos.

If I connect 2 (or more) keyboards to my computer and type on both at the same time, the desktop briefly becomes unresponsive. More keypresses increase the time of unresponsiveness.

E.g. when typing a full sentence in gedit or the terminal, only very few characters show up on the screen (I guess up until something is pressed on both keyboards at the same time), then everything freezes. Then after a while (some seconds), all the characters show up. And the desktop becomes responsive again.

Symptoms: During the freeze, windows stop updating their content. If seconds are enabled on the clock at the top middle, these freeze too. But I'm still able to move the mouse pointer around during the freeze without any problems.

The back story:

I got an ergonomic keyboard (R-Go Split Keyboard) yesterday, and quickly noticed the issue. But initiallly I thought it was an issue with the keyboard, and the problem wasn't that bad. But as I've gotten more used to the keyboard since yesterday and started picking up a proper typing speed, things got worse.

The keyboard is technically two separate cabled USB keyboards each with only about half of they keys of a normal keyboard (or at least that's very much my impression).

After getting the suspicion that this was a software issue, not a hardware issue, I tried typing on my old Logitech keyboard (Unifying Receiver) along with one of the R-Go halves: Same issue. Then I tried each of the halves without the other (as in "single" keyboard typing): No issue. Then I connected another Logitech keyboard (separate UR), typed on both Logitechs: Same issue.

Some further observations:

1) Nothing of significance in my syslog.
2) If I drop to a non-graphical shell, there's no problem. I suspect this issue is related to X.org or Gnome, but I'm in no position to say anything credible about that.
3) Also no problems when connecting the R-Go keyboard to a Windows or a MacOS machine.

Let me know if there are any logs I can provide or things I can run to produce useful debug output.

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1777708/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Mikkel Munch Mortensen (3xm) wrote :

> It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it

Sure! But I have no qualified guess.

I did some additional testing today, which may be helpful to others, but confused me a bit more:

I installed Plasma, and here the problem doesn't seem to be there. It feels like there's a slight delay when typing a lot of things at the same time, but it might just be Plasma's way of working. I haven't used it before, so I can't really say whether the slight delay is just how things work or is related to this issue.

But I also found out that I'm able to start a Wayland based Gnome session. Doing that, there's absolutely no problem with they keyboard. All multi-keyboard typing is shown instantly and no UI freeezing.

Based on this, I'm a bit confused about what package to file this bug against, as Plasma (as far as I know) runs on top of X, and Gnome works fine without X.

Pedro Palhares (pdimh) wrote :

I'm glad I found this, because it affects me too. I have the Same problem in gnome, but the problem is not present in plasma. I tried gnome with other OS and the bug didn't occur either.

It is very annoying and I could not find a workaround.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubuntu:
status: New → Confirmed
Pedro Palhares (pdimh) wrote :

This bug can be easily triggered by typing with two keyboards, Everytime you switch from one keyboard to the other, there is a lag. If you type fast enough you can even freeze the application. Other way to trigger this bug is to use xbindkeys with xautomation, everytime i try to simulate keyboard typing, the lag is there.

It happens with XOrg and Gnome, doesnt happen in wayland. The problem is i cant use wayland with NVidia driver.

Same happens to me.

Mikkel Munch Mortensen (3xm) wrote :

Now that other have marked themselves as affected, I'm trying to add a package, hoping that it will increase the chance that someone will look into it, although I'm not sure this is a Gnome bug (as mentioned earlier).

affects: ubuntu → meta-gnome3 (Ubuntu)
Pedro Palhares (pdimh) wrote :

After being annoyed by this bug for a long time, i started digging and found a workaround. Today i found that the bug is only present when i'm using certain keyboard layouts ("Portugues (Brasil)") and was not present when i changed the layout to EUA and language to English (need to set them both to English).

After some digging i found out the culprit is the ScrollLock key and that can be fixed by editing the layout file, which in my case is found at /usr/share/X11/xkb/symbols/br. The only modification i did was to remove or comment the line: modifier_map Mod3 { Scroll_Lock };
After that, set the language and layout back to Portugues (Brasil) and the problem was gone!

No more delays between typings.

PS: I tried this on Fedora, i will try this on ubuntu tomorrow.

Pedro Palhares (pdimh) wrote :

The only problem is the scroll lock key is no longer useful, but i dont use it, anyway.

PS: The keyboard layout which the bug is not present is US and not EUA like i said.

Mikkel Munch Mortensen (3xm) wrote :

Interesting findings, Pedro. How did you come up with that? What led you in this direction? Did you have a change to try this in Ubuntu yet?

However, this fix doesn't work for me. Switching from Danish layout to English does not get rid of the lag (I tried both US and UK English layouts; don't know if there's a difference).

Pedro Palhares (pdimh) wrote :

Did you set the language to English as well? I've tried in Ubuntu and it worked as well.

BUT I just found out that my solution may not solve your problem. Although it removes the lag between keypresses, if you type two keys at the same type (which happens when you type too fast), there is a small lag. In my case, i don't see any problem, because the secondary keyboard is for a very specific use.

Also, i looked at /usr/share/X11/xkb/symbols/dk file, and looks like the Scroll Lock isn't mapped there.

Mikkel Munch Mortensen (3xm) wrote :

>Did you set the language to English as well?

Yes, I always use the English interface, if that is what you mean.

> if you type two keys at the same type (which happens when you type too fast) (...)

So, if you're hammering away on the keyboards at the same time, do you still get the freeze, even with your fix? (Please, test it!)

> i looked at /usr/share/X11/xkb/symbols/dk file, and looks like the Scroll Lock isn't mapped there.

Right. It may inherit it from some of the other, more general layout files, though. But still:_ Switching to English layout didn't work for me either.

Pedro Palhares (pdimh) wrote :

> So, if you're hammering away on the keyboards at the same time, do you still get the freeze, even with your fix? (Please, test it!)

Yes, the fix i did solved the lag everytime i switched keyboards. The problem is a small lag still happen if i hit the two keyboards at the same time. As i only type on one keyboard at a time, it doesn't bother me, but it will prabably bother you.

Pedro Palhares (pdimh) wrote :

I realized if i set the layout "Portugues (Brasil)" without patching the file, the problem is even worse.

Dominik (misc-dominik-lindner) wrote :

I have exactly the same problem with an R-go split keyboard. Makes Ubuntu basically unusable unfortunately. Changing the keyboard layout doesn't help anything.

Mikkel Munch Mortensen (3xm) wrote :

> I have exactly the same problem with an R-go split keyboard

Great to see some confirmations!

For anyone skimming the comments, I'd like to emphasise that this is _not_ an R-Go specific issue. It can be reproduced by typing on any 2 connected keyboards at the same time. So it's a more general problem, which just happens to manifest itself for users of the R-Go keyboard(s).

Bobby Steed (ltlbsteed) wrote :

I too have issues with keyboard input lag on Ubuntu 18.04. I've made sure I'm current on all updates, I'm using the US layout and my language is set to English.

In my case I am using a KeyMouse Track (which the OS recognizes as two separate keyboards) but I have confirmed that it isn't related to the keyboard devices - two Logitech G810 keyboards plugged in simultaneously exhibit the same behavior.

As others have described, there is significant lag when pressing keys from two keyboards in an alternating fashion, and the faster you press the keys, the longer the delay before anything shows up on-screen once you stop typing. If only keys from one device are pressed, there is no discernible lag even if both keyboards are still plugged in.

Hopefully we can get some traction on this. I don't think Wayland is a viable option for me as I have an nVidia graphics card and I also have to use Skype for work... and I don't really want to switch to Plasma either.

Mikkel Munch Mortensen (3xm) wrote :

To anyone responding to this issue because it also affects them: Remember to click "This bug affects me" at the top of this page, to increase the likelihood that somebody will dig into the problem some day. Thanks! :)

Dominik (misc-dominik-lindner) wrote :

I don't think that will be addressed soon (or at all). Has anyone found a working workaround yet?

Mikkel Munch Mortensen (3xm) wrote :

Dominik, unfortunately not something that doesn't involve replacing Xorg or Gnome. Maybe it's been unintentionally fixed in 18.10, but I haven't had the time to try the beta.

Mikkel Munch Mortensen (3xm) wrote :

I just upgraded from 18.04 to 18.10, and the problem is still there for me.

Arun Nair (arungn) wrote :

I bought a Logitech K840 mechanical keyboard couple days back I noticed the lag in 18.04 and 18.10 if I press a lot of keys at the same time. And I've verified that it only happens in GNOME. I haven't tried it in Wayland though. I didn't notice this issue with my previous bluetooth keyboard.

Simon (simon-riezebos) wrote :

I have the same problem on 18.04. The trick mentioned above with removing scroll lock and changing input language seemed to make the delay smaller but still quite annoying. I am typing this in a Wayland session now and have 0 delay!

Same problem here. When I run htop while reproducing this bug, I can tell that shortly after the freeze, this command is using over 90 % CPU:

/usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3

Maybe this helps to find the cause for this bug:

When I run `xev -event keyboard` and press some keys, I see a KeyPress and a KeyRelease event for every key. When I press a key on another keyboard, I see a MappingNotify event first and then a KeyPress and a KeyRelease event:

KeyPress event, serial 28, synthetic NO, window 0x6800001,
    root 0x1a9, subw 0x0, time 1560057, (183,63), root:(1054,989),
    state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
    XLookupString gives 1 bytes: (20) " "
    XmbLookupString gives 1 bytes: (20) " "
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x6800001,
    root 0x1a9, subw 0x0, time 1560169, (183,63), root:(1054,989),
    state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
    XLookupString gives 1 bytes: (20) " "
    XFilterEvent returns: False

# now typing on another keyboard

MappingNotify event, serial 28, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 28, synthetic NO, window 0x6800001,
    root 0x1a9, subw 0x0, time 1562201, (183,63), root:(1054,989),
    state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
    XLookupString gives 1 bytes: (20) " "
    XmbLookupString gives 1 bytes: (20) " "
    XFilterEvent returns: False

KeyRelease event, serial 29, synthetic NO, window 0x6800001,
    root 0x1a9, subw 0x0, time 1562329, (183,63), root:(1054,989),
    state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
    XLookupString gives 1 bytes: (20) " "
    XFilterEvent returns: False

Maybe this MappingNotify event triggers something in Gnome that needs a second of processor time.

Jairo Rotava (jairorotava) wrote :

I have the same issue, but when using 1 keyboard and the xdotool. I use xdotool to input keypress like XF86AudioPlay, and others multimedia keys. This only happen when using the gnome. In wayland there is no such issue. The real keyboard does not have the multimedia keys. The system became shortly unresponsive everytime I switch from the real keyboard to the xdotool media keys, and vice versa.

This issue looks similar to this issue in Debian:
https://gitlab.gnome.org/GNOME/gnome-shell/issues/856

and I understand is has already been fixed with this patch, although I don't know how to use it :
https://gitlab.gnome.org/GNOME/mutter/merge_requests/579

Dmitra (intelliart) wrote :

I've bought a KeyMouse split keyboard and cannot use it because of this delay. Their support is aware of this issue but do not want to help fixing. https://www.keymouse.com/forum/large-lag-between-keystroke-and-response

If it is fixed in Gnome mutter, does it mean it will be available in Ubuntu 19.10?
Or is it possible to update just mutter on Ubuntu 18.04?

Thanks.

Rory Bradford (roryrjb) wrote :

This issue is not fixed in Ubuntu 19.10 (at least as of today). To reiterate this issue isn't present in Wayland, only Xorg. Also this issue was present for me in Kubuntu 19.10, but not in Ubuntu Mate or Xubuntu 19.10.

Rory Bradford (roryrjb) wrote :

Actually this issue *is* affecting Ubuntu Mate 19.10, it's just not as noticeable but definitely there.

Darrar Radgrioer (darrar) wrote :

This issue was fixed in Ubuntu 19.10. I switched from 18.04 to Eoan on 2th September and the bug was gone. Unfortunately one month later, somewhere around the beginning of October I upgraded my 19.10 system and the bug was present again. Awesome! :D

Since I am a newboy to Linux I dont know ho to roll back this upgrade and as far as I got it, its not that easy to downgrade gnome while wont touching the other packages. When somebody knows how to do this, pls go ahead.

Hubert Polonski (tobybdk) wrote :

I know nothing about Linux/Ubuntu and how it works, but I'm also having this issue, with a R-Go split keyboard. I find it very cool that one can use 'xev -event keyboard` to get an idea of what's happening behind the curtain. And it made me research. According to this link: https://tronche.com/gui/x/xlib/events/window-state-change/mapping.html --- the MappingKeyboard appears, when the keyboard mapping was changed.. Which, without knowing anything about how this works, leads me to believe that something, somewhere, either believes the keyboards to be of two different mappings, or something is forcing them to be of two different mappings.

Maybe, if one manually sets the mapping of both keyboards, to be exactly the same? I tried 'xinput -list | grep key' together with 'setxkbmap -device [number] -layout [layout]' to try and force the dansh layout on both keyboarsd, but without avail. Any ideas?

Darrar Radgrioer (darrar) wrote :

One guy (Wiggy boy <Lindholm> Wiggy boy <Lindholm>) found a fix:

from:

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1858

I'm trying out some stuff on Ubuntu 19.10 right now actually.
If you wanna help me or guide me I'd be more than happy to receive your help.
Send me an email REMOVED .
EDIT:
I think I've got this working actually. So I thought it'd be writing down in case someone else comes around wanting to duplicate it (perhaps those over at the Ubuntu Bug Report Forums). Be aware though, I JUST have it working now and have no idea if something will break later down the line. I bricked my Ubuntu installation twice trying to get it to work.
So I'm running Ubuntu 19.10 now, for this to work any older version will not work (at least not with this method).
So currently 19.10 is running gnome-shell 3.34.1 and we'll need to downgrade to 3.34.0 as this includes the fix, before it was reverted. Unfortunately the compiled packages have been removed so we'll have to download and install them manually and figure out the dependencies so things don't break.
Luckily however, Launchpad has some built packages, so we'll need to download for mutter:

gir1.2-mutter-5_3.34.0-3ubuntu1_amd64.deb
libmutter-5-0_3.34.0-3ubuntu1_amd64.deb
mutter-common_3.34.0-3ubuntu1_all.deb
mutter_3.34.0-3ubuntu1_amd64.deb

and for gnome-shell:

gnome-shell-common_3.34.0-1ubuntu1_all.deb
gnome-shell_3.34.0-1ubuntu1_amd64.deb

If the direct links doesn't work, here's where I found all the dpkg files, or if you're not running amd64 architecture, you should also be able to find alternatives:

mutter-3.34.0-3ubuntu1
gnome-shell-3.34.0-1ubuntu1

So, once you've got all the files you need. Open the terminal and the following command to exit the desktop enviroment (I don't know if this is needed but why not?):
sudo init 3
Then install each and everyone of your dpkg files with sudo dpkg -i /path/to/deb/file like so:
sudo dpkg -i gir1.2-mutter-5_3.34.0-3ubuntu1_amd64.deb
sudo dpkg -i libmutter-5-0_3.34.0-3ubuntu1_amd64.deb
sudo dpkg -i mutter-common_3.34.0-3ubuntu1_all.deb
sudo dpkg -i mutter_3.34.0-3ubuntu1_amd64.deb
sudo dpkg -i gnome-shell-common_3.34.0-1ubuntu1_all.deb
sudo dpkg -i gnome-shell_3.34.0-1ubuntu1_amd64.deb
Do not worry if it complains or warns about missing dependencies or breaking dependencies. This is because you have a newer version installed, and we're replacing them one by one.
Once finished, we start the desktop environment again with:
sudo init 5
Finally, we wanna let APT know not to update these packages, because that would undo everything. We do that by running following:
sudo apt-mark hold gir1.2-mutter-5
sudo apt-mark hold libmutter-5-0
sudo apt-mark hold mutter-common
sudo apt-mark hold mutter
sudo apt-mark hold gnome-shell-common
sudo apt-mark hold gnome-shell
Now you're done!
Once everything has been fixed and maybe you do want to upgrade all your versions, just run the previous commands but substitute hold with unhold. That should tell APT that it's okay to upgrade those packages again.

Darrar Radgrioer (darrar) wrote :

works also without the init command

Please use this Wiki-report at https://askubuntu.com/a/1195394/439867 with more details and evidences abiut this bug. Please more attention here, it affects many testimony and thousands of pageviews in the report's page.

I've the same issue in 19.10. Since I use Portuguese Brazil layout, I was able to circumvent this problem using the Pedro Palhares (Post #8) suggestion.

Diego (diego-giglio) wrote :

I'm having the same problem in Ubuntu 20.04 in XPS L502x.
I frequently use my laptop pluged in a external keyboard and mouse (logitech K270)

Thank you.

This problem also affects me. I used the method of downgrading and it really worked. However, I don't know what I'm gonna miss out because of that downgrade.

I also discovered a problem that only exists using a splitted keyboard: For logging in to Ubuntu, the shift keys don't work.

Dmitra (intelliart) wrote :

I've created a $50 bounty: https://www.bountysource.com/issues/91397439
Please, support and spread the word for those who can help to fix this issue.

Robert Price (o-r9bert-5) wrote :

In addition to the two-keyboards thing, I'm also experiencing this problem using the Sidewinder X4 keyboard when holding more than 6 simultaneous keys. According to xev, this keyboard also sends MappingNotify events when it gets to that point.

Osvald Lindholm (wiggy-boy) wrote :

For anyone looking for some closure, I doubt you'll see a fix for this anytime soon. So the best I can offer to you all is a little hack/fix you can do yourself. You can find it in the upstream bug over at gitlab.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1858#note_818548

Best of luck to you all!

Fede (fedecuci) wrote :

I just bought the R GO Split keyboard and experiencing the same issue on Ubuntu 20.04. Very unfortunate that it hasn't been solved yet.

omendez (mmoa33) wrote :

I have a Drevo BM87, running on Ubuntu 20.04, and the problem prevails.... I hope the issue can be fixed soon, because otherwise it renders the external keyboards pretty much useless.

Fede (fedecuci) wrote :

Is there another way to report this bug since it was opened quite long ago?

The #33 advice works on "19.10" but not on "20.04" bringing the system into "oh, no"-state.

Darrar Radgrioer (darrar) wrote :

I am using 20.04 & used this Workaround to fix it. Input lag is gone.

Had Found this because [https://github.com/federico-terzi/espanso/] severely froze my desktop when expanding text snippets.
Disabling Scroll lock did solve it.

Using Pop!_OS 20.04 LTS.

ToniO (mt801) wrote :

I'm using Ubuntu 20.04, and fixed this issue with the workaround by Wiggy boy <Lindholm> (Thanks!):
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1858#note_818548
(and I also had to enable the "Source code" source as explained here: https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list/857433#857433)

This bug was a bummer to find after switching to Gnome/Ubuntu (from Xfce, a bit older version though) mostly because of the feelingly lower input lag in the mouse. So having also gaming in mind, it was a bummer to find out that the keyboard and the extra buttons on the mouse don't work reasonably anymore without freezing with 100 % CPU :/

If the only drawback of this workaround affects keyboards other than qwerty, please at least have a configurable option in settings to disable other than qwerties and have a functional keyboard?

Cristiano Nunes (cfgnunes) wrote :

I use Ubuntu 20.04 and I have the same problem.

A similar bug I reported here:
https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1895486

After some use, I noticed a delay when using keyboard media controls (for example: increase volume audio).

The first time I push these key Gnome hangs for a short time before display the action on the screen.

(This problem is still happening in Ubuntu 18.04 too. Even worse some times, the system crashes when using media keys.)

For some reason, my Gnome freezes when using Fn keys, or when I try to use two keyboards. A friend of mine pointed to me that it occurs when switching to a keyboard layout that has Scroll Lock enabled, so I disabled it in the X11 keyboard layout file for my language, and it solved the problem.

A workaround to solve the problem is:

1) Opened the keyboard layout file for my language, in my case:

sudo nano /usr/share/X11/xkb/symbols/br

2) Commented the line:

modifier_map Mod3 { Scroll_Lock };

3) Logged out and logged in again or run command setxkbmap.

These steps are specific for the Brazilian Portuguese ABNT2 Layout and may not work for other layouts, but it can help you find a similar solution.

affects: meta-gnome3 (Ubuntu) → gnome-shell (Ubuntu)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers