Pulseaudio assumes X11 availability if getenv("DISPLAY")!=NULL
Gnome on Wayland is trying to move towards making the X server optional, and only raise it if any X11 client tried to connect to a display socket created on its behalf. In that world, a gnome session would still have a DISPLAY environment variable, and X11-dependent features would be spawned on demand together with the X server through systemd activation.
This plays odd though with some implicit handling of x11 in Pulseaudio though...
- Both the client library's
pa_context
and the pulseaudio daemon try to load part of their configuration from X root window properties, as long as DISPLAY is set. - the start-pulseaudio-x11 script (the de-facto way to start pulseaudio on any session type) loads x11-specific pulseaudio modules, as long as DISPLAY is set.
All of this would result in pulseaudio unintendedly (and needlessly) triggering the spawn of Xwayland, with extra pain points with the client library x11 property handling as gnome-shell is also a pulseaudio client, so xcb_connect() under its feet results in a deadlock.
Ideally, pulseaudio should shy away from using x11 features, and only enable them if there are other X11 peers. A possible list of changes is:
- Clients should be able to opt x11 config integration out. I thought of tying it to PA_PROP_WINDOW_X11_DISPLAY, but that's a behavior change. (Although fun point, the server specified through that property and the server found to fetch window properties from may currently differ)
- The daemon should be able to opt x11 config integration out. Maybe a
--x11-config=[BOOLEAN]
suffices there? - The startup script should be able to opt out loading x11-specific modules
- There should be systemd user session glue so that the x11-specific modules (cork/x11publish) can be loaded/unloaded externally.
It's probably hard to change all of this at once, I appreciate comments about the whole plan and ideas for a roadmap, I will happily do the patches. So far, the most pressing issue is being able to launch a user session without XOpenDisplay/xcb_connect happening.
Related gnome links: https://gitlab.gnome.org/GNOME/gnome-session/merge_requests/13, https://gitlab.gnome.org/GNOME/mutter/commits/wip/carlosg/xwayland-on-demand