Skip to content

Instantly share code, notes, and snippets.

@onomatopellan
Last active July 20, 2025 16:58
Show Gist options
  • Save onomatopellan/c5220c0efddaff69aaff77cca80b7b8e to your computer and use it in GitHub Desktop.
Save onomatopellan/c5220c0efddaff69aaff77cca80b7b8e to your computer and use it in GitHub Desktop.
Waydroid in WSL2 with sound (Weston on top of Weston approach)

Waydroid in WSL2 with sound

Requirements

Recommended to install Waydroid in a brand new Ubuntu 25.04 install. Waydroid needs a custom linux kernel. Actually just needs latest kernel for WSL2 with just these changes before compiling:

CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"

Make sure WSL2 uses the custom kernel and modules modifying .wslconfig (or using WSL Settings)

[wsl2]
kernel=D:\\mykernel\\bzImage-6.6.87.ANDROID
kernelModules=D:\\mykernel\\modules.vhdx

Setup

Download ubuntu-25.04-wsl-amd64.wsl distro from https://releases.ubuntu.com/plucky/

Double click on the .wsl file to install.

Run Ubuntu 25.04 and make sure is updated

sudo apt update && sudo apt upgrade -y

Install weston

sudo apt install weston

Install Waydroid

curl -s https://repo.waydro.id | sudo bash
sudo apt install waydroid

Configure Waydroid to only use software rendering (SwiftShader)

sudo nano /var/lib/waydroid/waydroid_base.prop

    ro.hardware.gralloc=default
    ro.hardware.egl=swiftshader

Make weston detect gpu for some acceleration

export GALLIUM_DRIVER=d3d12

Run weston

weston --backend=wayland-backend.so 

Inside weston desktop shell open a terminal and run

waydroid session start

When it shows 'Android with user 0 is ready' then open another terminal inside the weston desktop and run

waydroid show-full-ui

Tips:

  • If Waydroid shows some weird dbus errors make sure you shutdown the WSL2 VM (wsl.exe --shutdown) and try again.

  • By default Waydroid only launches correctly if the WSL2 networking mode is not MIRRORED. This is because dnsmasq tries to reserve port 53 that is already used in Windows. If you want to keep using MIRRORED networking you will need to add this to your .wslconfig (or using WSL Settings)

    [experimental]
    ignoredPorts=53
    
  • Every time the WSL2 kernel changes significantly (from ASHMEM support in 5.15.x to none in 6.6.x) you need to reconfigure Waydroid or it wont boot.

      sudo waydroid upgrade --offline
    
@onomatopellan
Copy link
Author

onomatopellan commented Jun 2, 2025

@Timbo303 Did you try the Weston on Weston approach? Since WSLg uses Weston as a Wayland compositor you can run another Weston window where you can launch Waydroid. You won't need the full Ubuntu desktop and sounds works inside the Weston desktop shell.
I made a quick guide here https://gist.github.com/onomatopellan/c5220c0efddaff69aaff77cca80b7b8e

I tried to follow your instructions. However weston doesn't start up for some reason giving me this error:

Error: Failed to connect to parent Wayland compositor: No such file or directory display option: (none), WAYLAND_DISPLAY=wayland-0 [18:39:48.523] fatal: failed to create compositor backend

The correct way to run it is weston --backend=wayland-backend.so or just weston

But it seems some env variable is not defined.

What's the content of your env variables? Run env and see if you have something like these:

SHELL=/bin/bash
WSL2_GUI_APPS_ENABLED=1
WSL_DISTRO_NAME=Ubuntu-25.04
GALLIUM_DRIVER=d3d12
WAYLAND_DISPLAY=wayland-0
DISPLAY=:0
XDG_RUNTIME_DIR=/run/user/1000/
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
HOSTTYPE=x86_64
PULSE_SERVER=unix:/mnt/wslg/PulseServer

ls -la /run/user/1000/ should show the wayland-0 socket

$ ls -la /run/user/1000/
total 0
drwxr-xr-x 6 onoma onoma 260 Jun  2 11:37 ./
drwxr-xr-x 3 root  root   60 Jun  2 11:36 ../
srw-rw-rw- 1 onoma onoma   0 Jun  2 11:36 bus=
drwxr-xr-x 4 onoma onoma  80 Jun  2 11:37 dbus-1/
drwx------ 2 onoma onoma 160 Jun  2 11:36 gnupg/
srw-rw-rw- 1 onoma onoma   0 Jun  2 11:36 pk-debconf-socket=
drwxr-xr-x 2 onoma onoma  80 Jun  2 11:36 pulse/
srw-rw-rw- 1 onoma onoma   0 Jun  2 11:36 snapd-session-agent.socket=
drwxr-xr-x 6 onoma onoma 160 Jun  2 11:36 systemd/
lrwxrwxrwx 1 root  root   31 Jun  2 11:36 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0=
lrwxrwxrwx 1 root  root   36 Jun  2 11:36 wayland-0.lock -> /mnt/wslg/runtime-dir/wayland-0.lock
srwxr-xr-x 1 onoma onoma   0 Jun  2 11:37 wayland-1=
-rw-r----- 1 onoma onoma   0 Jun  2 11:37 wayland-1.lock

Also make sure you have latest WSL version 2.5.7 (wsl.exe --version) and your .wslconfig file loads the generated kernel modules too:

[wsl2]
kernel=D:\\mykernel\\bzImage-6.6.87.ANDROID
kernelModules=D:\\mykernel\\modules.vhdx

@Timbo303
Copy link

Timbo303 commented Jun 2, 2025

You are a Pure Genius. I don't know how this wasn't figured out sooner these instructions are way easier. I got minecraft for android running at 1-2 fps (I expected minecraft to not work. Cut the rope works but with audio issues). I will make sure to update everyone and give you credit.

Screenshot 2025-06-02 125730

@onomatopellan
Copy link
Author

You are welcome. And yes, right now Waydroid only works with software rendering. I'm looking at the Lineage image Waydroid uses and their mesa actually is compiled with d3d12 support. That means Waydroid should have gpu acceleration in WSL2 through mesa but it doesn't work. I guess the problem is Waydroid is inside a container so it can't access /lib/wsl/lib and lib/wsl/drivers.

@onomatopellan
Copy link
Author

onomatopellan commented Jun 7, 2025

Well, I think it's not possible for now. I just compiled a vendor.img with mesa and it never enables d3d12. Inside Waydroid every binary and lib are android binaries that normally won't be ready for read external linux libraries.

In order to get gpu acceleration (OpenGL to D3D12) in Waydroid we would need:

  1. compiled android mesa with d3d12 gallium support enabled.
  2. compiled android d3d libraries from /usr/lib/wsl/lib
  3. compiled android libraries from /usr/lib/wsl/drivers

Step 1 is possible but 2 only can happen if Microsoft opensources libd3d12.so, libd3d12core.so and libdxcore.so. so we can compile them for android. Step 3 would need every gpu vendor compiling their drivers to android and bundle it in the windows drivers package. (like they already made for linux binaries)

@soybeans-generator
Copy link

@onomatopellan
Copy link
Author

@soybeans-generator Thanks for the link, it's a very nice project. Unfortunately it still has same problem as this gist, it only works with software rendering (swiftshader). In a real linux it uses gpu acceleration because mesa is able to access to the real gpu. In WSL2 we only get a gpu abstraction (/dev/dxg) so we would need all the android versions of the libraries from my previous post.

@PEMessage
Copy link

PEMessage commented Jul 17, 2025

For those who encounter

failed to connect to parent wayland compositor: no such file or directory display option: (none), wayland_display=wayland-0

You may need this

microsoft/WSL#11261

using workaround this post provided but need a slide tweak (we may also link pulse dir into XDG_RUNTIME_DIR)

The script I used are list below

#!/bin/bash
set -x
mkdir -p ~/.config/systemd/user
cat  <<EOF > ~/.config/systemd/user/symlink-wayland-socket.service
[Unit]
Description=Symlink Wayland socket to XDG_RUNTIME_DIR

[Service]
Type=oneshot
ExecStart=/usr/bin/ln -s /mnt/wslg/runtime-dir/wayland-0      \$XDG_RUNTIME_DIR
ExecStart=/usr/bin/ln -s /mnt/wslg/runtime-dir/wayland-0.lock \$XDG_RUNTIME_DIR
ExecStart=/usr/bin/ln -s /mnt/wslg/runtime-dir/pulse \$XDG_RUNTIME_DIR

[Install]
WantedBy=default.target
EOF


systemctl --user enable symlink-wayland-socket.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment