wslg icon indicating copy to clipboard operation
wslg copied to clipboard

Keyboard lags and repeats keys on Linux GUI Apps under WSLg

Open tkonsta opened this issue 2 years ago • 12 comments

Windows build number:

10.0.22621.2428

Your Distribution version:

22.04

Your WSL versions:

WSL version: 2.0.7.0 Kernel version: 5.15.133.1-1 WSLg version: 1.0.59 MSRDC version: 1.2.4677 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25880.1000-230602-1350.main Windows version: 10.0.22621.2428

Steps to reproduce:

  1. Start a Linux GUI App inside of WSL (I first ran into the problem on IntelliJ, however I can reproduce it in gedit as well)
  2. Start typing something fast (if I type slow enough, then the problem doesn't appear)
  3. First some of the typed keys are just not showing up, and at some moment one arbitrary key is just repeated until I hit another key

WSL logs:

pulseaudio.log stderr.log weston.log

WSL dumps:

No response

Expected behavior:

No lagging keyboard and no repeated keystrokes

Actual behavior:

see "steps to reproduce"

Additional information

  • I experienced this problem first on a Ubuntu 22.04 distro, which I had in use for quite some time without the problem and all of a sudden this started to happen. Then I installed a fresh Ubuntu 23.10 distro thinking that maybe something within the installation is causing the problem, but the same thing happens again - in IntelliJ as well as in gedit.
  • The problem also occurred in WSL 1.x. So I did the update to the 2.x pre-release version with the hope that the problem might be gone in 2.x, but that's also not the case.
  • The same problem does not happen in all the programs running on windows. For example I use Visual Studio Code running on Windows, and using a project inside of WSL for coding and no problem at all.
  • I also experience on most of the WSL startups a problem in the weston.log which is discussed in https://github.com/microsoft/wslg/issues/972. However there seems no relation between the rdp_allocate_shared_memory problem discussed in the other issue and this problem here. Even if the rdp_allocate_shared_memory problem does not occur, this problem still exists. Maybe they have a common root cause, but one seems not to be leading to the other.

tkonsta avatar Nov 11 '23 14:11 tkonsta

Now I had one WSL session where this worked as expected and there were no lags and no repeated letters. After shutting down the notebook and restarting it - thus restarting WSL - the problem exists again.

So the pattern looks similar (but not same) as the mentioned Weston problem (Failed to open "/mnt/shared_memory/{02...d0c}"). Sometimes (i.e. most of the times) the problem occurs, but sometimes not. Maybe some kind of race condition between the WSLg System distro and the user distro?

tkonsta avatar Nov 22 '23 16:11 tkonsta

I have this problem too, quite annoying. Starting to border on unusable to daily drive

atl-mk avatar Jul 31 '24 21:07 atl-mk

I've found myself experiencing this on a new laptop which I just set up. After installing all the available OS updates, I still have the problem, and ended up at this WSL version:

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.4112

Meanwhile, an old laptop which has the same exact wsl --version output is working fine.

mentalisttraceur avatar Aug 30 '24 21:08 mentalisttraceur

One super interesting thing I noticed: after one reboot, I got the "[WARN:COPY MODE]" window title issue, and while that was happening, the key input lag+repeat went away!

Then I rebooted and the warn-copy-mode went away and the key-lag-and-repeat returned.

mentalisttraceur avatar Aug 30 '24 21:08 mentalisttraceur

Reproduction advice: for me, this bug most reliably happens if

  1. I tap the same key twice very quickly, and
  2. right after switching to a WSLg window from a normal Windows window.

mentalisttraceur avatar Aug 30 '24 21:08 mentalisttraceur

For anyone else losing essential daily driver functionality to this, within a day I was able migrate over to GWSL and be back to my normal productivity.

It's a nice open source wrapper and management GUI to automate/ease most of the setup with VcXsrv. Currently you'll need to use the workaround from https://github.com/opticos/gwsl-source/issues/184 , and I had to figure out my own command lines for shortcuts instead of being able to use its automatically-generated ones, but otherwise it Just Works and I'm now able to just move on.

mentalisttraceur avatar Aug 31 '24 21:08 mentalisttraceur

In the meantime I can 100% reproduce this problem by enabling Microsoft PowerToys with the tool "Quick Accent" enabled. As soon as I enable "Quick Accent", the lagging in several WSLg UIs starts. As soon as I disable the tool again, it stops.

First I thought this could be because of the global shortcuts the tool uses. However, enabling the tool "Text Extractor", which also has a global shortcut, doesn't cause the issues.

tkonsta avatar Sep 09 '24 14:09 tkonsta

In the meantime I can 100% reproduce this problem by enabling Microsoft PowerToys with the tool "Quick Accent" enabled. As soon as I enable "Quick Accent", the lagging in several WSLg UIs starts. As soon as I disable the tool again, it stops.

OMG, I think it's working for me too. I've disabled it and haven't had any issues since.

atl-mk avatar Sep 11 '24 17:09 atl-mk

It seems to have made it better, but I've just experienced the same symptoms with it disabled?

atl-mk avatar Sep 16 '24 08:09 atl-mk

In the meantime I can 100% reproduce this problem by enabling Microsoft PowerToys with the tool "Quick Accent" enabled. As soon as I enable "Quick Accent", the lagging in several WSLg UIs starts. As soon as I disable the tool again, it stops.

First I thought this could be because of the global shortcuts the tool uses. However, enabling the tool "Text Extractor", which also has a global shortcut, doesn't cause the issues.

This is it!(!!!!!!). Thanks, I've been chasing this for about 4 days now. I suspected powertoys - I had remapped some keys with it, and I then disabled it because I suspected it may be causing the snafu. BUT I had totally forgotten about Quick Accent. FWIW, it affects all the editors i tried (emacs, gvim, xed, gedit) but not the console - typing

"The quick brown fox jumps over the lazy dog"

outputs:

The quickkkkkkkkkkkbrownnnnnnnnnnnnnnnnnnnfox jumps over the lazyydog

It also randomòy swallows keystrokes, so after 'xset r off' I get:

the qucbrownfox jumps over the laz dog Disable "Quick accent", and it goes away.

MonsieurCellophane avatar Nov 13 '24 14:11 MonsieurCellophane

Yeah, that's pretty much the same behavior I'm experiencing as well, @MonsieurCellophane

Today I experienced similar behavior while being on a VPN connection and with PowerToys completely disabled. First I thought it might be related to high CPU load due to the VPN de-/encryption going on, but the CPU load actually was pretty low, so CPU load doesn't seem to be the problem.

In total it seems that this issue is not only related to PowerToys, but PowerToys seems to be one of the possible triggers.

tkonsta avatar Nov 13 '24 15:11 tkonsta

Tentative: seems this bug only happens with X apps, not Wayland apps. (It happens with emacs-lucid but not emacs-pgtk.)

mentalisttraceur avatar Oct 15 '25 09:10 mentalisttraceur