You are not logged in.

#1 2024-12-03 03:08:17

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Laptop keyboard lag when not charging

Hi, I have a very annoying problem with my in-built Dell XPS 13 laptop keyboard in my Arch Install.

It seems to be rate-limited to about 2 key-presses per second whenever the laptop is not plugged in and charging.
This is very annoying as I have be careful to slow my typing a lot to avoid typos and missed letters.

When I run `libinput debug-events`, it seems to capture all of my keypresses at any speed, so it seems the keypresses are being correctly polled but not all being passed on to my terminal or other applications.

The problem disappears if I use a USB keyboard, however sometimes I can't take my USB keyboard with me.
Again, it also disappears if the laptop is plugged in with an appropriate charger.

Any idea how to debug / fix this?

Last edited by SpaceDog (2024-12-23 00:18:43)

Offline

#2 2024-12-03 05:21:48

seth
Member
Registered: 2012-09-03
Posts: 60,756

Re: Laptop keyboard lag when not charging

The cause is most likely some power management daeamon adjusting something™ depending on the power supply.
Also what's the context of the symptoms? Console? X11? Wayland? (which compositor?)
Also, how's the overall CPU load when this happens?

Since libinput registers all keys it's probably not just a visual thing where the screen doesn't get properly updated.

Offline

#3 2024-12-03 06:46:11

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

Thanks for your fast reply!
I'll try my best to answer these questions.

The situation happens whether I'm typing in the terminal, or in a terminal program like neovim, or in my internet browser and anywhere else.

I... don't know about the console.  How do I check that?
I'm running X, with dwm as my window manager and st as my terminal emulator, and zsh as my shell.
My compositor is xcompmgr.

CPU usage for zsh gets up to 20% after a while of mashing keys on the laptop keyboard.  My USB keyboard, which works properly, can get it even higher - up to 40%.  I have a bunch of other processes running (htop, firefox, R, nvim) but if I just sit back the total CPU usage of my computer is around 5-10% most of the time.

Offline

#4 2024-12-03 06:54:51

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,684
Website

Re: Laptop keyboard lag when not charging

Does killing the compositor help?

Use <Ctrl>+<Alt>+F6 to get to a console for testing.


Para todos todo, para nosotros nada

Offline

#5 2024-12-03 07:41:02

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

Head_on_a_Stick wrote:

Does killing the compositor help?

Use <Ctrl>+<Alt>+F6 to get to a console for testing.

Nope, doesn't help.

Also I think I just accidentally reported this post and didn't realize because I thought I was writing a reply.  I'll try to work out how to withdraw that report!
Edit: I can't figure it out.  I guess the admins will notice there's nothing objectionable and cancel the report.  Sorry!

Last edited by SpaceDog (2024-12-03 07:43:49)

Offline

#6 2024-12-03 08:47:17

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

seth wrote:

Since libinput registers all keys it's probably not just a visual thing where the screen doesn't get properly updated.

I missed this, yes it's definitely not a visual thing.

Here's me typing the same sentence quickly with the USB keyboard vs the inbuilt keyboard:

USB keyboard:     Hello, how are you doing today?
Inbuilt keyboard: elo, ow re ou i oa?
I'll try again:         Hl, ho ar oudoin tday?

Offline

#7 2024-12-03 14:55:05

seth
Member
Registered: 2012-09-03
Posts: 60,756

Re: Laptop keyboard lag when not charging

I'm running X, with dwm as my window manager and st as my terminal emulator, and zsh as my shell.
My compositor is xcompmgr.

Run "xev | tee /tmp/xev.log" type "archlinux", press ctrl+c and post the xev.log (try to not touch keyboard or touchpad during this)
Also please post your Xorg log, see https://wiki.archlinux.org/title/Xorg#General on where to find it
W/ dwm, you're probably starting this w/ startx/xinit?
Please also post your xinitrc

Nope, doesn't help.

Does that include the behavior on the linux console?

Offline

#8 2024-12-04 03:51:25

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

Yes, when I pressed ctrl-alt-F6 and went to the console, my laptop keyboard was still laggy as hell in the console.  I also tried turning off my compositor with `killall xcompmgr` and there was no improvement.

Here's my files

Xev,log:

http://0x0.st/X7QQ.txt

Xorg.0.log:

http://0x0.st/X7Q1.txt

.config/x11/xinitrc:

http://0x0.st/X7Qe.sh

.config/x11/xprofile:

http://0x0.st/X7Q2.sh

Offline

#9 2024-12-04 03:53:51

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

By the way, that 0x0.st site is pretty cool.

Offline

#10 2024-12-04 06:03:18

seth
Member
Registered: 2012-09-03
Posts: 60,756

Re: Laptop keyboard lag when not charging

KeyPress event, serial 33, synthetic NO, window 0x3000001,
    root 0x4d5, subw 0x0, time 53931442, (1522,376), root:(1555,410),
    state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XmbLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x3000001,
    root 0x4d5, subw 0x0, time 53931647, (1522,376), root:(1555,410),
    state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyPress event, serial 33, synthetic NO, window 0x3000001,
    root 0x4d5, subw 0x0, time 53931894, (1522,376), root:(1555,410),
    state 0x10, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (63) "c"
    XmbLookupString gives 1 bytes: (63) "c"
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x3000001,
    root 0x4d5, subw 0x0, time 53932003, (1522,376), root:(1555,410),
    state 0x10, keycode 54 (keysym 0x63, c), same_screen YES,
    XLookupString gives 1 bytes: (63) "c"
    XFilterEvent returns: False

