wslg icon indicating copy to clipboard operation
wslg copied to clipboard

GUI launching slow

Open LorVC opened this issue 4 years ago • 21 comments

Environment

Windows build number: 10.0.22000.100
Your Distribution version: Ubuntu 20.04
Your WSLg version:1.0.24

Steps to reproduce

  1. enter the normal Linux terminal
  2. run any GUI app like gedit

WSL logs:

Expected behavior

Opening performance same as launching from windows search or from the command "wslg APP"(in this case gedit)

Actual behavior

Opening is about minutes and more, instead ,launching from windows takes few seconds.

LorVC avatar Aug 04 '21 08:08 LorVC

@LoreBadTime, thanks for reporting the issue. May I ask the slowness only happens at first launch of Linux GUI app? We do aware of the slowness caused by fontconfig initialization since WSLg uses Windows fonts as well and it has to access via /mnt/c which is slower filesystem, but this only happens at first time after WSL VM started. Thanks!

hideyukn88 avatar Aug 10 '21 16:08 hideyukn88

Hi there,no this happens also after few launches,the main issue is that launching directly from Linux causes a slow launch(even 10 minutes), launching from Windows instead is fast;this happens,in my case,every time a app is launching

LorVC avatar Aug 10 '21 21:08 LorVC

@LoreBadTime, if I understand correctly, the slowness occurs at your end by launching, for example, xclock from xterm (= launching any Linux GUI app from Linux terminal), is this correct? So far I haven't been able to observe the slowness. Would you please run app under strace if it shows some clue? Thanks!

hideyukn88 avatar Aug 20 '21 18:08 hideyukn88

straceout.txt this is the strace output,idk how much is happening,but maybe the program is stuck in some kind of loop?

LorVC avatar Sep 12 '21 05:09 LorVC

I have this problem too - gedit or any other graphical app consistently takes minutes to run. On last timing it took 8m 50s. Assume some stuff is sitting waiting to timeout?

I've previously had GWSL (https://opticos.github.io/gwsl/) installed and I'm wondering if there is some leftover config that is still trying to connect to a nonexistent server? Just a thought. I don't know where the config would be though, so would appreciate any pointers.

halfninja avatar Oct 12 '21 19:10 halfninja

I found my answer in #26 - $DISPLAY was set to 172.24.96.1:0.0. After setting it to :0 apps start quickly.

For reference this gets left in .bashrc and .profile even after uninstalling GWSL so I guess this (for me) is a GWSL uninstall bug

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0 #GWSL
export PULSE_SERVER=tcp:$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}') #GWSL

halfninja avatar Oct 12 '21 20:10 halfninja

I can confirm with @halfninja that this is a GWSL bug.

Andrew-J-Larson avatar Oct 21 '21 18:10 Andrew-J-Larson

GWSL cannot detect when it is uninstalled so it cannot automatically remove its changes. However, there is a builtin button to "clean up" its changes to .profile and .bashrc.

Pololot64 avatar Oct 21 '21 18:10 Pololot64

I also came across this issue after I try to visualize the xfce4 desktop through VcXsrc. My method to resolve this issue is commenting out the below 2 lines and then restarting WSL2. Then it becomes normal.

export DISPLAY=xx.xx.xx.xx:0 export LIBGL_ALWAYS_INDIRECT=1

yang-yuke avatar Nov 22 '21 18:11 yang-yuke

Thanks for reminding me, I'd also had vcXsrv and had manually set a DISPLAY in my .bashrc to get around weirdness - getting rid of it after upgrading to Windows 11 and removing vcXsrv fixed everything!

vitaminj avatar Jan 26 '22 15:01 vitaminj

To me, the solutions written above do not solve the problem.

The apps launch but the GUI is frighteningly slow, and reacts with MINUTE delays to clicks, opening menus, etc. (after it loads).

I have tried deleting the GWSL export lines from .bashrc and .profile, but nothing has changed.

What am I missing?

f-liva avatar Sep 29 '22 06:09 f-liva

@f-liva That sounds like a different problem from what's described here (which is just about launch time, not sluggish behaviour once launched) so I'd raise a new issue.

halfninja avatar Sep 29 '22 11:09 halfninja

