wslg icon indicating copy to clipboard operation
wslg copied to clipboard

After each reboot [WARN: COPY-MODE] happens, many program fails to start

Open sarim opened this issue 2 years ago • 18 comments
trafficstars

Windows build number:

10.0.22621.1194

Your Distribution version:

22.04

Your WSL versions:

WSL version: 1.1.0.0 Kernel version: 5.15.83.1 WSLg version: 1.0.48 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.1194

Steps to reproduce:

  1. Turn on computer.
  2. Open Windows Terminal
  3. type gedit and enter, notice [WARN: COPY-MODE], in title. GUI is slow. At lease gedit opens, many other programs fail to start bcz of this.

WSL logs:

WSL LOG by powershell script: WslLogs-2023-02-01_23-05-52.zip

Logs from /mnt/wslg: pulseaudio.log stderr.log weston.log wlog.log

Output of WSL Debug Console Window: WSL_Debug_console_output.txt

WSL dumps:

/mnt/wslg/dumps is empty.

Expected behavior:

Gui applications run flawlessly, without [WARN: COPY-MODE], and without lag.

Actual behavior:

Apps like gedit run with [WARN: COPY-MODE] in title. and gui is laggy, like any change, animations etc... Some programs outright fail to start.

Only workaround I discovered is to run wsl --shutdown several times and test if gedit is running okey, after trying 3-4 times, it fixes itself. But we need to careful not to close all terminal of ubuntu, if distro gets shut down after idle period, problem reappears. AND 100% of the time when computer boots up it starts in wrong mode. This is happening for couple of months, with several of latest wsl versions.

sarim avatar Feb 01 '23 17:02 sarim

@sarim, thanks for reporting the issue, while [WARN: COPY-MODE] is not expected, but it should not prevent application from starting up, would you please share what apps are failing to start? thanks!

hideyukn88 avatar Feb 07 '23 19:02 hideyukn88

Thanks for reporting this @sarim. I see that you have a custom command line that disable cgroup_v1 in .wslconfig:

kernelCommandLine=cgroup_no_v1=all

This is probably the issue. Can you try removing that line, and then run wsl --shutdown and start wsl again and see if the issue is resolved ?

OneBlue avatar Feb 07 '23 19:02 OneBlue

I don't have the command line option but still get the WARN: COPY-MODE message.

dciarniello avatar Apr 12 '23 16:04 dciarniello

@sarim, thanks for reporting the issue, while [WARN: COPY-MODE] is not expected, but it should not prevent application from starting up, would you please share what apps are failing to start? thanks!

@hideyukn88 I don't remember exact apps now. But issue was with electron apps, those run with --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WaylandWindowDecorations. The hard crash issue kinda solved with electrons latest versions. But the glaring problem with [WARN: COPY-MODE] is, in this mode contents on display doesn't update correctly. For example in github-desktop, I'm seeing one file, now I click another file, the content still shows previous file, or the content showing is glitchy etc.. Whatevs, I don't think its necessary to try to fix things in [WARN: COPY-MODE]. I just don't want to run things in [WARN: COPY-MODE] . I want to run things in normal mode.

Thanks for reporting this @sarim. I see that you have a custom command line that disable cgroup_v1 in .wslconfig:

kernelCommandLine=cgroup_no_v1=all

This is probably the issue. Can you try removing that line, and then run wsl --shutdown and start wsl again and see if the issue is resolved ?

I've tried with that on and off. It doesn't matter. The root of the issue I think is this line.

rdp_allocate_shared_memory: Failed to open "/mnt/shared_memory/{ba3a781f-4787-440d-b2e6-82f295c7b564}" with error: Input/output error

In /mnt/wslg/weston.log. When this error shows up in weston.log, GUI applications open with [WARN: COPY-MODE].

@OneBlue I remember seeing this allocate shared memory issue in wsl/wslg issues too. It seems like a known and widely affected problem, not something only me is encountering. Was it properly debugged why allocating fails? Any Root issue to track it? Maybe a quick workaround could be weston should try to allocate it couple of times if it fails first time?

sarim avatar Jul 17 '23 21:07 sarim

Since a couple of days I also have the same problem of windows showing [WARN: COPY-MODE] and I also see the error

rdp_allocate_shared_memory: Failed to open "/mnt/shared_memory/{02...d0c}" with error: Input/output error

in the /mnt/wslg/weston.log

I don't have any custom command line set up in .wslconfig

Is there a way to disable or customize/shorten the [WARN: COPY-MODE] header? It makes it hard to distinguish multiple open IDE windows to see which project is opened in which of the windows..

tkonsta avatar Sep 27 '23 08:09 tkonsta

@tkonsta When you see WARN: COPY-MODE, run wsl --shutdown from powershell/cmd. Then open wsl again. For me it fixes the issue for that session.

I have this in my bashrc

if grep -q "rdp_allocate_shared_memory: Failed to open .* with error: Input/output error" "/mnt/wslg/weston.log"; then
    echo -e "\n\033[1;31mAttention: WSLG Weston log file contains an error regarding shared memory allocation\033[0m\n"
