emersion / xdg-desktop-portal-wlr

xdg-desktop-portal backend for wlroots
MIT License
591 stars 56 forks source link

Cannot get it to work, xdg-desktop-portal failed? #163

Open japhir opened 3 years ago

japhir commented 3 years ago

I've gone through all the steps in the checklist again, but still cannot get this to work! Aargh, I've spent over 2 hours again :cry:

  1. I run on Arch and have libpipewire02 installed. I can "screenshare" chromium tabs, but no full screen. In the firefox test thingie I don't get error messages but just don't see anything but the buttons when sharing the screen. Flags for both chromium and firefox are enabled.
  2. active!
  3. active!
  4. xdg-desktop-portal is active but shows an error
    > systemctl --user status xdg-desktop-portalsyste
    ● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
     Active: active (running) since Fri 2021-08-27 19:36:00 CEST; 43min ago
    Main PID: 1073 (xdg-desktop-por)
      Tasks: 10 (limit: 18893)
     Memory: 6.4M
        CPU: 395ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal.service
             ├─1073 /usr/lib/xdg-desktop-portal
             └─1128 /usr/lib/pxgsettings org.gnome.system.proxy org.gnome.system.proxy.http org.gnome.system.proxy.https org.gnome.system.proxy.ftp org.gnome.system.proxy.so
    Aug 27 19:35:59 worktop systemd[887]: Starting Portal service...
    Aug 27 19:36:00 worktop systemd[887]: Started Portal service.
    Aug 27 19:36:30 worktop xdg-desktop-por[1073]: Failed to get application states: GDBus.Error:org.freedesktop.portal.Error.Failed: Could not get window list
  5. this prints WAYLAND_DISPLAY=wayland-1 and the second command prints the same
  6. check I have the following config file:
    > cat ~/.config/xdg-desktop-portal-wlr/config
    [screencast]
    output_name=
    max_fps=30
    chooser_cmd=slurp -f %o -o
    chooser_type=simple

edit: just to be sure, here's my full env:

full env, click to expand ``` > env ALACRITTY_LOG=/tmp/Alacritty-40423.log COLORTERM=truecolor DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=gnome DISPLAY=:0 HG=/usr/bin/hg HOME=/home/japhir I3SOCK=/run/user/1000/sway-ipc.1000.908.sock LANG=en_US.UTF-8 LOGNAME=japhir MAIL=/var/spool/mail/japhir MOTD_SHOWN=pam MOZ_ENABLE_WAYLAND=1 MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins OLDPWD=/home/japhir PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/japhir/.cabal/bin:/home/japhir/bin:/home/japhir/.local/bin PWD=/home/japhir QT_QPA_PLATFORM=wayland-egl SHELL=/bin/zsh SHLVL=2 SWAYSOCK=/run/user/1000/sway-ipc.1000.908.sock TERM=alacritty USER=japhir WAYLAND_DISPLAY=wayland-1 XCURSOR_SIZE=24 XCURSOR_THEME=Yaru XDG_CURRENT_DESKTOP=sway XDG_RUNTIME_DIR=/run/user/1000 XDG_SEAT=seat0 XDG_SESSION_CLASS=user XDG_SESSION_ID=1 XDG_SESSION_TYPE=wayland XDG_VTNR=1 _=/usr/bin/env _JAVA_AWT_WM_NONREPARENTING=1 ZSH=/usr/share/oh-my-zsh PAGER=less LESS=-R LSCOLORS=Gxfxcxdxbxegedabagacad LS_COLORS= EDITOR=emacsclient -cn SUDO_EDITOR=vim VISUAL=emacsclient -cn ```
apiraino commented 3 years ago

@japhir as far as I understand there are many reasons it may not work. Just sharing my experience on how I solved in my case.

I am not sure what is the "firefox thingie" you're using to test screensharing. By reading your env vars I think you're using Sway with Xwayland. I use Sway ~1.5.1~ (EDIT: 1.6) without Xwayland, my packages as follows:

This error you see:

Aug 27 19:36:30 worktop xdg-desktop-por[1073]: Failed to get application states: \
    GDBus.Error:org.freedesktop.portal.Error.Failed: Could not get window list

I think it's irrelevant. I have it too but it seems harmless.

In my case I solved by doing two things:

  1. I looked closely at the portal files. The portal org.freedesktop.impl.portal.ScreenCast is needed to have screenshare working. I removed it from the file /usr/share/xdg-desktop-portal/portals/gtk.portal and checked that it is present in the /usr/share/xdg-desktop-portal/portals/wlr.portal:

    $ cat /usr/share/xdg-desktop-portal/portals/wlr.portal
    [portal]
    DBusName=org.freedesktop.impl.portal.desktop.wlr
    Interfaces=org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.ScreenCast;
    UseIn=wlroots;sway;Wayfire;river
  2. add to the Sway config this command, as suggested in the wiki:

    exec "systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"

To test I then manually started the portal and checked the output:

$ /usr/libexec/xdg-desktop-portal  -v
XDP: load portals from /usr/share/xdg-desktop-portal/portals
XDP: loading /usr/share/xdg-desktop-portal/portals/wlr.portal                 # loading the wlroots portal
XDP: portal implementation for wlroots, sway, Wayfire, river
XDP: portal implementation supports org.freedesktop.impl.portal.Screenshot
XDP: portal implementation supports org.freedesktop.impl.portal.ScreenCast    # provides support for ScreenCast portal! 
...

Then tested by opening Jitsi Meet on Firefox (v92) and the screensharing was working.

Not sure all this info can help. good luck.

japhir commented 3 years ago

Thanks for the help!

Just to report my env, I indeed use

I also noticed that I had some remnant install of libpipewire02 0.2.7-2, which I just removed.

I changed the line in my sway config to what you shared, I just had exec "systemctl --user import-environment" before. Then deleted the line you mentioned from the gtk portal file and made sure it was there in the wlr portal. Tried to launch /usr/libexec/xdg-desktop-portal -v but this doesn't exist, on my Arch linux machine I think the equivalent is likely /usr/lib/xdg-desktop-portal -v

...
XDP: loading /usr/share/xdg-desktop-portal/portals/wlr.portal # loaded
XDP: portal implementation for wlroots, sway, Wayfire, river
XDP: portal implementation supports org.freedesktop.impl.portal.Screenshot
XDP: portal implementation supports org.freedesktop.impl.portal.ScreenCast

rebooted and tried to screenshare via jitsi (or via the firefox test suite) but I only get a black screen. Perhaps it's because I have two monitors and it can't pick? I have the below config for monitor selection

cat ~/.config/xdg-desktop-portal-wlr/config
[screencast]
output_name=
max_fps=30
chooser_cmd=slurp -f %o -o
chooser_type=simple
apiraino commented 3 years ago

In comparison to your setup (may help exclude some factors):

My env vars are slightly different from yours, I don't have neither $DISPLAY (as I don't use Xwayland) nor $DESKTOP_SESSION set.

Anything strange from journalctl -f --user -xe if you restart the xdg-desktop-portal user service?

Sorry I can't help a lot, this is a bit black magic for me, too. Your setup looks correct, you should not be far from the solution.

japhir commented 3 years ago

Thanks again for further ideas!

I've ditched the config file.

I have all three xdg-desktop-portal-*'s running

I've removed the DESKTOP_SESSION from my .pam_environment and rebooted, but I see no effect. I forgot why I added it, IIRC something to do with using my Yaru-dark gtk theme.

I see one error message now after having restarted xdg-desktop-portal and letting the journalctl -f --user -xe command stay open. It just told me:

Sep 07 15:08:20 worktop xdg-desktop-por[6480]: Failed to get application states: GDBus.Error:org.freedesktop.portal.Error.Failed: Could not get window list

I've just tried to run a jitsi meeting after invoking chromium from the command line, and when sharing the screen and clicking the full screen several times, interestingly it does give me some error output!

chromium
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[3246:3246:0907/150256.060814:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
[3212:3212:0907/150313.598966:ERROR:base_capturer_pipewire.cc(1115)] Failed to select sources for the screen cast session.
[3212:3212:0907/150318.002416:ERROR:base_capturer_pipewire.cc(1115)] Failed to select sources for the screen cast session.
[3212:3212:0907/150333.785077:ERROR:base_capturer_pipewire.cc(1115)] Failed to select sources for the screen cast session.
[3212:3212:0907/150335.611852:ERROR:base_capturer_pipewire.cc(1115)] Failed to select sources for the screen cast session.

launching firefox (using version 91.0.2-1) doesn't log any errors when doing the same.

develroo commented 2 years ago

I am having similar issues on Debian 11 testing in Gnome 41 with pipewire 0.3.40-2 in Wayland. The xdg-desktop-portal-wlr services fails with this error.

/usr/libexec/xdg-desktop-portal-wlr 
2021/12/08 17:57:18 [ERROR] - config: no config file found
2021/12/08 17:57:18 [ERROR] - Compositor doesn't support zwlr_screencopy_manager_v1!
2021/12/08 17:57:18 [ERROR] - xdpw: failed to initialize screencast

From what I can understand, though, zwlr_screencopy_manager_v1 is experimental and not officially upstream yet? The z will be removed when it is.

EDIT: For reference the debug output


/usr/libexec/xdg-desktop-portal-wlr -l DEBUG 
2021/12/08 18:09:46 [ERROR] - config: no config file found
2021/12/08 18:09:46 [DEBUG] - config: outputname:  (null)
2021/12/08 18:09:46 [DEBUG] - config: max_fps:  0.000000
2021/12/08 18:09:46 [DEBUG] - config: exec_before:  (null)
2021/12/08 18:09:46 [DEBUG] - config: exec_after:  (null)
2021/12/08 18:09:46 [DEBUG] - config: chooser_cmd: (null)
2021/12/08 18:09:46 [DEBUG] - config: chooser_type: default
2021/12/08 18:09:46 [DEBUG] - dbus: connected
2021/12/08 18:09:46 [DEBUG] - wlroots: wl_display connected
2021/12/08 18:09:46 [DEBUG] - pipewire: pw_loop created
2021/12/08 18:09:46 [DEBUG] - pipewire: establishing connection to core
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_compositor  (Version: 4)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_drm  (Version: 2)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_shm  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: |-- registered to interface wl_shm (Version 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_output  (Version: 2)
2021/12/08 18:09:46 [DEBUG] - wlroots: |-- registered to interface wl_output (Version 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zxdg_output_manager_v1  (Version: 3)
2021/12/08 18:09:46 [DEBUG] - wlroots: |-- registered to interface zxdg_output_manager_v1 (Version 3)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_data_device_manager  (Version: 3)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_primary_selection_device_manager_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register gtk_primary_selection_device_manager  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_subcompositor  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register xdg_wm_base  (Version: 3)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zxdg_shell_v6  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_shell  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register gtk_shell1  (Version: 5)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wp_viewporter  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_pointer_gestures_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_tablet_manager_v2  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wl_seat  (Version: 5)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_relative_pointer_manager_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_pointer_constraints_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zxdg_exporter_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zxdg_importer_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_linux_dmabuf_v1  (Version: 3)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_keyboard_shortcuts_inhibit_manager_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register zwp_text_input_manager_v3  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register gtk_text_input_manager  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register wp_presentation  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wlroots: interface to register xdg_activation_v1  (Version: 1)
2021/12/08 18:09:46 [DEBUG] - wayland: registry listeners run
2021/12/08 18:09:46 [DEBUG] - wayland: xdg output listeners run
2021/12/08 18:09:46 [ERROR] - Compositor doesn't support zwlr_screencopy_manager_v1!
2021/12/08 18:09:46 [DEBUG] - pipewire: disconnecting fom core
2021/12/08 18:09:46 [ERROR] - xdpw: failed to initialize screencast
emersion commented 2 years ago

xdg-desktop-portal-wlr can only be used on some wlroots compositors which implement this extension. It should not be used on other compositors like GNOME or KDE.

develroo commented 2 years ago

Hmmm I see. Well I am just trying to narrow down why suddenly screen capture recording is not working and am back tracking the steps. To be honest xdg-desktop-portal-wlr was not installed by default but I was getting warnings in xdg-desktop-portal which seemed related to screen capture as well.

I will try and investigate other avenues.

Thanks

gustawdaniel commented 1 year ago

I have similar problem:

➜ systemctl --user status wireplumber
Unit wireplumber.service could not be found.

~ …
➜ systemctl --user status pipewire
● pipewire.service - PipeWire Multimedia Service
     Loaded: loaded (/usr/lib/systemd/user/pipewire.service; disabled; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/user/pipewire.service.d
             └─00-uresourced.conf
     Active: active (running) since Fri 2023-01-20 15:34:59 CET; 32min ago
TriggeredBy: ● pipewire.socket
   Main PID: 5089 (pipewire)
      Tasks: 2 (limit: 76757)
     Memory: 4.5M
        CPU: 25ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/pipewire.service
             └─ 5089 /usr/bin/pipewire

sty 20 15:34:59 fedora systemd[4015]: Started pipewire.service - PipeWire Multimedia Service.
sty 20 15:34:59 fedora pipewire[5089]: mod.rt: Can't find xdg-portal: (null)
sty 20 15:34:59 fedora pipewire[5089]: mod.rt: found session bus but no portal

kernel version:

uname -r
6.1.6-100.fc36.x86_64

system: Linux fedora with i3.

holooloo commented 1 year ago

I have the same situation:

pipewire[3008]: mod.rt: found session bus but no portal

6.2.0-20-generic Ubuntu 23.04 KDE

japhir commented 1 year ago

Actually on my end this somehow has started working correctly, i can now screenshare on Wayland from Firefox, teams, and zoom. This just have happened with package updates or at some point the pruning of packages that I do not use... But since many people seem to have similar issues I'm not sure whether to close this one or not.

Edit: one major change that I did was to remove the gnome shell that I was not using anyway. Before I thought it was useful for things like nautilus, their pdf reader (evince?), and network manager, but now I just have only those packages and got rid of the shell.