Skip to content

Instantly share code, notes, and snippets.

@saikocat
Created October 28, 2024 16:00
Show Gist options
  • Save saikocat/eec498db43bc71abfee79e2990f4d8b6 to your computer and use it in GitHub Desktop.
Save saikocat/eec498db43bc71abfee79e2990f4d8b6 to your computer and use it in GitHub Desktop.
wayland + systemd + kde + screenshare + 'loop->recurse > 0' failed at ../pipewire/src/pipewire/thread-loop.c:426 pw_thread_loop_wait()

Symptoms

  • Firefox - Google Meet | Zoom - can't share screen.
  • Chromium - Google Meet | Zoom - can share only tab, and not windows or desktop.
  • Slack - Share Screen - gray pop-up without any options to select.
  • Obs - Screen Capture (Pipewire) option is not available.
  • 'loop->recurse > 0' failed at ../pipewire/src/pipewire/thread-loop.c:... pw_thread_loop_wait()

Troubleshooting

For some reasons, I noticed that WAYLAND_DISPLAY & XDG_CURRENT_DESKTOP are not set in the shell env, which might point to the login manager / systemd not setting the values correctly.

Check env and proc of wayland

$ env | grep '^WAYLAND_DISPLAY=' 
WAYLAND_DISPLAY=wayland-0
$ < "/proc/$(pidof xdg-desktop-portal)/environ" tr '\0' '\n' | grep '^WAYLAND_DISPLAY='

Not work if the values are not the same or the same from /proc/xxx/environ is empty

Check running status of required services (most likely are all running)

$ systemctl --user status pipewire.socket pipewire 
$ systemctl --user status wireplumber
$ systemctl --user status xdg-desktop-portal
$ systemctl --user status plasma-xdg-desktop-portal-kde.service

Import env var and restart to pick-up the new env var

$ dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=KDE
$ systemctl --user stop pipewire pipewire.socket wireplumber xdg-desktop-portal plasma-xdg-desktop-portal-kde.service
$ systemctl --user start pipewire pipewire.socket wireplumber xdg-desktop-portal plasma-xdg-desktop-portal-kde.service
# --user restart is fine too

Double check the value is set

$ < "/proc/$(pidof xdg-desktop-portal)/environ" tr '\0' '\n' | grep '^XDG_CURRENT_DESKTOP='
XDG_CURRENT_DESKTOP=KDE

Restart firefox, obs, etc... to test

$ obs
...
info: PipeWire initialized
info: User added source 'Screen Capture (PipeWire)' (pipewire-screen-capture-source) to scene 'Scene'
info: [pipewire] Screencast session created
info: [pipewire] Asking for monitor and window
...

Attempt to set the values automatically (Unverified)

$ mkdir ~/.config/xdg-desktop-portal/
$ nvim ~/.config/xdg-desktop-portal/portals.conf
[preferred]
default=kde;gtk

$ mkdir -p ~/.config/systemd/user/xdg-desktop-portal.service.d/
$ nvim ~/.config/systemd/user/xdg-desktop-portal.service.d/override.conf
[Service]
Environment="XDG_CURRENT_DESKTOP=KDE"

References

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