fi

So whenever it shows the error, I do wsl --shutdown. And that fixes it for the session. The frequency of this happening decreased significantly since I opened the issue, but the problem still definitely remains.

sarim avatar Sep 27 '23 14:09 sarim

@tkonsta, @sarim, have you tired pre-release version of WSL which can be installed by wsl --update --pre-release? thanks!

hideyukn88 avatar Sep 27 '23 18:09 hideyukn88

I didn't try the update to the pre-release version yet and would prefer to wait for my productive work environment until WSL version 2 is officially released as stable.

However today I updated my Windows Nvidia GPU driver and after having installed the latest version with the "clean install" flag, the problem seems gone now. Could be a coincidence and I just hit one of the working attempts now, so I will keep an eye on how this evolves with the next restarts of WSL2.

tkonsta avatar Sep 28 '23 14:09 tkonsta

@tkonsta, thanks for update, NVIDIA GPU driver is very unlikely the cause of this issue, but most likely, during that update, it might involve the restart of WSL and new instance of WSL didn't hit this issue, thanks!

hideyukn88 avatar Sep 28 '23 16:09 hideyukn88

@hideyukn88 Yes, I always keep updated with latest pre-release version. As per my normal workflow, I boot up my computer and shutdown before going to sleep, and I keep my wsl terminal always open. WSL has once per day chance of showing this bug. As I said, the frequency decreased over time with updates, but within last few days, with wsl v2.0.0 and v2.0.1, It happened once. So the issue remains but decreased.

sarim avatar Sep 28 '23 17:09 sarim

@tkonsta, thanks for update, NVIDIA GPU driver is very unlikely the cause of this issue, but most likely, during that update, it might involve the restart of WSL and new instance of WSL didn't hit this issue, thanks!

You were totally right with that assumption, @hideyukn88 . It was just a single lucky restart attempt after installing the driver. Since then I didn't have one fine working WSL2 in about 10 restart attempts so far.

But at least thanks to the script in .bashrc, which was suggested by @sarim , now I can directly see that I will get the [WARN: COPY-MODE] headers and can decide to try some more restarts to get rid of it.

tkonsta avatar Oct 04 '23 07:10 tkonsta

This seems related to #179, where the same underlying error is causing trouble, but the focus of the other ticket is different.

Also in #426 there are some workarounds mentioned on how to restart Weston without the need to shutdown the whole wsl distro (deep links: https://github.com/microsoft/wslg/issues/426#issuecomment-907635787 and https://github.com/microsoft/wslg/issues/426#issuecomment-908442965 )

tkonsta avatar Nov 22 '23 16:11 tkonsta

I'm with latest pre-release of wsl as always. But problem seemed to came back with a vengeance for the last month. Always everyday It happens. Thanks to my script in https://github.com/microsoft/wslg/issues/972#issuecomment-1737468490 I always gets notified and do wsl --shutdown to fix it. I don't think it's even related to wsl/wslg version update, Rather a windows update. Because AFAIR it started happening after a windows update.

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.22621.3672

sarim avatar Jun 13 '24 15:06 sarim

I also run into this issue almost every day

WSL version: 2.3.11.0 Kernel version: 6.6.36.3-1 WSLg version: 1.0.63 MSRDC version: 1.2.5326 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.26100.1150

Stanzilla avatar Jul 17 '24 21:07 Stanzilla

Yes, It's been a constant problem last couple of months. Always have to do wsl --shutdown.

sarim avatar Jul 17 '24 22:07 sarim

I've been hitting this issue semi-regularly. Fairly annoying, but I found something less disruptive than wsl --shutdown:

wsl --system /bin/bash -c 'pgrep weston | xargs kill -9'

This only kills the GUI side of things, rather than taking down the whole WSL instance. I still need to restart the GUI programs, but they all start properly after running that command.

jaybosamiya avatar Sep 05 '24 22:09 jaybosamiya

I didn't comment in here but in recent month it has been constant, each time when wsl first starts this happens. Even when wsl gets auto shutdown due to no linux program / terminal being open, then started again, this happens most of the time. It feels like this not only relates to WSL/WSLg but also related to windows itself, because seems like it started happening more with some windows updates.

Since this hasn't been solved in years, I'm guessing the underlying bug is hard to pin down/fix? So about a workaround inside WSLg official weston? Like if weston encounters this it'll retry after 100ms. 3 retry then fall back to this copy-mode?

Also related new, possible DUP https://github.com/microsoft/wslg/issues/1278

sarim avatar Sep 05 '24 22:09 sarim

@jaybosamiya From the WIKI remember you can restart WSLg with Left-Ctrl + Left-Alt + Backspace.

To enable it, in PowerShell run notepad.exe $Env:USERPROFILE\.wslgconfig

and add this content:

[system-distro-env]
WESTON_RDPRAIL_SHELL_ALLOW_ZAP=true

After wsl.exe --shutdown you should be able to restart WSLg manually.

onomatopellan avatar Sep 07 '24 09:09 onomatopellan