emersion / xdg-desktop-portal-wlr

xdg-desktop-portal backend for wlroots
MIT License
580 stars 54 forks source link

Can screenshare with OBS, but Firefox and Chrome shares a black screen #250

Closed ghost closed 1 year ago

ghost commented 1 year ago

Used distribution: Arch Linux

Used version/commit of xdpw (+ connected PR):

❯ pacman -Q xdg-desktop-portal-wlr
xdg-desktop-portal-wlr-git v0.6.0.r4.g0a8bfa1-1

Installed GPU's (Vendor + Model):

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile] [10de:1c20] (rev a1)
    Subsystem: Acer Incorporated [ALI] Device [1025:1265]
    Kernel driver in use: nvidia

Used configuration_file (especially if force_mod_linear is used):

[screencast]
output_name=HDMI-A-1
exec_before=notify-send "Screencasting 4"
force_mod_linear=0
chooser_type=none

Changing to force_mod_linear=1 doesn't fix the issue

Used client and version which displays the corrupt image: Firefox 107, Chromium Version 107.0.5304.121 (Official Build) Arch Linux (64-bit)

Is the image still corrupt on OBS 27.2.4 or later:

No. OBS works fine

Anything special with your setup

I'm using this patch by installing hyprland-nvidia-git.

This is the desktop file that starts my session:

[Desktop Entry] Name=Hyprland (W) (NV) Comment=An intelligent dynamic tiling Wayland compositor 
Exec=[MYHOME]/.local/bin/wrappedhlnv 
Type=Application

With wrappedhlnv being:

#!/usr/bin/env bash

cd ~

export _JAVA_AWT_WM_NONREPARENTING=1
export XCURSOR_SIZE=24

# env for NVIDIA
# see: https://wiki.hyprland.org/Nvidia/
export LIBVA_DRIVER_NAME=nvidia
export XDG_SESSION_TYPE=wayland
export GBM_BACKEND=nvidia-drm
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export WLR_NO_HARDWARE_CURSORS=1

# use only external monitor
# see: https://wiki.hyprland.org/FAQ/#my-external-monitor-is-blank--doesnt-render--receives-no-signal-laptop
#export WLR_DRM_DEVICES=/dev/dri/card1
export WLR_DRM_DEVICES=/dev/dri/card0

exec Hyprland

I use Hyprland. I have the NVIDIA proprietary drivers and I'm starting Hyprland as their wiki tells me to start it in case of NVIDIA proprietary drivers, with all the environmental variables set. I also have a laptop with an external monitor, and so, in order to use only the external monitor, I defined WLR_DRM_DEVICES as specified here.

I can share the screen with OBS Studio, but not with Firefox nor Chromium. They share a completely black screen.

I went through the Hyprland screensharing wiki page, the gist by PowerBall253, and the official xdg-desktop-portal-wlr troubleshooting guide. All looks nice. Every settings is how it should be.

Except that the official troubleshooting guide says that Firefox and Chromium point to Pipewire 0.2 while I have Pipewire 0.3. Could this be it? They say I have to install a "Pipewire compat library", but I cannot find it in the Arch repos.

Also, I used mozregress to try and regress it. The problem is that my issue is not exactly reproducible. With the Firefox version of 1 year ago, all looks fine, and the screen is shared correctly. With the firefox version of today, using Jitsi I can see my screen correctly, BUT the person at the other end sees a black screen (I tried to connect with a tablet). With the firefox version from the Arch repos, I cannot even see my screen correctly, I see a black screen as well.

ghost commented 1 year ago

/usr/lib/xdg-desktop-portal -v

XDP: load portals from /usr/share/xdg-desktop-portal/portals
XDP: loading /usr/share/xdg-desktop-portal/portals/gnome-shell.portal
XDP: portal implementation for gnome
XDP: portal implementation supports org.freedesktop.impl.portal.Access
XDP: loading /usr/share/xdg-desktop-portal/portals/gnome-keyring.portal
XDP: portal implementation for gnome
XDP: portal implementation supports org.freedesktop.impl.portal.Secret
XDP: loading /usr/share/xdg-desktop-portal/portals/wlr.portal
XDP: portal implementation for wlroots, sway, Wayfire, river, phosh, Hyprland
XDP: portal implementation supports org.freedesktop.impl.portal.Screenshot
XDP: portal implementation supports org.freedesktop.impl.portal.ScreenCast
XDP: providing portal org.freedesktop.portal.MemoryMonitor
XDP: providing portal org.freedesktop.portal.PowerProfileMonitor
XDP: providing portal org.freedesktop.portal.NetworkMonitor
XDP: providing portal org.freedesktop.portal.ProxyResolver
XDP: providing portal org.freedesktop.portal.Trash
XDP: providing portal org.freedesktop.portal.GameMode
XDP: providing portal org.freedesktop.portal.Realtime

(/usr/lib/xdg-desktop-portal:40698): xdg-desktop-portal-WARNING **: 20:50:35.267: No skeleton to export
XDP: Falling back to gnome-shell.portal for org.freedesktop.impl.portal.Access
XDP: Using wlr.portal for org.freedesktop.impl.portal.Screenshot in Hyprland
XDP: providing portal org.freedesktop.portal.Screenshot
XDP: providing portal org.freedesktop.portal.Device
XDP: providing portal org.freedesktop.portal.Location
XDP: providing portal org.freedesktop.portal.Camera
XDP: Falling back to gnome-keyring.portal for org.freedesktop.impl.portal.Secret
XDP: providing portal org.freedesktop.portal.Secret
XDP: Using wlr.portal for org.freedesktop.impl.portal.ScreenCast in Hyprland
XDP: providing portal org.freedesktop.portal.ScreenCast

/usr/lib/xdg-desktop-portal-wlr -r -l TRACE

While doing screensharing:

log.log

ghost commented 1 year ago

Mozilla Firefox 106.0.1 is able to share the screen.

Mozilla Firefox 106.0.2 is not.

ghost commented 1 year ago

I went to Mozilla Firefox mercurial repo, but couldn't find commits about screencasting from 106.0.1 to 106.0.2.

Then I see that Arch has added a patch that has to do with screencasting in 106.0.2, which was apparently not there in 106.0.1.

See here.

Could this be it?

columbarius commented 1 year ago

Logs look fine. Maybe you could try version 107 which works for me. Another idea would be to test the flatpak, which is officially released by mozilla without community patches.

ghost commented 1 year ago

The AppImage of Firefox v. 109 works fine (it has the new version of libwebrtc, apparently).

Also installing version 106.0.1 of Firefox from the official Arch repo (using the downgrading utility, in order to avoid the patch introduced with 106.0.2), make screensharing working again.

So, as Firefox is concerned, I really think it's that patch introduced by the Arch team. But I still have to compile Firefox without it.

Now the question is why Chromium doesn't work as well :(

smlx commented 1 year ago

The chrome flatpak works here, could you try that to see if it works for you?

ghost commented 1 year ago

The chrome flatpak? So Google Chrome?

ghost commented 1 year ago

Here I am! Rock you like an hurricane :)

The chrome flatpak works here, could you try that to see if it works for you?

The flatpak of Google Chrome doesn't work. It shares a black screen, although the mouse moves around (but only on half of the shared screen).

The flatpak of Google Chrome (unstable) allows me to share browser tabs, but not the entire desktop.

konradreiche commented 1 year ago

@875d Have you checked this section in the troubleshoot guide?

Does the screencast starts, but the recording stays black or receives no image?

Clients might not support the same format. Please run https://gist.github.com/columbarius/50239ea3c4c70df8f240aa50f88e801a and check if entries with "type": "PipeWire:Interface:Port" have the property .params.Format and if not check if .params.EnumFormat contains an entry > compatible with the corresponding block from xdpw.

Please add the output of the script when opening an issue.

ghost commented 1 year ago

@875d Have you checked this section in the troubleshoot guide?

Does the screencast starts, but the recording stays black or receives no image? Clients might not support the same format. Please run https://gist.github.com/columbarius/50239ea3c4c70df8f240aa50f88e801a and check if entries with "type": "PipeWire:Interface:Port" have the property .params.Format and if not check if .params.EnumFormat contains an entry > compatible with the corresponding block from xdpw. Please add the output of the script when opening an issue.

Yes.

The output of the script is as follows:

~/Download 
❯ ./debug-pipewire-screencast.sh

~/Download 
❯ 
Geigerkind commented 1 year ago

Can confirm. Firefox 106.0.1 screen sharing works. Later versions dont work anymore. Also current versions of chromium (electron packaged apps like teams/discord) also dont work.

The above mentioned script returns the same for me. I have a similar setup to OP's (except using sway and not using the mentioned patch).

When using my integrated gpu (which is not connected to my monitor outputs unfortunately) screen sharing works on all current browsers (and tools). Sadly, this is not an option for me :(

Edit: Tried firefox-beta (108.0) (https://aur.archlinux.org/packages/firefox-beta-bin) there I dont even get a black screeen.

ghost commented 1 year ago

I'm going to close this issue since I don't have problems anymore with latest versions of Firefox and Chrome

Geigerkind commented 1 year ago

Can't confirm with the latest versions of 108. Still getting just black screens. Which versions do you use?

ghost commented 1 year ago

Can't confirm with the latest versions of 108. Still getting just black screens. Which versions do you use?

Are you talking about Firefox or Chrome?

They have similar versions now (latest Firefox I believe is 109, latest chrome 110)

Geigerkind commented 1 year ago

Yes. To my knowledge both are at 108 currently. With chrome do you mean google chrome? That one seems to be at 110. I will try out the dev branches later. Thanks :)

ghost commented 1 year ago

Firefox nightly is at 109, which, AFAIK, builds against the more recent version of libwebrtc which includes fixes for DMA-BUF. You can find the AppImage here.

By chrome I mean chromium, which you can download here.

If it still doesn't work, is a different issue than mine and you should open a new issue which your new logs.

Geigerkind commented 1 year ago

Wow, yes. This version seems to work. Cant wait that it will be distributed via the official arch repos! Thanks a lot!

Geigerkind commented 1 year ago

Tried it with the newest chrome version but I only managed to crash it due to double selection. Have you faced this issue?