microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.26k stars 310 forks source link

Keyboard lags and repeats keys on Linux GUI Apps under WSLg #1140

Open tkonsta opened 1 year ago

tkonsta commented 1 year ago

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

tkonsta commented 1 year ago

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?

atl-mk commented 4 months ago

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

mentalisttraceur commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

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.

tkonsta commented 2 months ago

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.

atl-mk commented 2 months ago

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 commented 2 months ago

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

MonsieurCellophane commented 2 weeks ago

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.

tkonsta commented 2 weeks ago

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.