wslg
wslg copied to clipboard
msrdc.exe randomly stealing focus
Version
10.0.22621.0
WSL Version
- [X] WSL 2
- [X] WSL 1
Kernel Version
5.15.74.2
Distro Version
Ubuntu 22.04
Other Software
Irrelevant, and happens as soon as the WSL instance is started.
Repro Steps
- Start any WSL instance. In my case I have a WSL v1 started without any WSLg support.
- Wait
- Focus is randomly stolen from your application.
I found an app somewhere at some point simply printing what process is currently getting focus. When focus is stolen I see the following line printed;
4300:C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\msrdc.exe | Thu 17 November 12:26:04
Often I am having an outlook window open at the time in which I am composing a mail and suddenly I cannot write in it anymore.
Expected Behavior
WSL should not steal focus.
Actual Behavior
Focus is randomly stolen
Diagnostic Logs
N/A
I had this same issue today and used Focus Logger to find the culprit. It's also pointing to WSL's msrdc.exe. I've seen this happen with Notepad before, but today it seems to be related to opening Windows Explorer for me. I ran process explorer prior to starting Windows Explorer and watched several wslhost.exe processes start up, but one specifically fires up a conhost.exe process which then starts the msrdc.exe process, and that steals focus before shutting down. This all happens within seconds or less.
Can confirm this behavior on Windows 11, i had no issues until about 2 days ago. msrdc.exe seems to steal focus for a moment every 2 minutes, kicking me out of fullscreen applications.
The only possible cause that I could think of is that I updated my VirtualBox install from from 6 to 7.X around that time. That could be a red herring though, unless someone else can confirm that correlation.
Can confirm this behavior on Windows 11, i had no issues until about 2 days ago. msrdc.exe seems to steal focus for a moment every 2 minutes, kicking me out of fullscreen applications.
The only possible cause that I could think of is that I updated my VirtualBox install from from 6 to 7.X around that time. That could be a red herring though, unless someone else can confirm that correlation.
I don't run VirtualBox at all here.
This problem is driving me absolutely nuts! No matter what I'm using my computer for the focus is lost randomly every couple of minutes. Even trying to shut WSL down doesn't make any difference. I assume if I remove msrdc.exe I'll brick my system, but I really don't know what do do at this point.
Has anyone found any way of fixing this?
/edit:
While wsl --shutdown
didn't do anything killing the WSL process in the task manger seems to at least give temporary relief until the process gets auto started again, e.g. by using Windows Explorer.
Two possible solutions I found are:
-
backup the msrdc.exe file and then delete it.
-
Disable remote credential guard in the group policy editor by:
First going to the local group policy editor, then navigating to Computer Configuration > Administrative Templates > System > Device Guard > Turn on Virtualization Based Security > Choose "Disabled" >Apply and restart pc
Can confirm, Windows 11 Pro, 22H2, 22621.963.
Been wondering what was causing it since November, thought it is from my custom keyboard layout, because one of the symptoms was that the language menu (next to the clock) would disappear in these moments.
@craigloewen-msft Any updates on this (or the other focus stealing threads)? I'm trying to rule out WSL from the cause of microsoft/terminal#13388, but that's proven... tricky.
I just uninstalled everything from my Windows 10 PC and reinstalled it, because it was so unstable. After re-installing I am still seeing the same issue. I can't even add a user to a new distribution because focus is stolen before I can enter a password for a new user.
Using Process Explorer I can see the following hierarchy when the problem occurs:
- wslservice.exe
- wslhost.exe
- conhost.exe
- msrdc.exe
- msrdc.exe
- WerFault.exe
Location of msrdc.exe C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\msrdc.exe
Command line argument msrdc.exe /v:0C22B93D-1735-409E-86C1-A57BAABA42C2 /hvsocketserviceid:4C7A87FC-FACB-11E6-BD58-64006A7986D3 /silent /wslg /plugin:WSLDVC_PACKAGE /wslgsharedmemorypath:WSL\0C22B93D-1735-409E-86C1-A57BAABA42C2\wslg "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\wslg.rdp"
I've seen crashes in msrdc.exe in this background process when using the "Sound for remote desktop" (https://www.sound-over-rdp.com/) software. The cause of the crash was an issue in a DLL they inject in all processes, seemingly to force the output sound device. There was a way to enable crash memory dumps I think with the global flags tool, if you get such a dump may help narrow down the cause of the crash.
The issue I am seeing today shows the following in Problem Details
Source Remote Desktop
Summary Stopped working
Date 1/18/2023 12:45 PM
Status Report sent
Description Faulting Application Path: C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\msrdc.exe
Problem signature Problem Event Name: MoAppCrash Package Full Name: MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe Application Name: praid:msrdc Application Version: 1.2.3575.0 Application Timestamp: 633c8bef Fault Module Name: KERNELBASE.dll Fault Module Version: 10.0.19041.2364 Fault Module Timestamp: 5b7d4d22 Exception Code: c06d007e Exception Offset: 000000000002cd29 OS Version: 10.0.19044.2.0.0.256.4 Locale ID: 1033 Additional Information 1: 3895 Additional Information 2: 3895d839a7fe3f6903b9cbca03bd030e Additional Information 3: 3981 Additional Information 4: 3981f255f8e6b8e54242bfc4bce248e4
Extra information about the problem Bucket ID: 1bdacafa384471b8e7d131b0fc19a97e (0)
This has to be the most infuriating thing I have ever encountered. I can't code in IntelliJ anymore, feels like every other second something is stealing my focus. Using the Focus Logger tool I also identified the "msrdc.exe" as the cause. In the midst of typing some code the focus is just gone, then returns after a few seconds.
I just did a clean install Win11 Pro and did all the updates. Now the Computer is basically unusable.
I found https://github.com/microsoft/wslg/discussions/523, and created the $HOME/.wslconfig
(windows home, C:\Users\..\.wslconfig
not in linux) with
[wsl2]
guiApplications=false
That at least seems to bring some relief.
having the same issue
WSL version: 1.0.3.0
Kernel version: 5.15.79.1
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1105
neither wsl --shutdown
nor $HOME/.wslconfig .. guiApplications=false
helped
Same issue here. I noticed that while wathing youtube in full screen. Screen loses focus and after inspecting it, I found that msrdc.exe was stealing the focus randomly.
I was also informed by WindowsFocusLogger that msrdc.exe is stealing focus from me and googling about the program I came across this issue page.
I tried $HOME/.wslconfig .. guiApplications=false
and then wsl --shutdown
and it seems to have relieved it for me at the moment.
I was also informed by WindowsFocusLogger that msrdc.exe is stealing focus from me and googling about the program I came across this issue page. I tried
$HOME/.wslconfig .. guiApplications=false
and thenwsl --shutdown
and it seems to have relieved it for me at the moment.
For my part, this is not applicable as I also have a WSL2 instance for the purpose of running GUI applications :-) What's interesting for me is that despite the WSL instance loaded is WSL1 without any GUI support it causes issues. If a partial fix would appear that only loaded the WSLg components if the distro has it enabled the problem would be a lot more manageable.
This issue is driving me nuts! I updated WSL2 weeks ago and started to get this problem. If it's caused by WSLg then I wish I can disable it since I don't currently use GUI.
Do this if you want to disable WSLg
When msrdc.exe starts, it should not be get focused if no window shows.
I am also experiencing this problem. Windows 10 Pro.
This is also happening for me on Win11 every 20 seconds or so. I tried using bladeSk/StayFocused, which helps a little, but doesn't prevent it completely.
I've also found that while msrdc is focused, it removes my ENG language indicator from the taskbar:
Normal:
While msrdc takes focus:
My tree from Process explorer is:
-
wininit.exe
-
services.exe
-
svchost.exe
- *
wslhost.exe -Embedding
- *
-
wslservice.exe
- *
wslhost.exe --mode 2 --vm-id {9c326228-a832-4354-be2b-eabc48ec2636} --handle 3000
... - *
wslhost.exe --mode 3 --vm-id {9c326228-a832-4354-be2b-eabc48ec2636} --handle 2060
...- *
conhost.exe 0x4
- *
msrdc.exe /v:9C326228-A832-4354-BE2B-EABC48EC2636 /hvsocketserviceid:C25E2050-FACB-11E6-BD58-64006A7986D3 /silent /wslg /plugin:WSLDVC_PACKAGE /wslgsharedmemorypath:WSL\9C326228-A832-4354-BE2B-EABC48EC2636\wslg "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.3.0_x64__8wekyb3d8bbwe\wslg.rdp"
- *
- *
wslhost.exe --mode 3 --vm-id {9c326228-a832-4354-be2b-eabc48ec2636} --handle 1880
...- *
conhost.exe 0x4
- *
- *
-
vmcompute.exe
- *
vmwp.exe 3C82ED2D-396C-40C6-80E7-9EB65CAA7746 0x234
- *
vmmemWSL
(Those with an asterisk are processes that only appear when it is taking focus)
- *
- *
-
-
wsl --list --running
shows that my Ubuntu distro is running while it is stealing focus, and then shows it no longer running immediately after.
I do have my text editor open on one of the files in the Ubuntu distro, but that shouldn't make it steal focus.
My way I found of preventing it stealing focus was to either: A. Don't have my editor looking at files on WSL in the background, or B. Run a program over WSLg and just have it minimised in the background.
this issue has been happening for 4 months, none of the workarounds help, i've just uninstalled wsl because it's unbearable losing focus this much
@meiskam
Does leaving a program open that is using wslg help? For example, I've got Sublime Merge on WSL open and just minimised in the background, and I haven't had any problems
This sounds dup to https://github.com/microsoft/wslg/issues/998, and the fix went into msrdc.exe, thanks!
Awesome, thanks! Do you know which version of wsl/msrdc will have the fix?
This is making using windows a nightmare. Always losing focus on the apps. Is there any workaround available?
You can disable wslg if you don't plan on using GUI apps in WSL, that would eliminate the problem until the fix can be fleshed out and proliferated
You can disable wslg if you don't plan on using GUI apps in WSL, that would eliminate the problem until the fix can be fleshed out and proliferated
Experiencing the same issues, and this worked for me. Added a new file .wslconfig to my home directory with the following:
[wsl2] guiApplications=false
After a reboot of wsl, msrdc.exe stopped crashing and pulling away focus.
@meiskam
Does leaving a program open that is using wslg help? For example, I've got Sublime Merge on WSL open and just minimised in the background, and I haven't had any problems
Yes, this actually worked perfectly. Thanks for the suggestion! (Popping open xcalc did the trick :)