microsoft / wslg

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

Windows window constantly losing focus and flickering #443

Open FireFoxAhri opened 3 years ago

FireFoxAhri commented 3 years ago

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:

You can access the wslg logs using explorer at: \\wsl$\<Distro-Name>\mnt\wslg (e.g.: \\wsl$\Ubuntu-20.04\mnt\wslg)

Expected behavior

All is OK.

Actual behavior

After using WSL. Windows is unable to use.

eightbit commented 1 year ago

@hideyukn88 That worked. Thanks a ton!

rommeswi commented 1 year ago

There is a terminal issue that references to here. Unless one sets guiapplications=false, the terminal window loses focus right after launch. The terminal issue has been closed as a duplicate of this, but even despite running the most recent WSL, the issue persists.

WSL version: 1.2.0.0 Kernel version: 5.15.90.1 WSLg version: 1.0.51 MSRDC version: 1.2.3770 Direct3D version: 1.608.2-61064218 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.1555

olaf-k commented 1 year ago

same here with a fresh Ubuntu install on wsl2. opening a fresh terminal session launches a new tab which loses focus right away. it doesn't happen once wsl is up and running when opening subsequent tabs.

WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1555
nx-frost commented 1 year ago

I have the same issue as mentioned by @rommeswi and @olaf-k, The issue only occurs with wslg in Windows Terminal (but works as expected when guiapplications=false is set in .wslconfig). The issue is very similar to microsoft/terminal #13388. It does not occur with Command Prompt or Powershell, only WSL, and only on the first launch; once running, new Terminal windows open as expected. If one runs wsl --shutdown and then relaunches, the issue occurs once again.

WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22623.1250
lsborg commented 1 year ago

Same here using powershell. Very annoying!!!!

Versão do WSL: 1.2.5.0
Versão do kernel: 5.15.90.1
Versão do WSLg: 1.0.51
Versão do MSRDC: 1.2.3770
Versão do Direct3D: 1.608.2-61064218
Versão do DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Versão do Windows: 10.0.22621.1702
MallocArray commented 1 year ago

Same issue for me after installing the latest WSL on a new machine using wsl --install -d Ubuntu-22.04 --web-download since business restrictions prevent using the Store directly. After starting Ubuntu 22.04 in WSL, focus was constantly being removed from any window until WSL was shutdown.

Accessing Windows 10 VM via Citrix

 wsl --version
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19044.2965

adding guiApplications=false to .wslconfig got me working for now.

tig commented 1 year ago

Same issue just started happening for me.

guiApplications=false stops the flickering.

[wsl2]
guiApplications=false
WSL version: 1.3.14.0
Kernel version: 5.15.90.3-1
WSLg version: 1.0.55
MSRDC version: 1.2.4419
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25880.1000-230602-1350.main
Windows version: 10.0.25236.1010
hideyukn88 commented 1 year ago

Thanks for reporting the issue, this is known issue and there are several root causes, some fixes are underway, some is understood, but no fix, and there might be unknowns. Below is cut & paste from what I posted at other issue.

Currently there is a few known issues can lead this situation.

1: If you have Citrix application installed, this applies to any Microsoft remote desktop software usage including WSLg, Citrix has KB published at https://support.citrix.com/article/CTX107825/how-to-disable-citrix-api-hooks-on-a-perapplication-basis. We have possible solution for this from Microsoft side, currently it's estimated to be released as WSL update by end of August.

2: Your organization deployed certain group policies to block remote desktop connection from your local computer. One of the most common policies we are aware of is, RDP signing requirement policy, when it is enabled, msrdc.exe for WSLg failed and enter restarting loop silently. This is because RDP file used with WSLg is not signed by Microsoft or any certificate your local computer trust. (Given WSLg is open source project, currently there is difficulties to have Microsoft signed RDP file). We are actively working with related groups within Microsoft to have solution, but not yet at this point.

3: There is another group policy let silently fail remote desktop connection, which we are not aware of. If your local computer is managed by your organization and experiencing this issue, please share the output from reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S.

4: If none of above, there is some unknown things happen in WSLg VM, this case, we will need dumps/logs from /mnt/wslg/dumps or /mnt/wslg/*.log. If you hesitate to share files directly at here. please submit file via Feedback Hub. and let us know the feedback ID. (Note: these folders are clean up at every WSL startup, thus files need to be captured while active WSL instance is experiencing the issue).

5: There is one known issue causing WSLg compositor in Linux (weston) during handshake with msrdc.exe, which is tracked by https://github.com/microsoft/wslg/issues/901.

6: at last, in order to mitigate this issue, https://github.com/microsoft/wslg/pull/1082 is submitted.

If there is any question, feel free to post question here, thanks!

tig commented 1 year ago

1: If you have Citrix application installed, this applies to any Microsoft remote desktop software usage including WSLg, Citrix has KB published at https://support.citrix.com/article/CTX107825/how-to-disable-citrix-api-hooks-on-a-perapplication-basis. We have possible solution for this from Microsoft side, currently it's estimated to be released as WSL update by end of August.

I don't use Citrix.

2: Your organization deployed certain group policies to block remote desktop connection from your local computer. One of the most common policies we are aware of is, RDP signing requirement policy, when it is enabled, msrdc.exe for WSLg failed and enter restarting loop silently. This is because RDP file used with WSLg is not signed by Microsoft or any certificate your local computer trust. (Given WSLg is open source project, currently there is difficulties to have Microsoft signed RDP file). We are actively working with related groups within Microsoft to have solution, but not yet at this point.

How can I see if this policy impacts me?

3: There is another group policy let silently fail remote desktop connection, which we are not aware of. If your local computer is managed by your organization and experiencing this issue, please share the output from reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S.

 reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client
    fEnableUsbBlockDeviceBySetupClass    REG_DWORD    0x1
    fEnableUsbNoAckIsochWriteToDevice    REG_DWORD    0x50
    fEnableUsbSelectDeviceByInterface    REG_DWORD    0x1

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client\UsbBlockDeviceBySetupClasses
    1000    REG_SZ    {3376f4ce-ff8d-40a2-a80f-bb4359d1415c}

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client\UsbSelectDeviceByInterfaces
    1000    REG_SZ    {6bdd1fc6-810f-11d0-bec7-08002be2092f}

4: If none of above, there is some unknown things happen in WSLg VM, this case, we will need dumps/logs from /mnt/wslg/dumps or /mnt/wslg/*.log. If you hesitate to share files directly at here. please submit file via Feedback Hub. and let us know the feedback ID. (Note: these folders are clean up at every WSL startup, thus files need to be captured while active WSL instance is experiencing the issue).

See attached.

pulseaudio.log stderr.log wlog.zip

5: There is one known issue causing WSLg compositor in Linux (weston) during handshake with msrdc.exe, which is tracked by #901.

weston.log

6: at last, in order to mitigate this issue, #1082 is submitted.

FilipMitrevFugro commented 1 year ago

Confirming this on a fresh Win10. disabling GUIs is not really a solution to the problem.

FilipMitrevFugro commented 1 year ago

Update: The issue was being caused from a enterprise policy registry entry. Please check Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Terminal Server Client in registry for an entry called EnableAdvancedRemoteFXRemoteAppSupport. Removing this helped me solve the issue, I can run UIs again after disabling the flag. More info here: https://github.com/microsoft/WSL/issues/9752