Was this ever solved? I'm running Ubuntu under WSL on a brand new Windows 11 Dell laptop, and launching GEDIT (which I have routinely been doing for years) takes tens of seconds each time. Notes :

  • My DISPLAY variable is set to :0.
  • There is no ~/.xinitrc file.
  • strace shows the delay happens after "poll([{fd=11, events=POLLIN}], 1, 25000"

PTW19 avatar Dec 14 '24 21:12 PTW19

  1. Remove the WSLg preview app
  2. Reboot
  3. Update WSL from the terminal
  4. Reinstall distro having the problem
  5. Check to make sure it's on WSL2, and change it if it's not

Then, see if you're still running into those problems.

Andrew-J-Larson avatar Dec 15 '24 01:12 Andrew-J-Larson

Andrew - many thanks for that rapid reply.

Forgive me if I ask for some additional information. I'm merely a developer of numerical libraries and console applications (with Tcl/Tk graphics) that run on Windows, Unix and macOS, and amazingly ignorant of systems management on any of the platforms.

  1. Remove the WSLg preview app - do I type "sudo apt remove WSLg" in the WSL terminal window?
  2. Reboot - I assume this means the Windows 11 host, not just restarting the WSL session?
  3. Update WSL from the terminal - does this mean type "wsl --update" in the WSL terminal?
  4. Reinstall distro having the problem - I'm unclear on what exactly I need to do. And will it delete all my $HOME... files?
  5. Check to make sure it's on WSL2, and change it if it's not - does this meant type "wsl -l -v" into Powershell?

Sorry if this is trying your patience.

PTW19 avatar Dec 15 '24 10:12 PTW19

p.s. I can't get anywhere even with Step 1. I don't know things like whether "WSLg preview app" is something in addition to WSL or a variant of WSL.

I am also disheartened. What I did when I got my last Dell laptop a decade ago was install VirtualBox and create a VM running Ubuntu. It just worked. This time, with my shining new Dell laptop running Windows 11 Pro, all three of my attempts to set up an Ubuntu VM have either failed or fallen short:

  • The Hyper-V one takes literally dozens of start/connect cycles before eventually it boots. There must be some race condition going on.
  • VirtualBox never gets as far as installing Ubuntu - it just hangs.
  • WSL almost hits the spot but gedit is unusable because of the loading time and I have to resort to using nano (or might revisit emacs) .

PTW19 avatar Dec 16 '24 09:12 PTW19

Andrew - many thanks for that rapid reply.

Forgive me if I ask for some additional information. I'm merely a developer of numerical libraries and console applications (with Tcl/Tk graphics) that run on Windows, Unix and macOS, and amazingly ignorant of systems management on any of the platforms.

  1. Remove the WSLg preview app - do I type "sudo apt remove WSLg" in the WSL terminal window?
  2. Reboot - I assume this means the Windows 11 host, not just restarting the WSL session?
  3. Update WSL from the terminal - does this mean type "wsl --update" in the WSL terminal?
  4. Reinstall distro having the problem - I'm unclear on what exactly I need to do. And will it delete all my $HOME... files?
  5. Check to make sure it's on WSL2, and change it if it's not - does this meant type "wsl -l -v" into Powershell?

Sorry if this is trying your patience.

  1. It would be an app installed on the Windows side of things, the preview isn't needed anymore unless you want strange bugs.
  2. Yes.
  3. Yes.
  4. If you need your home files, install a new instance of the distro first to transfer things over and replicate like you had things before uninstalling the broken one.
  5. Yes.

Andrew-J-Larson avatar Dec 16 '24 16:12 Andrew-J-Larson

p.s. I can't get anywhere even with Step 1. I don't know things like whether "WSLg preview app" is something in addition to WSL or a variant of WSL.

I am also disheartened. What I did when I got my last Dell laptop a decade ago was install VirtualBox and create a VM running Ubuntu. It just worked. This time, with my shining new Dell laptop running Windows 11 Pro, all three of my attempts to set up an Ubuntu VM have either failed or fallen short:

  • The Hyper-V one takes literally dozens of start/connect cycles before eventually it boots. There must be some race condition going on.
  • VirtualBox never gets as far as installing Ubuntu - it just hangs.
  • WSL almost hits the spot but gedit is unusable because of the loading time and I have to resort to using nano (or might revisit emacs) .