Nope, there're no events between those two (focus, substructure), indicating that the input simply goes elsewhere.
But w/ the console report, X11 and your session are off the hook anyway.

That being said:

dbus-update-activation-environment --all
dbus-launch ssh-agent dwm

Don't.
See the last link below, 2nd blue note on what to include at least. Don't use dbus-launch, you're breaking integration w/ the session bus.

That being said and assuming this isn't the cause for your laptop keyboard struggles: do you get the same when removing the logitech dongle (and also don't attach the mouse via bluetooth)?

Offline

#11 2024-12-04 08:17:40

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

Yep, same behaviour when I don't have any peripherals connected.
The only thing that changes this is plugging in the computer.

I had thought maybe there's something in the Dell BIOS doing this but I ran Linux Mint last year and didn't notice this problem then.

Offline

#12 2024-12-04 08:26:25

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

Uh oh, I commented out those 2 lines from my xinitrc, and added the last if block like the blue note from the "Fix your xinitrc" link said, and rebooted, and now I can't login.

Last edited by SpaceDog (2024-12-04 08:42:50)

Offline

#13 2024-12-04 08:27:40

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

https://i.imgur.com/uBMxhYe.jpeg

I'm using the console to reverse those changes

Last edited by SpaceDog (2024-12-04 08:29:50)

Offline

#14 2024-12-04 08:37:42

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

So one of these lines is necessary for me to start X11:
dbus-update-activation-environment --all
dbus-launch ssh-agent dwm

Offline

#15 2024-12-04 09:16:44

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,841

Re: Laptop keyboard lag when not charging

did you remove the line entirely? If you want dwm to start you need to start it, but don't dbus-launch it

ssh-agent dwm

Last edited by V1del (2024-12-04 09:17:53)

Offline

#16 2024-12-04 12:39:38

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

V1del wrote:

did you remove the line entirely? If you want dwm to start you need to start it, but don't dbus-launch it

ssh-agent dwm

Thanks, that works.  Yes I removed it entirely before.  I'm learning!

Offline

#17 2024-12-04 15:03:02

seth
Member
Registered: 2012-09-03
Posts: 60,756

Re: Laptop keyboard lag when not charging

The most obvious thing to happen is that the notebook downclocks on battery, https://wiki.archlinux.org/title/CPU_fr … _governors
Check governor and scaling_cur_freq's

The two problems with that theory are
1. only the internal keyboard is affected
2. not on the libinput level
3. even on powersaving your system should outperform your fingers…

Do you get the same behavior w/ a fresh user account?
Or with the LTS kernel?

Offline

#18 2024-12-05 01:28:30

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

I just tried libinput again and it does seem to miss some keys, so maybe I was wrong in the op.

Offline

#19 2024-12-05 01:42:10

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

I have tried starting Arch with "Arch advanced options - Arch linux-lts" and the problem is still there.
Also it's still there on a newly created user account.

Another clue: I just noticed that when I plug the computer in, and the keyboard is working well, and then I unplug it, it keeps working well for a while.  I don't know what the exact trigger is for the keyboard to start getting laggy but it's not immediate when I unplug it.

Last edited by SpaceDog (2024-12-05 01:43:16)

Offline

#20 2024-12-05 02:25:20

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

So, the keyboard is still working well and it's been unplugged for about 40 minutes.  I've been back to the computer once or twice in that time.  So I'm thinking that it's a problem triggered either by the keyboard going to "sleep" after not being used for a long time, or with the battery level dropping below a certain threshold (it's at 94% at the moment) and being unplugged.

Offline

#21 2024-12-05 02:29:13

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

I've been watching my CPU frequencies with
`watch cat /sys/devices/cpu/cpu[0-9]*/cpufreq/scaling_cur_freq/`
and they've mostly been around 400000 (the minimum) up to 1.5 million.  They're mostly tending towards 400000 and 800000.  The maximum is 4 million.
And they were more or less the same whether the computer was plugged in or not - I tested it before plugging my computer in while the keyboard was still laggy.

Offline

#22 2024-12-05 02:30:17

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

cat /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave

(keyboard is working well.)
I'll test it again later when the keyboard is lagging.

Last edited by SpaceDog (2024-12-05 02:32:17)

Offline

#23 2024-12-05 04:44:39

seth
Member
Registered: 2012-09-03
Posts: 60,756

Re: Laptop keyboard lag when not charging

Please don't bump, edit your previous post to mend it.

wrt libinput, see whether you can out-type evtest
wrt the trigger, please provide the system journal of a boot once it starts lagging again,

sudo journalctl -b | curl -F 'file=@-' 0x0.st

Offline

#24 2024-12-08 07:44:30

SpaceDog
Member
Registered: 2024-12-03
Posts: 23

Re: Laptop keyboard lag when not charging

Ok, the last time I posted here, I unplugged my computer and the keyboard kept working well as I ran the battery down to 2% before plugging it back in again.

I have booted it today while unplugged and the problem is back.   Here is the boot log:
http://0x0.st/Xh8N.txt

Offline

#25 2024-12-08 08:01:24

seth
Member
Registered: 2012-09-03
Posts: 60,756

Re: Laptop keyboard lag when not charging

Dec 08 11:25:19 SpaceDog kernel: i8042: Warning: Keylock active

Try to add " i8042.reset i8042.unlock=1" to the https://wiki.archlinux.org/title/Kernel_parameters

Offline

Board footer

Powered by FluxBB