ttalvitie / browservice

Browservice: Browse the modern web on historical browsers
MIT License
1.08k stars 32 forks source link

Browservice fails to start in WSL2 #94

Open dajhorn opened 1 year ago

dajhorn commented 1 year ago

If the wslu support package is installed in a WSL2 guest, then /tmp/.X11-unix is a symlink to /mnt/wslg/.X11-unix, which is a read-only tmpfs mount.

$ ls -la /tmp
total 12
drwxrwxrwt  3 root    root    4096 Feb 11 22:40 .
drwxr-xr-x 19 root    root    4096 Feb 11 22:37 ..
lrwxrwxrwx  1 root    root      19 Jan  5 16:22 .X11-unix -> /mnt/wslg/.X11-unix
drwx------  2 dajhorn dajhorn 4096 Feb 11 22:17 .mount_browseQmMvt2

$ mount | grep wslg
none on /mnt/wslg type tmpfs (rw,relatime)
/dev/sdc on /mnt/wslg/distro type ext4 (ro,relatime,discard,errors=remount-ro,data=ordered)
none on /mnt/wslg/versions.txt type overlay (rw,relatime,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/system/rw/work)
none on /mnt/wslg/doc type overlay (rw,relatime,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/system/rw/work)
none on /mnt/wslg/.X11-unix type tmpfs (ro,relatime)

This causes browservice to fail like this:

$ ./browservice-v0.9.6.2-x86_64.AppImage
INFO @ src/main.cpp:200 -- Loading vice plugin retrojsvice.so
INFO @ src/main.cpp:207 -- Initializing vice plugin retrojsvice.so
INFO @ retrojsvice.so src/context.cpp:281 -- Creating retrojsvice plugin context
INFO @ src/xvfb.cpp:64 -- Starting Xvfb X server as child process
_XSERVTransSocketUNIXCreateListener: mkdir(/tmp/.X11-unix) failed, errno = 22
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for unix
...
_XSERVTransSocketOpenCOTSServer: Unable to open socket for unix
_XSERVTransOpen: transport open failed for unix/UBUNTU:59535
_XSERVTransMakeAllCOTSServerListeners: failed to open listener for unix
(EE)
Fatal server error:
(EE) Failed to find a socket to listen on(EE)
PANIC @ src/xvfb.cpp:131: Starting Xvfb failed

The same error happens if /mnt/wslg/.X11-unix is remounted read-write.

Browservice starts as expected if the /tmp/.X11-unix symlink is deleted such that the X11 stack recreates it as a directory, but that breaks Windows desktop integration with other Linux apps.

$ ./browservice-v0.9.6.2-x86_64.AppImage
INFO @ src/main.cpp:200 -- Loading vice plugin retrojsvice.so
INFO @ src/main.cpp:207 -- Initializing vice plugin retrojsvice.so
INFO @ retrojsvice.so src/context.cpp:281 -- Creating retrojsvice plugin context
INFO @ src/xvfb.cpp:64 -- Starting Xvfb X server as child process
INFO @ src/xvfb.cpp:135 -- Xvfb X server :0 successfully started
[0211/224947.674874:ERROR:bus.cc(399)] Failed to connect to the bus: Could not parse server address: Unknown address ty>
[0211/224947.680637:ERROR:bus.cc(399)] Failed to connect to the bus: Could not parse server address: Unknown address ty>
INFO @ retrojsvice.so src/context.cpp:331 -- Starting plugin
INFO @ retrojsvice.so src/http.cpp:620 -- Starting HTTP server (listen address: 127.0.0.1:8080)
INFO @ retrojsvice.so src/http.cpp:628 -- HTTP server started successfully
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[0211/224947.955547:ERROR:gpu_init.cc(523)] Passthrough is not supported, GL is desktop, ANGLE is
[0211/224947.999609:WARNING:sandbox_linux.cc(385)] InitializeSandbox() called with multiple threads in process gpu-proc>
[0211/224948.091606:ERROR:gpu_memory_buffer_support_x11.cc(49)] dri3 extension not supported.

$ xclock
No protocol specified
Error: Can't open display: :0

Version info is:

$ uname -a
Linux UBUNTU 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.47+Branch.main.Sha.77aa1e2f49e1253cde9ceb9124ca0873eb3eadf2
Mariner: VERSION="2.0.20221010"
DirectX-Headers:
mesa:
pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5
FreeRDP: c574044a10003e50453acb4cf42801c5833fb572
weston: e7e91e17f370702f386c843cf9014cc4bcef4179
PS C:\> wsl --version
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.1194

I appreciate that running browservice in WSL2 is a corner case because it can run on the Windows host, but there might be a more general bug in how the /tmp/.X11-unix symlink is handled.

ttalvitie commented 1 year ago

Yeah, the only way currently to run Browservice with WSLg is to remove the symlink or run Browservice with command line option --use-dedicated-xvfb=NO (causing the browser to run in the desktop X session). I currently don't have good ideas on how to fix this, as the error occurs in Xvfb, not in Browservice itself. We could possibly patch both Xvfb and Chromium to use a different path for the sockets, but that is hacky and error-prone. I'm open to suggestions on better ways to make this work.