Bug 498280 - Compositor latency causes input lag
Summary: Compositor latency causes input lag
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: input (other bugs)
Version First Reported In: 6.2.3
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-05 14:23 UTC by jackyzy823
Modified: 2025-06-02 15:32 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
redacted-journal-log.txt (343.48 KB, text/plain)
2025-01-05 14:23 UTC, jackyzy823
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jackyzy823 2025-01-05 14:23:59 UTC
Created attachment 177126 [details]
redacted-journal-log.txt

SUMMARY
I'm not sure what happened. But suddenly the mouse / touchpad 's move speed is far slower than normal. The keyboard's input speed is slow too.
However the audio output is at normal speed.  The CPU/Memory usage is normal in the System Monitor.

I tried to unplug and plug the receiver of the mouse. it doesn't help
I tried `kwin_wayland --replace` and it doesn't help.
I tried `systemctl restart sddm` and then re-login . it doesn't help.

Only reboot solves the problem.

This is the second time i encountered this issue.

OBSERVED RESULT
Random laggy

EXPECTED RESULT
No random laggy

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  Fedora 40
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION

The log around the time when laggy happens , shows 
```
Jan 05 21:21:53 MACHINE_NAME kwin_wayland[1932]: kwin_libinput: Libinput: event14 - PNP0C50:00 0911:5288 Touchpad: kernel bug: Touch jump detected and discarded.
                                           See https://wayland.freedesktop.org/libinput/doc/1.26.2/touchpad-jumping-cursors.html for details

Jan 05 21:23:52 MACHINE_NAME kwin_wayland[1932]: kwin_libinput: Libinput: client bug: timer event14 keyboard: scheduled expiry is in the past (-70ms), your system is too slow
Jan 05 21:24:07 MACHINE_NAME kwin_wayland_wrapper[2032]: Key repeat discarded, Wayland compositor doesn't seem to be processing events fast enough!
```

I guess this might be related to libinput.
Comment 1 Nate Graham 2025-01-06 19:15:27 UTC
You're right, it is a Libinput issue. Generally when this happens, it's because Libinput enabled pointer hysteresis because it detected that the hardware wasn't providing great enough precision, which can also sometimes happen if the system is under load.

IMO this is a terrible mis-feature and 100% of the time when it's triggered for me across four laptops, it's made the situation worse than it would have been without it.

You can open a bug report about this at https://gitlab.freedesktop.org/libinput/libinput/-/issues
Comment 2 jackyzy823 2025-01-12 09:43:38 UTC
Update: I opened a ticket on https://gitlab.freedesktop.org/libinput/libinput/-/issues/1074 when i encounter the problem the third time.

and they said it is "not our bug" .

> so the delay here is caused by the compositor, presumably because it's busy rendering things.


I don't know what to do know.  :(
Comment 3 jackyzy823 2025-02-02 08:29:27 UTC
Some updates:  due to 6.12+ kernels bug on glitching display, i revert to kernel 6.8.9 and the other KDE/plamsa components remain the newest. and seems that the input lag didn't happen again ( at least for two weeks) . So maybe we should blame on kernel ?
Comment 4 jackyzy823 2025-02-18 16:27:21 UTC
Some updates:

I encountered this again with 6.12.11-100.fc40.x86_64.
in the log i found `Feb 19 00:12:42 code01 kernel: amdgpu 0000:62:00.0: [drm] *ERROR* dc_dmub_srv_log_diagnostic_data: DMCUB error - collecting diagnostic data` 

So i tried to restart amdgpu module (with the method in https://unix.stackexchange.com/a/553834) `sudo cat /sys/kernel/debug/dri/<GPU_ID>/amdgpu_gpu_recover` , and the system recovered , the lag disappeared.
Comment 5 Rolf Schröder 2025-02-20 10:30:16 UTC
I believe I have the same issue. I am running the following system:

```
Operating System: NixOS 24.11
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.1
Kernel Version: 6.6.76 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 PRO 8840U w/ Radeon 780M Graphics
Memory: 61.5 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: LENOVO
Product Name: 21MCCTO1WW
System Version: ThinkPad T14 Gen 5
```

The machine is completely new so I initially thought this was a hardware problem. I check Windows 11, tty1 as well as Ubuntu Live (24.04, X11) and none of the them could reproduce the lag. Since it works fine on tt1 (i.e. I do not feel any lag while typing), I presume it's KDE/Wayland related and no hardware issue.
Comment 6 Rolf Schröder 2025-02-20 10:59:59 UTC
I could not find any obvious (error) messages related to amdgpu but `sudo cat /sys/kernel/debug/dri/<GPU_ID>/amdgpu_gpu_recover` seems to have helped here, too. I have GPU_ID 1 and 128 (i.e. two subfolders in .../dri) and only `cat` the first one. After a couple of minutes of playing around with the system, my impression is that get lag is gone.

Thanks a lot!
Comment 7 Rolf Schröder 2025-03-07 04:04:32 UTC
As a short update here: I currently have an alias `recover-amdgpu` (`sudo cat /sys/kernel/debug/dri/1/amdgpu_gpu_recover'`)  which I only use when necessary. Because: At work, I connect the machine (Thinkpad T14) to a docking station (which has an external monitor connected to it) - here, I *never* experience the issue. When working without the docking station (i.e. "mobile"), I *always* have the problem. It manifests already during login (i.e. typing the password lags).

The alias has work always except for a single time. Upon invocation, the screen turns black, comes back again and KDE reports a little information about "desktop effects" (not always). The one time it did not work, the screen turned off/on several times until eventually the command prompt appeared again. However, the lag did not go away. The only thing I did differently here was to activate the Night Light. I rebooted and `recover-amdgpu`'ed and it worked again (Night Light was then already enabled since I had activated in just before).
Comment 8 Rolf Schröder 2025-04-28 03:27:39 UTC
For me, the problem is now gone. I am currently running

Operating System: NixOS 24.11
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.2
Kernel Version: 6.6.85 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 PRO 8840U w/ Radeon 780M Graphics
Memory: 61.5 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: LENOVO
Product Name: 21MCCTO1WW
System Version: ThinkPad T14 Gen 5

I believe the problem only ever occurred with Night Light enabled (in the past).
Comment 9 Zamundaaa 2025-06-02 15:32:02 UTC
ok, cool