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

Ubuntu 24.04 Wayland falling back to X11 #1244

Open
avlec opened this issue May 13, 2024 · 30 comments
Open

Ubuntu 24.04 Wayland falling back to X11 #1244

avlec opened this issue May 13, 2024 · 30 comments
Labels
bug Something isn't working

Comments

@avlec
Copy link

avlec commented May 13, 2024

Windows build number:

10.0.22621.0

Your Distribution version:

24.04

Your WSL versions:

WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.3296

Steps to reproduce:

  1. wsl --install Ubuntu-24.04
  2. setup account
  3. sudo apt update
  4. sudo apt install emacs-pgtk
    (or other GTK app)
  5. emacs

WSL logs:

stderr.log
weston.log
pulseaudio.log

WSL dumps:

No response

Expected behavior:

Emacs or whatever GUI application to launch using Wayland and not Xwayland

Actual behavior:

Outputs the following and falls back to xorg display frames.

MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen

image

@avlec avlec added the bug Something isn't working label May 13, 2024
@avlec
Copy link
Author

avlec commented May 14, 2024

Some more context if I try to explicitly set the GDK_BACKEND as follows I just get the following console output, no window is opened, and the program terminates.

> GDK_BACKEND=wayland emacs

(emacs:1152): Gtk-WARNING **: 09:26:41.236: cannot open display: :0

@avlec
Copy link
Author

avlec commented May 14, 2024

On 22.04 I do not need to use weston. I can also just use emacs without pgtk but this should be something that works

@viruscamp
Copy link

Due to a bug of systemd fixed in 24.04, you must do :

ln -sf  /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/

Or use an autostart conf : https://github.com/viruscamp/wslg-links

BTW, It's real that wayland working in 22.04@WSL depends a bug of systemd.

@avlec
Copy link
Author

avlec commented May 15, 2024

Yeah I'm not having any luck with the symlink.

This is still happening #1244 (comment)

A weird quirk is that creating this symlink under your user account doesn't work (symlink is red in ls) but creating it when su'd into ubuntu the symlink creation works (symlink is blue in ls) but it still can't open the app.

@zcobol
Copy link

zcobol commented May 15, 2024

The fix provided by @viruscamp makes emacs work on wayland instead of Xwayland:

emacs-pgtk_wsl_wayland

Your ls -la $XDG_RUNTIME_DIR output should be like above.

Thanks @viruscamp!

@avlec
Copy link
Author

avlec commented May 15, 2024

So yeah no dice still. My XDG_RUNTIME_DIR seems to be missing things when compared to your screenshot.

In the screenshot creating those links under my user account doesn't work. Creating the links under the ubuntu user works but it still can't open the display.

image

@avlec
Copy link
Author

avlec commented May 15, 2024

Perhaps I'm running into this issue ubuntu/WSL#468 because I would have just used the ubuntu username but it complains that user already exists?

How are you installing 24.04? Are you updating from an existing 22.04?

@viruscamp
Copy link

Perhaps I'm running into this issue ubuntu/WSL#468 because I would have just used the ubuntu username but it complains that user already exists?

How are you installing 24.04? Are you updating from an existing 22.04?

I think you met the bug.

id avlec
id ubuntu

You can see that uid=1000 is ubuntu . WSLg works only for uid=1000. That another bug of WSLg.

Ubuntu's fix only applies to new install of 24.04.

Maybe there is only unstable and insecure method:

  • manually edit /etc/passwd to swap uid
  • chown uid for home of swapped user

@avlec
Copy link
Author

avlec commented May 16, 2024

Yes all of my attempts to use 24.04 on WSL have been fresh installs.

The fixes @viruscamp linked are working on the ubuntu user.

I'm just running into the user bug still with installing 24.04 fresh. (I removed the 24.04 app and reinstalled from winget) Is there some Windows or WSL update I have not gotten?

@viruscamp
Copy link

I guess the fixed wsl-setup package has not been put into the install image of ubuntu 24.04 for WSL.

We'd better wait them to publish a new image.

@elsaco
Copy link

elsaco commented May 16, 2024

@avlec you're correct, wslg already starts a compositor:

Command line: /usr/bin/weston --backend=rdp-backend.so --modules=wslgd-notify.so --xwayland --socket=wayland-0 --shell=rdpr
ail-shell.so --log=/mnt/wslg/weston.log --logger-scopes=log,rdp-backend,rdprail-shell

Looks like the Ubuntu-24.04 switches to cloud-init and has user id=1000 defined in the cloud.cfg:

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
  # This will affect which distro class gets used
  distro: ubuntu
  # Default user name + that default users groups (if added/used)
  default_user:
    name: ubuntu
    lock_passwd: True
    gecos: Ubuntu
    groups: [adm, cdrom, dip, lxd, sudo]
    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
    shell: /bin/bash

and the installer is creating a user with id=1002 messing up wslg which is hardcoded to user id=1000.

If you want to fix it and use emacs-pgtk with wayland backend just edit /etc/group and /etc/passwd and switch IDs. You also have to edit the regkey and change DefaultUid from 0x3ea (1002) to 0x3e8 (1000). Look for the corresponding distro keys in \HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\. Or, wait for the store package to be fixed.

emacs-pgtk works, after applying @viruscamp fix:

emacs_pgtk_ubuntu

@avlec
Copy link
Author

avlec commented May 16, 2024

Yes @elsaco that's where we've gotten to. Just don't know what @zcobol did to have it working without hacking the user/groups.

Note: an easier hack is to create a 24.04 and use a throw away username and then just do the registry edit trick to change the DefaultUid then you can login as ubuntu and apply viruscamp's fix

@viruscamp is there any issue anywhere tracking the problem you fixed?

@mwoodpatrick
Copy link

I just did a clean install of Ubuntu 24.04 and applied viruscamp's fix and

lrwxrwxrwx 1 ubuntu ubuntu  31 May 19 06:54 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0
lrwxrwxrwx 1 ubuntu ubuntu  36 May 19 06:54 wayland-0.lock -> /mnt/wslg/runtime-dir/wayland-0.lock

Linls are valid

But when I run google-chrome as the ubuntu user (id: 1000) I get:

MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen

Does anyone know why or have any suggestions on the best way to debug?

wsl --version shows:

WSL version: 2.2.2.0
Kernel version: 5.15.150.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22635.3640

@andrekenji
Copy link

I had a issue " Error: Can't open display: " when I tried to run applications.
PS: I had already installed package x11-apps .

Resolved:

step 1: Windows 11, open Powershell with Run as Administrator, Command line: wsl --update
After updated, I opened WSL ubuntu 24.04 LTS and executed command line: xeyes
And GUI open in Windows.

I don't know if this will help you.

@nullbio
Copy link

nullbio commented Jul 12, 2024

image
I get these strange errors, but xeyes works...

@Canvis-Me
Copy link

Canvis-Me commented Jul 14, 2024

@mwoodpatrick Try to enable systemd and the service from https://github.com/viruscamp/wslg-links, after restart wsl2 you may get chrome working.

@KoenDierckx
Copy link

KoenDierckx commented Jul 20, 2024

To work around the user id issue, I used cloud-init customization

Created file
C:\Users\XXX\.cloud-init\Ubuntu-24.04.user-data

#cloud-config
users:
- default
- name: test
  gecos: Test
  groups: adm, admin, cdrom, floppy, sudo, audio, dip, video, plugdev, users, netdev
  shell: /bin/bash
  sudo: ALL=(ALL) NOPASSWD:ALL
  lock_passwd: false
  plain_text_passwd: test

Then destroyed my wsl environment, and recreated it this way

# THIS WILL DESTROY THE CURRENT INSTALL
wsl --unregister Ubuntu-24.04

ubuntu2404.exe install --root 
ubuntu2404.exe run cloud-init status --wait
wsl --terminate Ubuntu-24.04
wsl

Installed firefox, and it will be using xwayland

Apply the fix from @viruscamp
ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR

Firefox now runs fine with full wayland support

To make it run permanent, add it to /etc/bash.bashrc
(echo; echo'# FIX WSLG'; echo 'ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/') >> /etc/bash.bashrc

For bonus point, add that step to cloud-init

- (echo; echo'# FIX WSLG'; echo 'ln -sf  /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/') >> /etc/bash.bashrc

BUT
what is still failing for me is glxgears (or google_chrome, ...)

$ glxgears
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen

UPDATE
After further investigating this, I believe for better hardware support the usage of the GPU driver that supports WDDM 3.x is required. But that is only supported since windows 11. With windows 10 we are stuck on 2.7. And we are still on windows 10 enterprise. Check dxdiag in windows to see you current version

Would appreciate it if someone could test this with a WDDM 3.x driver on windows 11...

@code-SL
Copy link

code-SL commented Jul 29, 2024

I'm on Debian (12.6) in wsl and emacs 29.2 doesn't launch per above, so it's not just an Ubuntu issue. I compiled emacs locally (using --prefix=<mylocaldirectory>),

But confirm @viruscamp workaround works #1244 (comment).

@alonbl
Copy link

alonbl commented Aug 23, 2024

I do not see authoritative Microsoft response / acknowledge of this issue nor in microsoft/WSL#11261, is there anything else @microsoft needs to attend this issue and fix it properly?

@ghost ghost mentioned this issue Sep 6, 2024
@AZeed18
Copy link

AZeed18 commented Sep 11, 2024

It may be very wrong, but can't I just set XDG_RUNTIME_DIR to /mnt/wslg/runtime-dir in /etc/profile to fix the problem? what are disadvantages of that?

@tsteven4
Copy link

tsteven4 commented Oct 6, 2024

Would appreciate it if someone could test this with a WDDM 3.x driver on windows 11...

I get these messages still on windows 11, but glxgears works.

`$ glxgears
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen

`

@TarunDaCoder
Copy link

ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/

This command works for me. But I have to run it every time WSL restarts itself to open up the app, otherwise it doesn't open. So is there anyway I can automate it? If I add it into my zshrc it opens the "Oh No! Something went wrong" screen.

@wang1zhen
Copy link

for Ubuntu, there is a packaged named =wsl-config=, I think it might be a good idea to integrate these tweaks into that, and also as a Debian user, I would love it if it could be migrated to Debian.

@TarunDaCoder
Copy link

@wang1zhen

for Ubuntu, there is a packaged named =wsl-config=

Could you please send the link to that? I would love to check it out.

@wang1zhen
Copy link

@wang1zhen

for Ubuntu, there is a packaged named =wsl-config=

Could you please send the link to that? I would love to check it out.

https://packages.ubuntu.com/noble/wsl-setup FYI. but this might be somehow off-topic I think.

@Souvlaki42
Copy link

I have similar issues. I was using Ubuntu 22.04 under wayland and now Ubuntu 24.04 runs under X11 for some reason. If anyone finds any solutions I'm interested.

@TarunDaCoder
Copy link

@Souvlaki42 for now this command works
ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/

@Souvlaki42
Copy link

@TarunDaCoder I think I've tried this before and didn't but after a fresh install of WSL2 it worked now.
It should be noted that this command should run in .bashrc or .zshrc though, because every time the instance is shut down, I need to do it again. Thanks for your solution non the less.

@TarunDaCoder
Copy link

Hey, glad to hear it worked!

It should be noted that this command should run in .bashrc or .zshrc though, because every time the instance is shut down, I need to do it again. Thanks for your solution non the less.

Yeah, I am facing that issue as well, but if I put it in my .bashrc or .zshrc it shows me the "Oh No! Something went wrong!" screen and I'm not sure why.

@pickerj
Copy link

pickerj commented Oct 27, 2024

@TarunDaCoder in the issue linked by @alonbl (microsoft/WSL#11261), the issue description shows the steps to make a systemd oneshot service to create those symlinks, have you tried that workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests