30

I recently switched to Ubuntu 18.04 and since then I have a lot of keyboard input lag, sometimes multiple seconds. I can type the words but it takes some time until they show on the screen.

I previously used Ubuntu 16.04 without any issues.

This error occurs in Terminal but also in my web browser.

Any idea where I could start debugging this problem?

What I figured out is that this also may trigger by some keys more than others. For example when I'm typing cdcdcdcd it appears a lot.

Also it may be important to know that I use a different keyboard layout which I set with this command:

setxkbmap de neo  # (german neo layout) (so cd is rl on asdf)

Although this doesn't make a difference for the lag.

Apparently this issue is only happening on the GNOME/budgie desktop.

  • 1
    I had a similar experience with USB keyboard. Switching back to Unity helped. If that is an option, there is a guide linuxconfig.org/… – logcat May 14 '18 at 19:01
  • I have to say im really not a big fan of unity :( – jrsm May 16 '18 at 19:31
  • 1
    I think I have the same issue. Some observations: 1) If I drop to a non-graphical shell, there's no problem. 2) In Gnome: It's not just the keyboard input that's freezing, but most of the UI. I've enabled seconds in my clock and they also freeze for a while after multiple keypresses. But the mouse pointer is still moving around if I move the mouse. 3) This is not an issue with all keyboards. My old Logitech keyboard with the Unifying Receiver works fine. 4) The affected keyboard works fine with Windows and MacOS on other computers. 5) Nothing of significance in my syslog. – decibyte Jun 19 '18 at 14:25
  • 2
    Okay, a few more observations: If I connect 2 Logitech keyboards and type on them at the same time, I experience the same issue. This might sound like an unusual use case, but my usual keyboard is an ergonomic R-Go Split Keyboard -- an abnormality which is technically two separate keyboards (each with only half they keys of a normal keyboard). A combination of one half and a Logitech keyboard gives the same result. Along with my above observations: Does that give anyone any idea about what's going on? Especially with that fact that it only occurs (for me) in Gnome(3). – decibyte Jun 19 '18 at 14:47
  • 1
    I don't know if you also happen to be in a dual keyboard typing situation like me. But for the record, I've opened a bug with my own observations: bugs.launchpad.net/ubuntu/+bug/1777708 – decibyte Jun 19 '18 at 18:57

10 Answers 10

9

Maybe you could try your system log. I have noticed the following error on my system (multiple times):

xhci_hcd 0000:3a:00.0: xHCI host controller not responding, assume dead

This seems to be a USB3 problem. My keyboard and touch-pad on my laptop do not have this problem. My USB connected mouse also lags.

When I load Ubuntu 18.04 with the previous and still available kernel on my system as used in 17.10, kernel version 4.13.0-39-generic, I do not get the XHCI errors. Also, my keyboard and mouse do not lag anymore.

I am able to select this kernel via the GRUB menu in my setup.

Remark I have not figured it out completely yet. The older kernel appears to work better but the lag is there every now and again. I can make some remarks when using the default kernel: A continuous key press (just holding a letter or character) is doing fine. It just outputs the letter or character constantly without jitter. Also, just entering letters are fine. Where I think it is going wrong with my setup are special characters like (Commas, periods, colons, semicolons, etc.). As soon as those are introduced to the input it stars going wrong. Initially I thought this might be caused by dead keys but switching those off do not make a difference. Can you confirm this behavior? Also, slow keys do not solve it on my setup.

Update This morning I got an update which seems to solve the keyboard problem on my site. From my update log: Commandline:

$ aptdaemon role='role-commit-packages' sender=':1.147'
Upgrade: intel-microcode:amd64 (3.20180312.0~ubuntu18.04.13.20180425.1~ubuntu0.18.04.1)

This is the only update for 18.04 I got so far. This probably also solved the slow boot times on my Laptop. It's now seconds in stead of a minute. I will send a confirmation later this week.

| improve this answer | |
  • xhci loos good on my sys log hower I get often something like 1 18:19:54 ryzen gnome-software[2177]: json_object_has_member: assertion 'member_name != NULL' failed May 1 18:19:54 ryzen gnome-software[2177]: g_strsplit: assertion 'string != NULL' failed May 1 18:19:54 ryzen gnome-software[2177]: g_strv_length: assertion 'str_array != NULL' failed May 1 18:19:54 ryzen gnome-software[2177]: json_object_has_member: assertion 'member_name != NULL' failed May 1 18:19:54 ryzen gnome-software[2177]: g_strsplit: assertion 'string != NULL' failed – jrsm May 1 '18 at 16:24
  • I have not figured it out completely yet. The older kernel appears to work better but the lag is there every now and again. I can make some remarks: – André Klaver May 3 '18 at 8:47
  • I'd be curious to know more about this issue you had. Did you ever file a bug report? If this is a real bug, it's going to affect a lot of people, as more and more users are moving to 18.04 & also more and more machines are using USB 3.0 – Hee Jin May 4 '18 at 18:02
7

This may be the slow keys feature

It is toggled on and off by holding down the shift key for 8 seconds

Press the shift key for 8 seconds and see if the problem goes away

| improve this answer | |
  • 1
    Might be good to note that in order for this feature to be toggled on/off using the shift key, the user has to first change their system settings to enable the shortcut. See Ubuntu Help: Turn On Slow Keys – Hee Jin May 1 '18 at 16:37
  • Except that it appears to be enabled by default :/ I never enabled it and this solved my problem – Jim Anthony May 1 '18 at 16:51
  • Oh weird! It wasn't enabled by default on my system, but actually I was going to phrase my comment to include for the fact that it's possible that it might be for some users, because it totally seemed possible to me. Anyway hopefully this fixes it for the question-asker! – Hee Jin May 1 '18 at 22:36
  • This does nothing at all. – Luís de Sousa Aug 21 '18 at 15:25
  • 3
    After debugging deeper into this issue I can verify that the laggy keyboard input is not caused by slowkeys! I have disabled and validated slowkeys behavior in Ubuntu 18.04.1 and I have seen the lag issue when this has been disabled. When I enable slowkeys, it takes a long time to type a letter, and the delay is constant. When the laggy keys issue is happening, the delay is variable and sometimes a character becomes repeated many times because I've been trying to press a couple times without it registering in a timely manner. – TrinitronX Dec 8 '18 at 3:44
3

It isn't the keyboard. It isn't the window compositor. The problem with lagging is the sequence of events that occur within the gui controls of any given program. one thing they all have in common besides keyboard input and displayed text is accessibility options like orca screen reader that cause the gui to have to do more work between screen updates. it's just like with 3d video rendering where too many computations drop your frame rate down until it behaves like a series of stills with no continuity.

kill the calculations and you you kill the lag.

I stopped my lag problem by killing the orca process and then going to [start-up programs]. once there, I removed orca from the start-up list along with other programs that I didn't want at start-up. I also unchecked the box to stop remembering running programs at shut-down.

no more lag on keyboard input, even in Firefox

| improve this answer | |
2

I had the same issue with my favorite keyboard. All my other keyboards where working fine.

I solved the problem by switching to wayland.

You can do this with the gear button next to the sign in button at the login screen.

| improve this answer | |
1

I had this happen on my main laptop computer when playing Terraria, when playing on my "new desktop" with such amazing parts as ddr2 ram and a dual core e8600 and USB 2.0, I had no latency, I could not even see any input lag when comparing a low end wireless keyboard to a ps2 mechanical keyboard. A computer restart and plugging it in helped. For me I think it was because the system's battery was low and it wasn't plugged in.

| improve this answer | |
  • I'm seeing the issue on a desktop HTPC system with Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz that has 8 cores! It also has a RAID6 with 5 disks, with 8GiB of RAM (DIMM DDR4 Synchronous 2133 MHz (0.5 ns)). So the issue is definitely not related to hardware! It seems more likely that it is software related based on my experience. – TrinitronX Dec 8 '18 at 3:51
1

I have had similar problems using a wireless Logitech Keyboar & Mouse, with a unified receiver. I have a stationary PC, and have tried a number of things to address that:

  1. Updated the firmware to latest Logitech version using fwupdmgr. I thought it had helped but apparently not lasting effect.

  2. I created a new udev rule in a new file /etc/udev/rules.d/10-logitech-receiver.rules with the following contents:

=======

# Unified USB receiver

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d",
ATTR{idProduct}=="c52b", ATTR{product}=="USB Receiver", TEST=="power/control", ATTR{power/control}:="on"

=======

This rule ensures that the receiver power is always on. Maybe it is not necessary on a stationary PC, but it can't hurt. I thought it had helped, but doubtful if it had a lasting effect. It may be helpful on a laptop, at the expense of power usage.

  1. Interference with other devices

