udevbe / greenfield

HTML5 Wayland compositor :seedling:
GNU Affero General Public License v3.0
901 stars 27 forks source link

[Build] WSL2 #109

Open markusbkk opened 1 year ago

markusbkk commented 1 year ago

I'd like to use this issue to track my process in getting Greenfield to work under Windows 11/WSL2.

According to https://github.com/microsoft/WSL/issues/938#issuecomment-560030005, this apparently worked before.

RN, after disabling WSLg with the following command (to be updated with a snippet that will automatically pull the Windows username. As soon as I've figured out how to properly get the Windows username from Powershell or cmd without additional characters), Greenfield proxy reports that no dev/dri interface can be found.

echo $'[wsl2]\nguiApplications=false' > /mnt/c/Users/[Windows User]/.wslconfig
Zubnix commented 1 year ago

/dev/dri is optional. It allows for Wayland clients to be hardware accelerated and was only relatively recently added to Greenfield. The comment you posted, Greenfield didn't have support for /dev/dri at the time.

markusbkk commented 1 year ago

/dev/dri is optional. It allows for Wayland clients to be hardware accelerated and was only relatively recently added to Greenfield. The comment you posted, Greenfield didn't have support for /dev/dri at the time.

Makes sense. I think shutting down WSLg made it more complicated than I had thought. Turns out, I just needed to changed the WAYLAND_DISPLAY variable (export WAYLAND_DISPLAY=wayland-1) and start Firefox (my test target ... because browser inception) with MOZ_ENABLE_WAYLAND=1 firefox.

Works properly now. Alas, a bit slow and flickery. But so does the native Wayland compositor on my machine, too. One more question: How do I connect XWayland applications to the compositor? By default, it's still launching them through WSLg for me.

EDIT: NVM. DISPLAY is analogous to WAYLAND_DISPLAY. Just as I thought. It's not displaying xeyes for some other reasons, but Greenfield seems to work on my machine now.

EDIT2: Was apparently an XAUTH issue. After manually setting $Xauthority though, it's now stuck at Spawned XWayland Server (trying with xeyes instead of firefox)

Zubnix commented 1 year ago

Using these steps https://github.com/udevbe/greenfield/issues/108#issuecomment-1294757123 I can run xterm & xeyes

markusbkk commented 1 year ago

Using these steps #108 (comment) I can run xterm & xeyes

Thanks again. I got it working with those steps on my WSL2 Ubuntu 20.04 system, too. Namely, the XAuthority parts helped a lot.

Zubnix commented 1 year ago

I've done some digging on how to run this smoothly on WSLg, and it seems WSLg uses a system distro image to run Weston with a custom build of MESA to get hardware acceleration. I expect Greenfield to run faster/smooth if a similar image is used.

Zubnix commented 1 year ago

Wsl2 now supports gpu video encoding https://devblogs.microsoft.com/commandline/d3d12-gpu-video-acceleration-in-the-windows-subsystem-for-linux-now-available/