There are some incompatibilities with VirtualBox when some of the requirements for WSL are turned on.

  • See this: https://learn.microsoft.com/en-us/windows/wsl/faq#will-i-be-able-to-run-wsl-2-and-other-3rd-party-virtualization-tools-such-as-vmware--or-virtualbox-

Andrew-J-Larson avatar Dec 16 '24 16:12 Andrew-J-Larson

Your advice is much appreciated. There is nothing called WSLg installed on the Windows 11 side - and I tried searching for the string "WSLg" in the list. This presumably eliminates Steps 1 and 2. I tried "wsl --update" and it said I had the latest version. The current VM is WSL2 so presumably a reinstall will be the same.

I'll check out the link. I had tried disabling Hyper-V to test VirtualBox but to no avail.

I'm wondering if it's all to do with Windows 11 update 24H2. Another symptom I'm getting is very slow loading of some newly GCC-compiled C programs, all on the Windows side.

I'm glad my ancient Windows 10 Dell Precision M4700 is still running, VirtualBox and all...

PTW19 avatar Dec 16 '24 17:12 PTW19

Your advice is much appreciated. There is nothing called WSLg installed on the Windows 11 side - and I tried searching for the string "WSLg" in the list. This presumably eliminates Steps 1 and 2. I tried "wsl --update" and it said I had the latest version. The current VM is WSL2 so presumably a reinstall will be the same.

I'll check out the link. I had tried disabling Hyper-V to test VirtualBox but to no avail.

I'm wondering if it's all to do with Windows 11 update 24H2. Another symptom I'm getting is very slow loading of some newly GCC-compiled C programs, all on the Windows side.

I'm glad my ancient Windows 10 Dell Precision M4700 is still running, VirtualBox and all...

Luckily I work in IT, and I can certainly tell you that what you're experiencing is a CPU slowdown everywhere in the OS, not caused by WSL, or Hyper-V.

I'd recommend restoring to a version of Windows 11 before the 24H2 update, as there have been numerous performance issues I've seen when I've had users upgrade to that version.

Andrew-J-Larson avatar Dec 16 '24 18:12 Andrew-J-Larson

I followed most of the suggestions mentioned here but the problem persists. I did notice that for gEdit, when I try to run it normally, it takes about 30 - 60 seconds to open, but when I run it using sudo it opens immediately. As a total newbie to the Linux world, I can't make sense of it.

Gofnax avatar Mar 21 '25 14:03 Gofnax

I decided to give WSL2 a try and immediately ran into this issue. Running a GUI app as user was slow. As root it launched instantly. strace showed "poll([{fd=11, events=POLLIN}], 1, 25000"

After some time of poking around I was finally able to fix it by uninstalling xdg-desktop-portal-gtk and xdg-desktop-portal.

sudo apt remove xdg-desktop-portal xdg-desktop-portal-gtk

Now GUI apps launch immediately as user.

TeeHunter13 avatar May 25 '25 14:05 TeeHunter13

For whatever reason, without having changed anything since my previous reply, I can now run gedit normally, with no perceptible startup delay. If the problem returns I shall no doubt try uninstalling xdg-desktop-portal-gtk and xdg-desktop-portal as TeeHunter13 has suggested.

In recent times I have been using WSL as my Linux VM very successfully, while my Hyper-V VM continues not to work properly, requiring dozens of restarts before eventually booting. For what I do, I think WSL has won.

PTW19 avatar May 25 '25 16:05 PTW19

I decided to give WSL2 a try and immediately ran into this issue. Running a GUI app as user was slow. As root it launched instantly. strace showed "poll([{fd=11, events=POLLIN}], 1, 25000"

After some time of poking around I was finally able to fix it by uninstalling xdg-desktop-portal-gtk and xdg-desktop-portal.

sudo apt remove xdg-desktop-portal xdg-desktop-portal-gtk

Now GUI apps launch immediately as user.

Hi, doing this worked for me, gedit launches instantly without being root!

valentinvuillon avatar Jun 19 '25 13:06 valentinvuillon