I noticed that when I had an USB key in a neighbouring usb slot or some other USB device nearby, lagging increased. I moved the other UDB devices to the backplane, and put the reciver on a USB extension cord placed on the front of the PC and placed it about a meter away from the PC. This was clearly the best solution so far - at least for my wireless Logitech setup. It may also be related to how many devices that are connected on each USB bus, so voltage may drop and hurt reception. I also noticed that it worked far better in USB 3.x slots than in USB 2.x ditto.

After moving it away from potentially interfering devices it is now stable, with the keyboard at a distance of approx. 3 m. from the dongle :-)

| improve this answer | |
0

If you're playing games or of the gaming sort, the communication app Discord was grabbing too much of my video card and causing hiccups. Try disabling "Hardware Acceleration" in it's setting. Did wonders for me. No more keyboard lag in games or while typing.

Apparently it's a little buggy. From the horses mouth: https://twitter.com/discordapp/status/924910040552747008?lang=en

Other's having the issue: https://www.reddit.com/r/PUBATTLEGROUNDS/comments/6ibgj3/psa_turn_off_hardware_acceleration_in_discord/

| improve this answer | |
0

I have had feature Slow Keys on, the feature which puts a delay between when a key is pressed and when it is accepted. Its behave looks exactly as you describe above.

To deactivate Slow Keys open Settings, choose Universal Access, then choose Typing Assist (AccessX) and turn it off.

| improve this answer | |
0

For short: In 99% You need go to Settings->Universal Access and switch to Off / Default all items except Repeat Keys.

| improve this answer | |
-1

((PLEASE EDIT HERE, IT IS A WIKI! BUT IT'S NOT AN ANSWER, IS A 2019 BIG-PICTURE))

REVIEWING THE MANY HYPOTHESIS:

Would this lag be a side effect of a Trojan scanning our keyboards?

It seems that it is not, but a double check is necessary: please report here any evidence (and procedures to check the evidence) on the Trojan hypothesis.

Evidence that is not an "external Trojan": the lag problem persist in the USB-Live and in fresh UBUNTU 18 installations — before to install any "external of the ISO" application.

PS: "internal" is introduced by release 18 ISO distribution... so, we can consider a bug, not a virus.

Would this lag caused by feature "Slow Keys"

It is another problem! It is a good first hypothesis, easy to test and discard.

NOTE: this page recives thousands pageviews, so, if you was looking for "Slow Keys", see this good (4 votes) answer and solution (or see this other page discussion).

Would this lag be a hardware lag problem?

No, see @TrinitronX comments demonstrating that it is not. All types of hardwares offer the same lag experience, it is not a "lag by hardware low performance".

Would this lag be a USB-driver problem?

Yes, a USB-keyboard problem, a bug or a conflict on the software of device-driver... But something that occurs mainly with old machines and/or old devices, when ported from UBUNTU v16 LTS to v18 LTS, beucause the lag not exist on v16 neither on modern devices.

Evidences: please check all comments and answers (and edit here listing it), they all talk about different USB devices.


CONCLUSION ABOUT OUR MAIN PROBLEM AND ITS CORRECT HYPOTHESIS:

THIS problem is the lag caused by change to some USB keyboards

This 2019 review of the question is about the USB keyboard's driver bug and its manifestation as a lag.

After ~1.5 years this question is stable and offers a general testimony about keyboard input lag: that it is a 1 second to 3 seconds lag, in general starting a section or change USB device (to non-USB). In all applications (e.g. terminal, Gedit, browser, somethimes login). It is a real bug in the UBUNTU 18 distribution.

How to detect/confirm that my problem is THIS problem?

Monitoring changes in the syslog during lag occurences by

  • tail -f /var/log/syslog: open it in a terminal-window and in other window test to edit by USB keyboard and by original (onboard) keyboard. Collect evidences and compare here with the reported ones.

  • grep -i controller /var/log/syslog must to show typical "ohci_hcd: USB" lines in your collected evidences.

  • grep -i ETC /var/log/syslog you can use other words (e.g. "unhandled") instead "ETC" to check collected evidences.


OTHER USEFUL INFORMATION FOR ANSWERS AND DISCUSSIONS

Study cases, complete profile (system and hardware) where THIS lag problem occured.

CASE 1. It is a fresh UBUNTU 18 LTS, the machine is working fine with Ubuntu 16 LTS (in another partition), it is an old Samsung with Intel i3 core, SSD disk and RAM used as this free -m command:

              total        used        free      shared  buff/cache   available
Mem:           3741        1466        1278         260         995        1794
Swap:          2047           0        2047

Monitoring changes in the syslog during lag occurences, main changes and other evidence:

tail -f /var/log/syslog.

... /usr/lib/gdm3/gdm-x-session[1324]: (II) config/udev: Adding input device DELL Dell USB Entry Keyboard (/dev/input/event11)
... /usr/lib/gdm3/gdm-x-session[1324]: (**) DELL Dell USB Entry Keyboard: Applying InputClass "libinput keyboard catchall"
... /usr/lib/gdm3/gdm-x-session[1324]: (II) Using input driver 'libinput' for 'DELL Dell USB Entry Keyboard'
... /usr/lib/gdm3/gdm-x-session[1324]: (II) systemd-logind: got fd for /dev/input/event11 13:75 fd 47 paused 0
... /usr/lib/gdm3/gdm-x-session[1324]: (**) DELL Dell USB Entry Keyboard: always reports core events
... /usr/lib/gdm3/gdm-x-session[1324]: (**) Option "Device" "/dev/input/event11"
... /usr/lib/gdm3/gdm-x-session[1324]: (II) event11 - DELL Dell USB Entry Keyboard: is tagged by udev as: Keyboard
... /usr/lib/gdm3/gdm-x-session[1324]: (II) event11 - DELL Dell USB Entry Keyboard: device removed
... /usr/lib/gdm3/gdm-x-session[1324]: (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/0003:413C:2107.0002/input/input13/event11"

In this kind of experiments the main greps are:

grep -i HCI /var/log/syslog
... kernel: [ 3770.983036] usb 2-1.1: new low-speed USB device number 5 using ehci-pci
... kernel: [ 7084.642797] usb 2-1.1: new high-speed USB device number 6 using ehci-pci
... kernel: [    1.141461] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
... kernel: [    1.141471] ehci-pci: EHCI PCI platform driver
... kernel: [    1.141981] ehci-pci 0000:00:1a.0: EHCI Host Controller
... kernel: [    1.142001] ehci-pci 0000:00:1a.0: new USB bus registered, assigned bus number 1
... kernel: [    1.142025] ehci-pci 0000:00:1a.0: debug port 2
... kernel: [    1.146059] ehci-pci 0000:00:1a.0: cache line size of 64 is not supported
... kernel: [    1.146091] ehci-pci 0000:00:1a.0: irq 16, io mem 0xfc806000
... kernel: [    1.158091] ehci-pci 0000:00:1a.0: USB 2.0 started, EHCI 1.00
... kernel: [    1.158232] usb usb1: Product: EHCI Host Controller
... kernel: [    1.159065] ehci-pci 0000:00:1d.0: EHCI Host Controller
... kernel: [    1.163101] ehci-pci 0000:00:1d.0: cache line size of 64 is not supported
... kernel: [    1.178159] usb usb2: Manufacturer: Linux 5.0.0-37-generic ehci_hcd
... kernel: [    1.178720] ehci-platform: EHCI generic platform driver
... kernel: [    1.178738] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
... kernel: [    1.178743] ohci-pci: OHCI PCI platform driver
... kernel: [    1.178757] ohci-platform: OHCI generic platform driver
... kernel: [    1.178768] uhci_hcd: USB Universal Host Controller Interface driver
... kernel: [    1.467492] ahci 0000:00:1f.2: version 3.0
... kernel: [    1.468810] scsi host0: ahci
... kernel: [    1.502080] usb 1-1: new high-speed USB device number 2 using ehci-pci
... kernel: [  477.859695] usb 2-1.2: new low-speed USB device number 5 using ehci-pci

grep -i controller /var/log/syslog
... kernel: [    0.270587] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
... kernel: [    1.120115] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4
... kernel: [    1.141461] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
... kernel: [    1.141981] ehci-pci 0000:00:1a.0: EHCI Host Controller
... kernel: [    1.158232] usb usb1: Product: EHCI Host Controller
... kernel: [    1.159065] ehci-pci 0000:00:1d.0: EHCI Host Controller
... kernel: [    1.178157] usb usb2: Product: EHCI Host Controller
...

grep -i controller /var/log/syslog
... kernel: [    0.270587] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
... kernel: [    1.120115] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4
... kernel: [    1.141461] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
... kernel: [    1.141981] ehci-pci 0000:00:1a.0: EHCI Host Controller
... kernel: [    1.158232] usb usb1: Product: EHCI Host Controller
... kernel: [    1.178738] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
... kernel: [    1.178768] uhci_hcd: USB Universal Host Controller Interface driver

Not the answer you're looking for? Browse other questions tagged or ask your own question.