-
Notifications
You must be signed in to change notification settings - Fork 859
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, Wayland, Ubuntu 24.04, PyQt6 #12616
Comments
No logs.etl found in the archive. Make sure that you ran Diagnostic information
|
Actually, wslg-links do So the link is Try |
Hi there, the content appears to not be linked (if I'm misunderstanding the tool's usage, please clarify):
Just to sanity check the tool,
|
I would avoid using Ubuntu 24.04 in WSL for now. We're still using the 22.04, sadly 24.04 has too many issues yet with WSL and involves hacks to make it work decently. Hope they'll fix it soon. |
Ah, I got it, Ubuntu and Debian do not need |
Add the following line to
If
Override user-runtime-dir@.service to re-create the wayland and pulseaudio sockets
and add the following
Confirm that wayland socket is available:
|
Hi @viruscamp ; I read the post you had, but I did not understand what you meant there. I had thought "mask" may mean some technical term for some sort of linking or mounting Please correct me if I'm misunderstanding: if Ubuntu doesn't rely on the I'm not familiar with systemd configuration files, but from what I gathered, you're using the Regardless, the re-directs are working:
@loadhigh could you elaborate what does your approach do differently from Virus Camp's? Is there a general benefit (beyond the current wayland issue) to mounting fstab before systemd initializes? Your suggesting for the system service seems (to my untrained eye) to do the same that Virus Camp's does; is this just an alternative file to edit, or does your process achieve something I'm missing? |
|
Windows Version
Microsoft Windows [Version 10.0.26100.3194]
WSL Version
2.4.11.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.167.4-1
Distro Version
Ubuntu 24.04
Other Software
PyQt6 v6.8.1
python3 v3.13.2
gnome-text-editor v46.3 (46.3)
Repro Steps
About
The goal was to plot some data under Ubuntu 24, using Python3's Matplotlib, via PyQt6. A cryptic error about wayland sent me down a rabbit hole. As this dive collected bits and pieces from multiple forums and discussions, I am posting it here such that, by keyword indexing and search engines, other users can find a way forward with less searching.
This is broken into two sections: the first concerns issues with DRI3 and MESA drivers not being up-to-date in Ubuntu 24.04; once that part of the stack is working, the second part deals with Wayland configuration in WSLg.
To reproduce:
WSL & component versions:
MESA
According to https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps WSL should support the Wayland protocol for GUI apps. Given the contents of that tutorial, I expected it to work out of the box; this was not the case. Attempting to launch the Gnome text editor yields an error:
Issues with GUI apps that mention MESA, libEGL have been reported in microsoft/wslg#1250
Installing the Ubuntu package libgles2-mesa-dev allowed the application to launch, the window to draw. The text editor was able to display submenus (e.g. about, save-as file view), save a file, and close the window. This said, the console had:
It seems the MESA driver on Ubuntu 24.04 is broken but there is an update from a 3rd party PPA https://askubuntu.com/questions/1516040/mesa-and-glx-errors-when-running-glxinfo-ubuntu-24-04
The current version of the MESA driver in the main Ubuntu package repo is
After updating via the PPA addition, as documented at https://itsfoss.com/install-mesa-ubuntu/ :
Now, launching the gnome text editor launches a nicer window (no extra frame around the window), and the console has:
However, I couldn't figure out how to resize the window; hovering the mouse cursor over the edge did not change the cursor's icon, nor did it allow the usual grab-to-resize behavior of most window management systems. However, it seems to be using DRI3 at least.
Qt6, Python, Wayland
Ok, so now at least the WSLg demo is kind of working. On to what I actually wanted to do: Qt6 & Python
Installing PyQt6 and testing a minimal sample:
A window is created, the contents are blank, and the error suggests an issue with the wayland protocol plugin.
WSLg supports the Wayland protocol and has a Weston composer inside the "system distro" https://github.com/microsoft/wslg?tab=readme-ov-file#wslg-architecture-overview
Some environment variables for these are set to the correct values, as per https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg:
After setting the environment variable
$ export QT_DEBUG_PLUGINS=1
, the same command shows more verbose output, but does show several plugins from the python PyQt6 library at/home/[user]/.local/lib/python3.13/site-packages/PyQt6/Qt6/plugins/platforms
, includingwayland
,wayland-egl
, andminimalegl
Manually inspecting the contents of the folder, there are files there:
The plugins were installed, by are failing to load. They can be manually selected via an environment variable.
Try wayland directly
No window was drawn.
Try wayland-egl
No window was drawn.
Try minimal
This yielded an unresponsive terminal and no window; the terminal was manually terminated.
Try xcb
This drew an empty window, with no contents; but also, with no errors.
In this context, with the
xcb
platform selected via the environment variable above, using matplotlib to draw a plot as expected, using the QtAgg backend.xcb
is a library for the X protocol, suggesting this works by bypassing Wayland and instead using an X11 path.All together, this suggests an issue with Wayland, Ubuntu 24 and WSLg. Searching online eventually showed
https://stackoverflow.com/questions/79151910/how-to-fix-errors-in-wsl-gui which pointed to https://github.com/viruscamp/wslg-links
As per https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg, there does seem to be an X server running:
However, this does not appear to be a link to a different file from
/mnt/wslg/
These support Virus Camp's results. The suggested fix from https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg#setting-tmp-in-etcfstab yields an error, as:
Testing Virus Camp's approach:
I do not know what issue there is with pulseaudio; I have not noticed issues, but I also don't use audio under WSL...
After rebooting the WSL VM
PS > wsl --shutdown
, relaunching and tryingThe window displays, can be resized, and there's no errors on screen. The
gnome-text-editor
screen can now be resized. Plotting with Matplotlib and PyQt6 works as expected. In a different session (i.e. without setting QT_QPA_PLATFORM), everything works as expected too.This said, the .X11-unix link still seems missing, with neither
ls
norreadlink
suggesting it's a link:Summary
Instead of working out-of-the-box, Wayland apps appear to require a few extra components to work under Ubuntu 24.04 and WSLg. These include an updated MESA "driver" from an external PPA,
libgles2-mesa-dev
from Ubuntu's package tracker, and some more complex file over-writting shenanigans to get a very protected link re-written the right way.Once Ubuntu updates their MESA driver, the first section of this write-up will be (hopefully) obsolete.
As for the
.X11-unix/X0 link
, that seems to be Microsoft's to fix.Expected Behavior
The wayland application works out of the box, as advertised.
Actual Behavior
The wayland application does not work.
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: