xdg-desktop-portal-hyprland: OBS window sharing not working

First of all thank you for Hyprland!

I have an issue sharing windows in OBS. When I try to share window in OBS I get only black screen. The program logs error:

'loop->recurse > 0' failed at ../pipewire/src/pipewire/thread-loop.c:417 pw_thread_loop_wait()
info: [pipewire] Stream 0x564e0a695e10 state: "unconnected" (error: none)
info: PipeWire initialized
info: [pipewire] Screencast session created
info: [pipewire] Asking for desktop
info: [pipewire] desktop selected, setting up screencast
info: [pipewire] Server version: 0.3.70
info: [pipewire] Library version: 0.3.70
info: [pipewire] Header version: 0.3.70
info: [pipewire] Created stream 0x564e0a695e10
info: [pipewire] Stream 0x564e0a695e10 state: "connecting" (error: none)
info: [pipewire] Playing stream 0x564e0a695e10
info: [pipewire] Stream 0x564e0a695e10 state: "paused" (error: none)
info: [pipewire] Stream 0x564e0a695e10 state: "error" (error: no more input formats)
error: [pipewire] Error id:2 seq:8 res:-32 (Unknown error -32): no more input formats

I killed killall xdg-desktop-portal xdg-desktop-portal-hyprland and started /usr/lib/xdg-desktop-portal-hyprland -l DEBUG I checked /usr/lib/xdg-desktop-portal-hyprland -l DEBUG:

2023/05/14 14:08:08 [DEBUG] - hyprland: toplevel handle created 55aab89a0000
2023/05/14 14:08:08 [DEBUG] - hyprland: toplevel app_id com.obsproject.Studio
2023/05/14 14:08:09 [INFO] - dbus: create session method invoked
2023/05/14 14:08:09 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_90/obs13
2023/05/14 14:08:09 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_90/obs5
2023/05/14 14:08:09 [INFO] - dbus: app_id: 
2023/05/14 14:08:09 [INFO] - dbus: select sources method invoked
2023/05/14 14:08:09 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_90/obs14
2023/05/14 14:08:09 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_90/obs5
2023/05/14 14:08:09 [INFO] - dbus: app_id: 
2023/05/14 14:08:09 [INFO] - dbus: option types:1
2023/05/14 14:08:09 [INFO] - dbus: option multiple: 0
2023/05/14 14:08:09 [INFO] - dbus: option cursor_mode:2
2023/05/14 14:08:09 [INFO] - dbus: persist 2
2023/05/14 14:08:09 [DEBUG] - dbus: select sources: found matching session /org/freedesktop/portal/desktop/session/1_90/obs5
2023/05/14 14:08:09 [INFO] - wlroots: capturable output: DZX model: Z1: id: 50 name: HDMI-A-1
2023/05/14 14:08:09 [DEBUG] - Screencast: Picker: Running command "WAYLAND_DISPLAY=wayland-1 QT_QPA_PLATFORM="wayland" XCURSOR_SIZE=24 HYPRLAND_INSTANCE_SIGNATURE=f27873a6f06dc2f87600edb890f3c38298bfb55f_1684083312 XDPH_WINDOW_SHARING_LIST="3097100288[HC>]com.obsproject.Studio[HT>]Properties for  Screen Capture (PipeWire) [HE>]3095601824[HC>]LibreWolf[HT>]New Issue · hyprwm/xdg-desktop-portal-hyprland — LibreWolf[HE>]3095601392[HC>]foot[HT>]obs[HE>]3095601040[HC>]com.obsproject.Studio[HT>]OBS 29.1.1-1 - Profile: Untitled - Scenes: Untitled[HE>]3095600688[HC>]foot[HT>]/usr/lib/xdg-desktop-portal[HE>]3095600336[HC>]foot[HT>]/usr/lib/xdg-desktop-portal-hyprland[HE>]" hyprland-share-picker"
2023/05/14 14:08:15 [DEBUG] - Screencast: Attempting to find window for window:-1199365472

2023/05/14 14:08:15 [INFO] - xdpw: screencast instance 0x55aab89a2180 has 1 references
2023/05/14 14:08:15 [INFO] - xdpw: 2 active screencast instances
2023/05/14 14:08:15 [INFO] - hyprland: window handle -1199365472
2023/05/14 14:08:15 [INFO] - dbus: session closed
2023/05/14 14:08:15 [DEBUG] - dbus: destroying session 0x55aab8998500
2023/05/14 14:08:15 [DEBUG] - xdpw: screencast instance 0x55aab899b0f0 now has 0 references
2023/05/14 14:08:15 [DEBUG] - xdpw: destroying cast instance
2023/05/14 14:08:15 [DEBUG] - pipewire: destroying stream
2023/05/14 14:08:15 [INFO] - pipewire: stream state changed to "unconnected"
2023/05/14 14:08:15 [INFO] - pipewire: node id is -1
2023/05/14 14:08:15 [DEBUG] - hyprland: toplevel handle created 55aab8999d50
2023/05/14 14:08:15 [DEBUG] - hyprland: toplevel app_id hyprland-share-picker
2023/05/14 14:08:15 [DEBUG] - hyprland: toplevel closed hyprland-share-picker
2023/05/14 14:08:15 [INFO] - dbus: start method invoked
2023/05/14 14:08:15 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_90/obs15
2023/05/14 14:08:15 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_90/obs5
2023/05/14 14:08:15 [INFO] - dbus: app_id: 
2023/05/14 14:08:15 [INFO] - dbus: parent_window: 
2023/05/14 14:08:15 [DEBUG] - dbus: start: found matching session /org/freedesktop/portal/desktop/session/1_90/obs5
2023/05/14 14:08:15 [INFO] - wlroots: no modifiers available for format 0
2023/05/14 14:08:15 [INFO] - pipewire: stream state changed to "connecting"
2023/05/14 14:08:15 [INFO] - pipewire: node id is -1
2023/05/14 14:08:15 [INFO] - pipewire: stream state changed to "paused"
2023/05/14 14:08:15 [INFO] - pipewire: node id is 66
2023/05/14 14:08:15 [INFO] - xdph: registered restoreToken with token E2CA1774-21B3-4663-B49E-6E1BF34ADDC1
2023/05/14 14:08:15 [DEBUG] - dbus: start: returning node 66
2023/05/14 14:08:15 [INFO] - pipewire: stream state changed to "error"
2023/05/14 14:08:15 [INFO] - pipewire: node id is 66
2023/05/14 14:08:16 [DEBUG] - hyprland: toplevel closed com.obsproject.Studio

systemctl --user status xdg-desktop-portal-hyprland logs:

● xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-hyprland.service; static)
     Active: active (running) since Sun 2023-05-14 14:11:24 CST; 1min 3s ago
   Main PID: 19905 (xdg-desktop-por)
      Tasks: 6 (limit: 76108)
     Memory: 12.7M
        CPU: 374ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/xdg-desktop-portal-hyprland.service
             └─19905 /usr/lib/xdg-desktop-portal-hyprland

May 14 14:11:24 archlinuxtower systemd[838]: Starting Portal service (Hyprland implementation)...
May 14 14:11:24 archlinuxtower systemd[838]: Started Portal service (Hyprland implementation).

systemctl --user status wireplumber logs:

● wireplumber.service - Multimedia Service Session Manager
     Loaded: loaded (/usr/lib/systemd/user/wireplumber.service; enabled; preset: enabled)
     Active: active (running) since Sun 2023-05-14 10:55:12 CST; 3h 15min ago
   Main PID: 1296 (wireplumber)
      Tasks: 6 (limit: 76108)
     Memory: 38.7M
        CPU: 281ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/wireplumber.service
             └─1296 /usr/bin/wireplumber

May 14 13:50:06 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:50:12 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:50:20 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:50:24 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:50:35 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:50:47 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:51:48 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 13:52:12 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 14:02:26 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera
May 14 14:08:15 archlinuxtower wireplumber[1296]: <WpPortalPermissionStorePlugin:0x5645dfb8c7d0> Failed to call Lookup: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for camera

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 21 (4 by maintainers)

Most upvoted comments

So, I did some further digging.

As @xbb mentions, the program crashes due to cast->target.output being NULL when window sharing. I was able to get around this by commenting out that portion of the code (obviously an actual fix would be required, but this enables me to get further).

After doing that, it is no longer the program that crashes, but OBS itself. I saw that OBS was reporting the pipewire stream format as Spa:Enum:VideoFormat:RGBx, while output streaming was reported as Spa:Enum:VideoFormat:BGRx.

Changing these lines:

https://github.com/hyprwm/xdg-desktop-portal-hyprland/blob/4d9ff0c17716936e0b5ca577a39e263633901ed1/src/screencast/screencast_common.c#L331-L332

To return return SPA_VIDEO_FORMAT_BGRx no longer crashes OBS, but obviously the colors are now wrong as blue and red are flipped.

I’m 99% sure the code here is correct, and the issue might be with OBS not handling this format properly, but I’m far from knowledgeable enough here to make that call.

EDIT:

https://github.com/obsproject/obs-studio/issues/8925 might be related to this. It seems the latest xdg-desktop-portal-wlr version has fixed this issue. I can see that this repo is around 15 commits behind, so maybe a pull from upstream is in order…

I think I got it

https://github.com/hyprwm/xdg-desktop-portal-hyprland/blob/4d9ff0c17716936e0b5ca577a39e263633901ed1/src/screencast/pipewire_screencast.c#L458-L462

output is null when selecting a window, so the portal crashes at that point.

Can be fixed either by checking cast->target.output is not null (but it will not apply transforms, for example if your screen is rotated the captured window rotation is not adjusted), or setting the output in here, like for screen and region selections:

https://github.com/hyprwm/xdg-desktop-portal-hyprland/blob/4d9ff0c17716936e0b5ca577a39e263633901ed1/src/screencast/wlr_screencast.c#L744-L760

Though, I don’t know how to get the correct output from the window result, I think it needs to be sent from hyprland-share-picker like for region selection and I’m not sure if it breaks screencast session restore.

The problem is gone because you don’t use XDPH with Gnome, so why close this issue? You’re not alone, think about the others please ❤️

Same here, screen sharing works but window and region are just black screens.

hyprland 0.25.0
xdg-desktop-portal 1.16.0
xdg-desktop-portal-hyprland 0.3.1
pipewire 0.3.71
wireplumber 0.4.14
obs-studio 29.1.2

AMD Radeon RX 580. Monitor set to 8 bit and 10 bit, same result.

When launching XDPH with /usr/lib/xdg-desktop-portal-hyprland -l DEBUG and picking a window in OBS, XDPH crashes (region doesn’t but it’s black). Stack trace:

Stack trace of thread 14416:
#0  0x00005616f1656f80 n/a (xdg-desktop-portal-hyprland + 0x12f80)
#1  0x00005616f1657708 n/a (xdg-desktop-portal-hyprland + 0x13708)
#2  0x00007f6bc1dda8d2 n/a (libffi.so.8 + 0x78d2)
#3  0x00007f6bc1dd724f n/a (libffi.so.8 + 0x424f)
#4  0x00007f6bc1dd9e96 ffi_call (libffi.so.8 + 0x6e96)
#5  0x00007f6bc21dca23 n/a (libwayland-client.so.0 + 0x7a23)
#6  0x00007f6bc21dd203 n/a (libwayland-client.so.0 + 0x8203)
#7  0x00007f6bc21dd494 wl_display_dispatch_queue_pending (libwayland-client.so.0 + 0x8494)
#8  0x00005616f164b388 n/a (xdg-desktop-portal-hyprland + 0x7388)
#9  0x00007f6bc1e05bb0 __libc_start_call_main (libc.so.6 + 0x27bb0)
#10 0x00007f6bc1e05c79 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x27c79)
#11 0x00005616f164bad5 n/a (xdg-desktop-portal-hyprland + 0x7ad5)

Stack trace of thread 14417:
#0  0x00007f6bc1ef2fd6 epoll_wait (libc.so.6 + 0x114fd6)
#1  0x00007f6bc1a3a8b4 n/a (libspa-support.so + 0x158b4)
#2  0x00007f6bc1a2d4bd n/a (libspa-support.so + 0x84bd)
#3  0x00007f6bc2063a24 n/a (libpipewire-0.3.so.0 + 0x46a24)
#4  0x00007f6bc1e6bab4 start_thread (libc.so.6 + 0x8dab4)
#5  0x00007f6bc1ef2b60 __clone3 (libc.so.6 + 0x114b60)

Stack trace of thread 14418:
#0  0x00007f6bc1e6805e __futex_abstimed_wait_common (libc.so.6 + 0x8a05e)
#1  0x00007f6bc1e6ada0 pthread_cond_wait@@GLIBC_2.3.2 (libc.so.6 + 0x8cda0)
#2  0x00007f6bbf0c7bfb n/a (radeonsi_dri.so + 0xc7bfb)
#3  0x00007f6bbf10eb37 n/a (radeonsi_dri.so + 0x10eb37)
#4  0x00007f6bc1e6bab4 start_thread (libc.so.6 + 0x8dab4)
#5  0x00007f6bc1ef2b60 __clone3 (libc.so.6 + 0x114b60)

Stack trace of thread 14419:
#0  0x00007f6bc1e6805e __futex_abstimed_wait_common (libc.so.6 + 0x8a05e)
#1  0x00007f6bc1e6ada0 pthread_cond_wait@@GLIBC_2.3.2 (libc.so.6 + 0x8cda0)
#2  0x00007f6bbf0c7bfb n/a (radeonsi_dri.so + 0xc7bfb)
#3  0x00007f6bbf10eb37 n/a (radeonsi_dri.so + 0x10eb37)
#4  0x00007f6bc1e6bab4 start_thread (libc.so.6 + 0x8dab4)
#5  0x00007f6bc1ef2b60 __clone3 (libc.so.6 + 0x114b60)

Stack trace of thread 14421:
#0  0x00007f6bc1e6805e __futex_abstimed_wait_common (libc.so.6 + 0x8a05e)
#1  0x00007f6bc1e6ada0 pthread_cond_wait@@GLIBC_2.3.2 (libc.so.6 + 0x8cda0)
#2  0x00007f6bbf0c7bfb n/a (radeonsi_dri.so + 0xc7bfb)
#3  0x00007f6bbf10eb37 n/a (radeonsi_dri.so + 0x10eb37)
#4  0x00007f6bc1e6bab4 start_thread (libc.so.6 + 0x8dab4)
#5  0x00007f6bc1ef2b60 __clone3 (libc.so.6 + 0x114b60)

Stack trace of thread 14420:
#0  0x00007f6bc1e6805e __futex_abstimed_wait_common (libc.so.6 + 0x8a05e)
#1  0x00007f6bc1e6ada0 pthread_cond_wait@@GLIBC_2.3.2 (libc.so.6 + 0x8cda0)
#2  0x00007f6bbf0c7bfb n/a (radeonsi_dri.so + 0xc7bfb)
#3  0x00007f6bbf10eb37 n/a (radeonsi_dri.so + 0x10eb37)
#4  0x00007f6bc1e6bab4 start_thread (libc.so.6 + 0x8dab4)
#5  0x00007f6bc1ef2b60 __clone3 (libc.so.6 + 0x114b60)
ELF object binary architecture: AMD x86-64

I also noticed in the OBS Studio log that for screen and region, the pipewire negotiated format was Format: 8 (Spa:Enum:VideoFormat:BGRx) but for window it’s Format: 7 (Spa:Enum:VideoFormat:RGBx). I don’t know if it helps…

closing due to the v1.0 rewrite

downgrading OBS does not fix anything for me fyi, still negotiation errors.