wslg
wslg copied to clipboard
Windows window constantly losing focus and flickering
Environment
Windows build number: 10.0.22449.0
Your Distribution version: Ubuntu
Your WSLg version: 1.0.27
Two of my PC faced the same issue. The Intel one occurred more times than the first.
1. AMD 5800x + NVIDIA 1070ti latest driver 471.96
2. Intel i7-10510U UHD620 latest driver 30.0.100.9805
Steps to reproduce
It appears itself sometime after using WSL, even don't start a wslg window.
Then the window with focus will constantly losing focus. E.g. Windows Terminal, The title bar is flickering showing it is losing focus and gaining focus. But I can't type any word into it. Only a quick Mouse click and type can input one char into terminal. After input wsl --shutdown then everything is normal.
https://user-images.githubusercontent.com/14964489/132632006-19e56c03-3b19-4f3f-8de3-e74b2a64be88.mp4
https://user-images.githubusercontent.com/14964489/132632048-5fa2459e-be51-476d-9c87-c629176b35b1.mp4
WSL logs:
- Attach WSLg logs from
/mnt/wslg
You can access the wslg logs using explorer at: \\wsl$\<Distro-Name>\mnt\wslg (e.g.: \\wsl$\Ubuntu-20.04\mnt\wslg)
- pulseaudio.log
- weston.log
versions.txt
WSLg ( x86_64 ): 1.0.27+Branch.main.Sha.88b37acc845d5608873211ab7a3fc09bc49151d1
Mariner: VERSION="1.0.20210224"
FreeRDP: b05321cd4e6a862aef76163a69db4e1910245736
weston: 7c0bbd09f40f796eb0d2c0974e8f91347d9ef08f
pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5
mesa:
Expected behavior
All is OK.
Actual behavior
After using WSL. Windows is unable to use.
@FireFoxAhri, thanks for reporting the issue. For diagnostics purpose, would you please disable Linux GUI support by adding below to .wslconfig (refer https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig), and if the problem persist? thanks!
[wsl2] guiapplications=false
After set this option. I don't faced the issue.
My typical usage of WSL is VS Code remote WSL and compile and debug C/C++ projects.
Then I delete the config the problem comes again quickly.
@FireFoxAhri, thanks for additional info, by looking at your weston.log, it looks weston (WSLg's wayland compositor) is keep restarting, (while it shouldn't case the focus lost in Windows side, but) I would like to know why it's restarting first. Do you see any core dumps are created at /mnt/wslg/dumps? thanks!
@hideyukn88 ,Thanks for helping to solve this problem. the Intel one is my working PC. So I need to wait until Monday to see it. Sorry for the inconvenience. I'll try to see if I can reproduce in my home PC, It happens rarely than Intel one.
core.zip After this issue appears again, there is one core.weston. @hideyukn88
@FireFoxAhri, thanks for sharing the core dump with me. I looked at the dump and confirmed this is fixed by https://github.com/microsoft/weston-mirror/pull/39, and the fix is a part of https://github.com/microsoft/wslg/releases/tag/v1.0.28 release. Thanks!
Guys, I am suffering from the same thing - it's impossible to work as the focus is being stolen by the mstsc process spawned by wslhost. Looking at my Windows update I see I have last installed "Windows Subsystem for Linux WSLg Preview - 1.0.26" on Oct 29. Is the solution to disable it and wait for 1.0.28?
This issue makes the Greenshot screen capture utility non-functional. I only see the problem with systems that have a NVIDIA GPU. On my laptop, if I disable the NVIDIA GPU and only use the Intel GPU, Greenshot works fine.
Disabling WSLg works fine for all GPU's.
@FireFoxAhri, thanks for sharing the core dump with me. I looked at the dump and confirmed this is fixed by microsoft/weston-mirror#39, and the fix is a part of https://github.com/microsoft/wslg/releases/tag/v1.0.28 release. Thanks!
maybe it's a dump question, but how can i install the 1.0.28 prerelease edition?
The installer is just a MSI file. So, a simple double click may do the trick 🤞
After installing the 1.0.28 prerelease version I'm not able to reproduce the error.
I experienced a similar problem with 1.0.26 on Win11 22000.348: mstsc stole focus (verified with WindowFocusLogger) once every minute or so when any WSL distros were running, including those used by Docker Desktop. After installing 1.0.28 prerelease, it has not happened. I'll update if it does.
My GPU is AMD RX 6700 XT with driver 21.11.3.
EDIT: Have not noticed this problem since installing 1.0.28 prerelease.

1.0.26 with Win11 also. Installing 1.0.28 to test, looking forward to being fixed properly!
Temporary fix, until the issue is resolved, is unfortunately to disable WSLg as per:
https://github.com/MicrosoftDocs/wsl/blob/main/WSL/wsl-config.md#options-for-wslconfig
Edit %USERPROFILE%\.wslconfig and add this to the [wsl2] section.
guiApplications=false
The shutdown and restart wsl2.
Unfortunately, this problem still persists on WSLg v1.0.32 on Windows 11 build 22598 and renders my computer unusable. This does not happen immediately after I fire up WSL, for instance, but after some time, all windows keep losing focus repeatedly every few seconds. The problem goes away when I forcibly shut down WSL or set guiapplications=false in .wslconfig.
However, one of the core reasons I upgraded to Win11 was WSLg support, and while I know people are working on this, it's kinda frustrating to use WSLg or keep it disabled, which takes away a massive potential from WSL, even though it's still a great tool and I depend on it.
@amzon-ex, @bpienig, thanks for trying out WSLg, do you see any dump files at /mnt/wslg/dumps? if so, please share with us, thanks!
@hideyukn88 No, in my case, there's no folder named dumps within /mnt/wslg/.
@amzon-ex, if you disable WSLg by .wslconfig, then you won't have that folder. But once you reenable it, and when you encounter the window focus issue, I hope there will be dumps created in that folder, thanks!
After installing 1.0.28 prerelease I can confirm the flickering issue goes away.
However, the high CPU usage remains. Like most reports on here WSL2 (Vmmem) goes along fine and then suddenly blows up. I however can replicate the issue, so hopefully that helps. It happens without fail once I load Affinity Designer (installed through the Windows store). In fact that seems to be only thing that sets it off. I can go weeks of daily WSL2 usage with no issues, then shortly after loading Affinity Designer my Vmmem CPU usages goes from <3% to at least 25%.
Also of note, if I shutdown my WSL instance then re-start it the CPU kicks up again. The only way stop the high CPU usage once it starts is a computer restart. :( So in my case something else must be started up when I load Affinity Designer. Maybe what needs to be tracked down to solve this issue?
I encountered this issue today when using any image editor. Even MSPaint. I'll try disabling wslgui. But that's going to hinder my workflow quite a bit :c
@onetrev,
After installing 1.0.28 prerelease I can confirm the flickering issue goes away.
The latest WSLg release is 1.0.33, please install it from aka.ms/wslstorepage, and try it, thanks!
Hey @hideyukn88 ... Thanks for pinging me on this. I've been testing WSLg 1.0.33 all day today and so far so good! Which is excellent news. Thanks again!
Ah, the same issue i have, #8490 @WSL.
I'm sure it related with the PNG image in the clipboard.
I fount it here, #8166 @WSL.
I'm sure it related with the PNG image in the clipboard.
I believe I got this bug to trigger without using my clipboard. 🤔 I think it has more to do with just image APIs in general. Often times I would open up MSPaint and it would trigger the bug instantly.
Maybe there's multiple bugs here that are causing the same thing.
One problem / question @hideyukn88 ... I uninstalled Windows Subsystem for Linux WSLg Preview (1.0.28 prerelease) before downloading the MS Store version you suggested (v1.0.33).
But now Windows Update wants me to install WSLg again (and in this case it's version 1.0.26 since that's the latest public release version). Is there something I can do to rectify this please?
@onetrev, you do not need to uninstall WSLg prior to install Store version, those are two separate installations and Store version takes priority. We are currently working on to merge these 2 separate releases into one, hasn't happened yet. If WU installs update while Store version is installed, WU version won't be used. Thanks!
Updating to WSLg 1.0.34 has solved this problem for me. In an elevated prompt:
(base) PS C:\Users\mitch> wsl --update
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
(base) PS C:\Users\mitch> wsl --version
WSL version: 0.60.0.0
Kernel version: 5.10.102.1
WSLg version: 1.0.34
MSRDC version: 1.2.2924
Direct3D version: 1.601.0
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.160
Thank you for the hard work developers!
After upgrading to the lastest version (Kernel version: 5.10.102.1), the issue is still active. Launching WSL or Docker Desktop make the screen flickering / refreshing every second making Windows unusable.
Thanks to @bpienig, the following tips works ! https://github.com/microsoft/wslg/issues/443#issuecomment-1090658280
(Win11 Pro Version 10.0.22000 Build 22000)
@cvionnet, would you please share output from wsl --version (run from Windows command prompt), thanks!
@hideyukn88 Hi ! I must be making a mistake because the command returns :
Invalid command line option: --version
With wsl --status :
Default Distribution: Ubuntu Default Version: 2 Windows Subsystem for Linux was last updated on 10/08/2022 Kernel version: 5.10.102.1