Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSLg Qt program doesn't work inside the bottle #175

Closed
WuTao18 opened this issue Jun 12, 2021 · 7 comments
Closed

WSLg Qt program doesn't work inside the bottle #175

WuTao18 opened this issue Jun 12, 2021 · 7 comments
Labels
bug Something isn't working closed-as-stale help wanted Extra attention is needed no-issue-activity

Comments

@WuTao18
Copy link

WuTao18 commented Jun 12, 2021

Windows version (build number):
21390.1010

Linux distribution:
Manjaro

Genie version:
1.42

Describe the bug
WSLg works fine with genie, except for Qt programs. Qt programs work fine outside the bottle, but it doesn't work inside the bottle. Qt programs can be launched in the bottle, but the GUI cannot be displayed properly.

To Reproduce
Steps to reproduce the behavior:

  1. Start Manjaro WSL: wsl -d Manjaro
  2. Run a shell in the bottle: genie -s
  3. Run a Qt program such as VLC: vlc
  4. See error

Expected behavior
Qt programs can work as good as other GUI programs.

Screenshots
Run VLC in the bottle:
image

Run VLC outside the bottle:
image

@WuTao18 WuTao18 added the bug Something isn't working label Jun 12, 2021
@PhyX-Meow
Copy link

Same issue here, I can't run cmake-gui inside bottle.

@cerebrate cerebrate added the help wanted Extra attention is needed label Jun 16, 2021
@cerebrate
Copy link
Member

Cannot consistently repro. (Odd results: vlc fails even outside bottle, audacious succeeds even inside bottle.

Anyone who knows something about Qt and its perversions care to chip in?

@PhyX-Meow
Copy link

PhyX-Meow commented Jun 17, 2021

Cannot consistently repro. (Odd results: vlc fails even outside bottle, audacious succeeds even inside bottle.

Anyone who knows something about Qt and its perversions care to chip in?

On my machine, the result is consistent, both vlc and audacious succeed outside bottle and fail inside bottle.
wslg: 1.0.12
Windows: 10.0.21390.2025
Distro: Manjaro testing
Qt5: 5.15.2+kde+r196-1
Qt6: 6.1.1-1

@cerebrate
Copy link
Member

I cannot repro this on a distribution I'm familiar with (which list does not include Manjaro); unfortunately, Arch issues already eat up a disproportionate amount of support time, and I don't have enough to dedicate to hunting down something this specific to an Arch derivative.

I'll leave this open and hopefully someone who has more knowledge of Manjaro can find something.

@cerebrate cerebrate removed their assignment Jul 13, 2021
@cerebrate cerebrate removed the on-hold label Aug 8, 2021
@esgie
Copy link

esgie commented Sep 19, 2021

I have been experiencing exactly same issue (under our „beloved” ArchWSL).
It looks like the cause is that the main process of affected (X11) app runs in the bottle as expected, although forked subprocesses are being started outside of the bottle somehow. And outside of the bottle wslg-xwayland.service isn’t in force, so if /tmp is wiped at any stage of boot (for example by mounting it as tmpfs which is quite common scenario), /tmp/.X11-unix/X0 cannot be accessed.
That result in, for example, qutebrowser properly displaying UI, but area where web pages are rendered with individual subprocesses remain black.

To fix that, wslg socket at /tmp/.X11-unix/X0 has to be regenerated from outside of the bottle, after systemd has started (e.g. after /tmp gets wiped). Then, it will be reachable from both out- and inside world.

As a workaround I have disabled wslg-xwayland.socket and added such a snippet to my ~/.bashrc.

wsl_mount_root=/mnt
wsl_windir="${wsl_mount_root}/c/WINDOWS/System32"
wsl_distro=Arch
wsl_wslg_display=0

# check if in-built wslg socket exists at all
if test -S $wsl_mount_root/wslg/.X11-unix/X0; then
        # fix is needed in case system socket in /tmp doesn't exist or it's true, canonical path isn't the wslg socket's one
        if ! test -e /tmp/.X11-unix/X${wsl_wslg_display} || ! test "$(readlink -f /tmp/.X11-unix/X${wsl_wslg_display})" = "$wsl_mount_root/wslg/.X11-unix/X0"; then
			echo -e "* WSL: restoring WSLG X11 server socket on /tmp/.X11-unix/X${wsl_wslg_display}"
			# recreate /tmp/.X11-unix directory if needed
			if test ! -d /tmp/.X11-unix; then
				$wsl_windir/wsl.exe -d $wsl_distro -u root install -dm 1777 -o root /tmp/.X11-unix
			fi
			# delete existing socket if needed. this must obviously break something that created that socket
			# and you'd rather define display not colliding with other sockets
			if test -e /tmp/.X11-unix/X${wsl_wslg_display}; then
				$wsl_windir/wsl.exe -d $wsl_distro -u root rm -Rf /tmp/.X11-unix/X${wsl_wslg_display} /tmp/.X${wsl_wslg_display}-lock
			fi
			# if desired display is different than wslg's default 0, check if WSLG socket doesn't already exist on X0
			# if yes, delete it aswell to avoid having the same wslg socket bound to two separate display numbers
			if test $wsl_wslg_display -ne 0; then
				if test -e /tmp/.X11-unix/X0 && test "$(readlink -f /tmp/.X11-unix/X0)" = "$wsl_mount_root/wslg/.X11-unix/X0"; then
					$wsl_windir/wsl.exe -d $wsl_distro -u root rm -Rf /tmp/.X11-unix/X0 /tmp/.X0-lock
				fi
			fi
			# create symlink to wslg socket
			$wsl_windir/wsl.exe -d $wsl_distro -u root ln -s $wsl_mount_root/wslg/.X11-unix/X0 /tmp/.X11-unix/X${wsl_wslg_display}
			# export updated display number for user's convenience
			export DISPLAY=:${wsl_wslg_display}
        fi
fi

First four lines must be customized per needs.
Script - in short - creates simple symlink from OUTSIDE of the bottle, so /tmp/.X11-unix/X0 is linked to /mnt/wslg/.X11-unix/X0 and the link is accessible from both worlds. In addition, user may configure different display number for using wslg, then the link is created as X1, X2, etc. and gfx works after updateing DISPLAY var accordingly. (i have added that as I was starting desktop manager via systemd headlessly (with vnc access) and I wasn’t able to configure it to start on other display than :0 to keep access to WSLG from the user session)

@PhyX-Meow
Copy link

PhyX-Meow commented Oct 13, 2021

@esgie Hello, I tried your script. It work as expected as cmake-gui runs perfetly but......
Now gvim and microsoft-edge refuse to start and crash in a second.

❯ edge
[1013/231838.595223:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[1013/231838.595270:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
[1] 1122 trace trap microsoft-edge-beta

❯ gvim
E233: Could not open display

E852: The child process failed to start the GUI

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

There has been no activity on this issue for over 60 days. If there is no further activity within 7 days from this message, it will be automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working closed-as-stale help wanted Extra attention is needed no-issue-activity
Projects
None yet
Development

No branches or pull requests

4 participants