hyprwm / xdg-desktop-portal-hyprland

xdg-desktop-portal backend for Hyprland
BSD 3-Clause "New" or "Revised" License
267 stars 45 forks source link

First screen share is working, subsequent shares show black screen #172

Open herrwusel opened 7 months ago

herrwusel commented 7 months ago

Similar to #148, I'm experiencing the behaviour that the first screen share is working and afterwards only a black screen is shown.

I built commit 4fc83e6 and started XDPH with -v:

[TRACE] [core] got poll event
[TRACE] [core] got poll event
[TRACE] [sc] hlOnBuffer for 0x6183b95d86c0
[TRACE] [sc] hlOnDmabuf for 0x6183b95d86c0
[TRACE] [sc] hlOnBufferDone for 0x6183b95d86c0
[TRACE] [sc] pw format 8 size 3804x2070
[TRACE] [sc] hl format 875709016 size 3804x2070
[TRACE] [sc] wlrOnBufferDone: dequeue, no current buffer
[TRACE] [pw] dequeue on 0x6183b95aa2b0
[TRACE] [pw] dequeue failed
[LOG] [screencopy/pipewire] Out of buffers
[TRACE] [pw] pwStreamParamChanged on 0x6183b95aa2b0
[TRACE] [pipewire] pw requested dmabuf
[TRACE] [pw] Format renegotiated:
[TRACE] [pw]  | buffer_type DMA
[TRACE] [pw]  | format: 8
[TRACE] [pw]  | modifier: 72057594037927938
[TRACE] [pw]  | size: 3804x2070
[TRACE] [pw]  | framerate 60
[TRACE] [core] got poll event
[TRACE] [core] got poll event
[TRACE] [core] got poll event
[TRACE] [core] got poll event
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95cebe8 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95cec18 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95cec48 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95cec78 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95ceca8 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95cecd8 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95ced08 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [pw] pwStreamAddBuffer with 0x6183b95ced38 on 0x6183b95aa2b0
[TRACE] [pw] createBuffer: type dma
[TRACE] [pw] buffer datas 1
[TRACE] [core] got poll event
[TRACE] [core] got poll event

If I cut too much from the logs, I can provide a full log.

mtwb47 commented 7 months ago

I don't have the logs yet, but I too have this issue with one of my monitors. Will record two of my three monitors, but the third one will not capture. Must restart the portal via systemctl to get it to work.

hyprland-portal version is the most recent one pulled from the git repository and built from source. Hyprland itself is version - 0.34.0-1.1

vaxerski commented 7 months ago

can't really test 3 monitors myself due to the lack of 3 monitors (I only have two) but sharing two at once seems to work for me.

Can I get a log from that? Is it also pw being out of buffers?

mtwb47 commented 7 months ago

Can I get a log from that? Is it also pw being out of buffers?

I'm a complete wayland noob, so can you point me towards where I can find them? Or should I look in the systemd logs? Also, not sure about the pw thing either. Again total noob.

herrwusel commented 7 months ago

For me, it is happening with two monitors: laptop and external. I searched for “pw being out of buffers” but I don't know what to do with it.

vaxerski commented 7 months ago

You can append -v to your xdph systemd service and then journalctl -u xdg-desktop-portal-hyprland > log.txt (worth noting you have to restart the service for the change to take effect, obviously)

Or you can use the nuclear script from the wiki and append -v to the xdph cmdline for verbose logs. Then, attach the result. https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/#usage

herrwusel commented 7 months ago

If you are referring to me, I did run xdgh by first using the nuclear script and then running from the command line (see first post).

It might be a problem with the Intel iGPU. I just got another laptop with an AMD iGPU and sharing just works(TM).

rurigk commented 7 months ago

I think i found how to reproduce (AMD gpu)

This error only happens if you turn off and on your monitor

Kill and then launch xdg-desktop-portal-hyprland -> turn off monitor -> turn on monitor -> try to screen cap that monitor If i restart xdg-desktop-portal-hyprland it gets fixed until monitor is turned off and on again

@herrwusel can you try if this triggers yor problem?

herrwusel commented 6 months ago

Kill and then launch xdg-desktop-portal-hyprland -> turn off monitor -> turn on monitor -> try to screen cap that monitor If i restart xdg-desktop-portal-hyprland it gets fixed until monitor is turned off and on again

I can't reproduce this on my current system.

malcolmrebughini commented 5 months ago

I used to have this issue with zoom, but now zoom will always show a black screen (reported here: #178 ). But the issue now happens with firefox too.

The first time it works, the second time the picker shows up but selecting anything won't start the share, and trying to share again does not even bring the picker dialog anymore. Killing the process and starting firefox resets the state and you can go through the same steps again.

[LOG] [screencopy]  | appid: 
[LOG] [screencopy] SelectSources:
[LOG] [screencopy]  | /org/freedesktop/portal/desktop/request/1_74/webrtc582008398
[LOG] [screencopy]  | /org/freedesktop/portal/desktop/session/1_74/webrtc_session552811761
[LOG] [screencopy]  | appid: 
[LOG] [screencopy] option persist_mode to 1
[LOG] [screencopy] unused option multiple
[LOG] [screencopy] unused option types
[LOG] [screencopy] restore data invalid / missing, prompting
[LOG] execAndGet: WAYLAND_DISPLAY=wayland-1 QT_QPA_PLATFORM="wayland" XCURSOR_SIZE=24 HYPRLAND_INSTANCE_SIGNATURE=c5e28ebcfe00a5
10922779b2c568cfa52a317445_1712073150 XDPH_WINDOW_SHARING_LIST="<REDACTED" hyprland-share-picker 2>&1
[LOG] [sc] Selection: /screen:DP-2

[LOG] [screencopy] SHAREDATA returned selection 0
[LOG] [screencopy] Start:
[LOG] [screencopy]  | /org/freedesktop/portal/desktop/request/1_74/webrtc1912163979
[LOG] [screencopy]  | /org/freedesktop/portal/desktop/session/1_74/webrtc_session552811761
[LOG] [screencopy]  | appid: 
[LOG] [screencopy]  | parent_window: 
[LOG] [pw] Building modifiers for dma
[LOG] [screencopy] Sharing initialized
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] [pipewire] Asked for a wl_shm buffer which is legacy.
[WARN] 
[pipewire] Asked for a wl_shm buffer which is legacy.
[LOG] [sc] Incompatible formats, renegotiate stream
[LOG] [pw] Building modifiers for dma
[LOG] [pw] Building modifiers for dma
[ERR] [screencopy] tried scheduling on already scheduled cb (type 0)

Systeminfo:

Hyprland, built from branch HEAD at commit c5e28ebcfe00a510922779b2c568cfa52a317445  (props: bump ver 0.37.1).
Date: Sat Mar 16 14:51:49 2024
Tag: v0.37.1

flags: (if any)

System Information:
System name: Linux
Node name: malcolm
Release: 6.8.2-arch2-1
Version: #1 SMP PREEMPT_DYNAMIC Thu, 28 Mar 2024 17:06:35 +0000

GPU information:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile] [10de:1c8c] (rev a1) (prog-if 00 [VGA controller])

os-release: NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo

plugins:
local/xdg-desktop-portal 1.18.2-1
    Desktop integration portals for sandboxed apps
local/xdg-desktop-portal-hyprland 1.3.1-6
    xdg-desktop-portal backend for hyprland
Salaron commented 3 months ago

I can reproduce the issue too with one of my monitors. After some debugging and reading logs, I noticed that when I select the monitor where screen capture is working, the required buffer type is SPA_DATA_MemFd. For the monitor that is not working (black screen), the buffer type is SPA_DATA_DmaBuf.

So, I hardcoded the buffer type to SPA_DATA_MemFd in the function pwStreamAddBuffer, and now screen capture works for all of my monitors. very hacky way

Also there is some logs for frame enqueue.

Frame enqueue with buffer type SPA_DATA_DmaBuf:

[TRACE] [pw] Enqueue data:
[TRACE] [pw]  | seq 0
[TRACE] [pw]  | pts 20549907886846
[TRACE] [pw]  | meta has damage
[TRACE] [pw]  | damage @ 0: 0 0 2560 1440
[TRACE] [pw]  | end damage @ 1: 0 0 0 0
[TRACE] [pw]  | size 2560x1440
[TRACE] [pw]  | plane 0
[TRACE] [pw]     | fd 31
[TRACE] [pw]     | maxsize 0
[TRACE] [pw]     | size 9
[TRACE] [pw]     | stride 10240
[TRACE] [pw]     | offset 0
[TRACE] [pw]     | flags 0
[TRACE] [pw] --------------------------------- End enqueue

Frame enqueue with buffer type SPA_DATA_MemFd:

[TRACE] [pw] Enqueue data:
[TRACE] [pw]  | seq 1
[TRACE] [pw]  | pts 21323287480221
[TRACE] [pw]  | meta has damage
[TRACE] [pw]  | damage @ 0: 0 0 2560 1600
[TRACE] [pw]  | damage @ 1: 0 0 2560 1600
[TRACE] [pw]  | end damage @ 2: 0 0 0 0
[TRACE] [pw]  | size 2560x1600
[TRACE] [pw]  | plane 0
[TRACE] [pw]     | fd 33
[TRACE] [pw]     | maxsize 16384000
[TRACE] [pw]     | size 16384000
[TRACE] [pw]     | stride 10240
[TRACE] [pw]     | offset 0
[TRACE] [pw]     | flags 0
[TRACE] [pw] --------------------------------- End enqueue

As you can notice, maxsize and size for dma has very small values compared to memfd.

Env: Fedora 40, Hyprland 0.41.0, XDPH 8f1ee9f964ef8820f44b6d13e49e187f10043050

vaxerski commented 3 months ago

MemFd is legacy and extremely slow compared to dma

Laobiz commented 3 months ago

Adding bitdepth,10 to my monitor config helped to remediate the issue. So full monitor config would look like this: monitor=HDMI-A-1,2560x1440@144.0,0x0,1.0,bitdepth,10

malcolmrebughini commented 3 months ago

Setting the bitdepth like @Laobiz suggested fixed the issue for me on zoom :thinking:

brighamdent commented 3 months ago

Great job @Laobiz I've had this issue for a while now. It worked like a charm! I just added the bitdepth to my monitor config.

Beyley commented 1 month ago

Even with bitdepth set to 10 i also get this issue with vesktop, but only on my ultrawide monitor, heres my full logs incase it has any extra info, everything works fine on plasma

[TRACE] [sc] wlrOnBuffer for 0x61c87bbc1c10
[TRACE] [sc] wlrOnDmabuf for 0x61c87bbc1c10
[TRACE] [sc] wlrOnBufferDone for 0x61c87bbc1c10
[TRACE] [sc] pw format 8 size 3440x1440
[TRACE] [sc] wlr format 875713112 size 3440x1440
[TRACE] [sc] wlr format dma 875713112 size 3440x1440
[TRACE] [sc] wlrOnBufferDone: dequeue, no current buffer
[TRACE] [pw] dequeue on 0x61c87bbfc2c0
[TRACE] [sc] wlr frame copied
[TRACE] [core] got poll event
[TRACE] [core] got poll event
[TRACE] [sc] wlrOnFlags for 0x61c87bbc1c10
[TRACE] [sc] wlrOnDamage for 0x61c87bbc1c10
[TRACE] [sc] wlr damage: 0 0 3440 1440
[TRACE] [sc] wlrOnReady for 0x61c87bbc1c10
[TRACE] [sc] frame timestamp sec: 55776 nsec: 469527796 combined: 55776469527796ns
[TRACE] [pw] enqueue on 0x61c87bbfc2c0
[TRACE] [pw] Enqueue data:
[TRACE] [pw]  | seq 2
[TRACE] [pw]  | pts 55776469527796
[TRACE] [pw]  | meta has damage
[TRACE] [pw]  | damage @ 0: 0 0 3440 1440
[TRACE] [pw]  | damage @ 1: 0 0 3440 1440
[TRACE] [pw]  | damage @ 2: 0 0 3440 1440
[TRACE] [pw]  | end damage @ 3: 0 0 0 0
[TRACE] [pw]  | size 3440x1440
[TRACE] [pw]  | plane 0
[TRACE] [pw]     | fd 30
[TRACE] [pw]     | maxsize 0
[TRACE] [pw]     | size 9
[TRACE] [pw]     | stride 13824
[TRACE] [pw]     | offset 0
[TRACE] [pw]     | flags 0
[TRACE] [pw] --------------------------------- End enqueue
[TRACE] [screencopy] set fps 60, frame took 12.01ms, ms till next refresh 4.66, estimated actual fps: 60.00
[TRACE] [core] adding timer for 6ms
[TRACE] [core] got poll event
[TRACE] [core] got timer event
[TRACE] [screencopy] frame callbacks initialized
[TRACE] [core] calling timer 0x61c87bcd7d80
[TRACE] [core] got poll event
[TRACE] [core] got poll event
[TRACE] [sc] wlrOnBuffer for 0x61c87bbc1c10
[TRACE] [sc] wlrOnDmabuf for 0x61c87bbc1c10
[TRACE] [sc] wlrOnBufferDone for 0x61c87bbc1c10
[TRACE] [sc] pw format 8 size 3440x1440
[TRACE] [sc] wlr format 875713112 size 3440x1440
[TRACE] [sc] wlr format dma 875713112 size 3440x1440
[TRACE] [sc] wlrOnBufferDone: dequeue, no current buffer
[TRACE] [pw] dequeue on 0x61c87bbfc2c0
[TRACE] [pw] dequeue failed
[LOG] [screencopy/pipewire] Out of buffers

my monitor info is provided here:

Monitor DP-4 (ID 0):
    3440x1440@164.99899 at 1920x120
    description: Samsung Electric Company LC34G55T H4ZT800669
    make: Samsung Electric Company
    model: LC34G55T
    serial: H4ZT800669
    active workspace: 2 (2)
    special workspace: 0 ()
    reserved: 0 30 0 0
    scale: 1.00
    transform: 0
    focused: yes
    dpmsStatus: 1
    vrr: 0
    activelyTearing: false
    disabled: false
    currentFormat: XRGB8888
    availableModes: 3440x1440@165.00Hz 3440x1440@99.98Hz 3440x1440@59.97Hz 2560x1440@165.00Hz 2560x1440@99.95Hz 2560x1440@59.95Hz 1920x1200@165.00Hz 1920x1080@165.00Hz 1920x1080@100.00Hz 1920x1080@60.00Hz 1920x1080@60.00Hz 1920x1080@59.94Hz 1920x1080@50.00Hz 1600x1200@165.00Hz 1680x1050@59.95Hz 1600x900@60.00Hz 1280x1024@75.03Hz 1280x1024@60.02Hz 1440x900@59.89Hz 1280x800@59.81Hz 1152x864@75.00Hz 1280x720@60.00Hz 1280x720@60.00Hz 1280x720@59.94Hz 1280x720@50.00Hz 1024x768@75.03Hz 1024x768@70.07Hz 1024x768@60.00Hz 832x624@74.55Hz 800x600@75.00Hz 800x600@72.19Hz 800x600@60.32Hz 800x600@56.25Hz 720x576@50.00Hz 720x480@60.00Hz 720x480@59.94Hz 640x480@75.00Hz 640x480@72.81Hz 640x480@66.67Hz 640x480@60.00Hz 640x480@59.94Hz 720x400@70.08Hz 

Monitor DP-5 (ID 1):
    1280x1024@75.02500 at 5360x120
    description: Dell Inc. DEL 1708FPBLK X876H92M1JRS
    make: Dell Inc.
    model: DEL 1708FPBLK
    serial: X876H92M1JRS
    active workspace: 11 (11)
    special workspace: 0 ()
    reserved: 0 0 0 0
    scale: 1.00
    transform: 1
    focused: no
    dpmsStatus: 1
    vrr: 0
    activelyTearing: false
    disabled: false
    currentFormat: XRGB8888
    availableModes: 1280x1024@60.02Hz 1280x1024@75.03Hz 1280x800@60.02Hz 1152x864@75.00Hz 1280x720@60.02Hz 1024x768@75.03Hz 1024x768@60.00Hz 800x600@75.00Hz 800x600@60.32Hz 640x480@75.00Hz 640x480@59.94Hz 720x400@70.08Hz 

Monitor HDMI-A-5 (ID 2):
    1920x1080@60.00000 at 0x0
    description: Samsung Electric Company SAMSUNG
    make: Samsung Electric Company
    model: SAMSUNG
    serial: 
    active workspace: 21 (21)
    special workspace: 0 ()
    reserved: 0 0 0 0
    scale: 1.00
    transform: 0
    focused: no
    dpmsStatus: 1
    vrr: 0
    activelyTearing: false
    disabled: false
    currentFormat: XRGB8888
    availableModes: 1920x1080@60.00Hz 1920x1080@60.00Hz 1920x1080@59.94Hz 1920x1080@30.00Hz 1920x1080@29.97Hz 1920x1080@24.00Hz 1920x1080@23.98Hz 1600x1200@60.00Hz 1680x1050@59.88Hz 1280x1024@75.03Hz 1280x1024@60.02Hz 1440x900@74.98Hz 1440x900@59.90Hz 1280x960@60.00Hz 1360x768@60.02Hz 1280x800@59.91Hz 1152x864@75.00Hz 1280x720@60.00Hz 1280x720@60.00Hz 1280x720@59.94Hz 1024x768@75.03Hz 1024x768@70.07Hz 1024x768@60.00Hz 832x624@74.55Hz 800x600@75.00Hz 800x600@72.19Hz 800x600@60.32Hz 720x480@60.00Hz 720x480@60.00Hz 720x480@59.94Hz 720x480@59.94Hz 640x480@75.00Hz 640x480@72.81Hz 640x480@66.67Hz 640x480@60.00Hz 640x480@59.94Hz 720x400@70.08Hz 

xdph: 5555f467 hyprland: 57371b93 arch linux

maakiono commented 1 month ago

this might be related to #245, i have the same issue on my intel system running gui-libs/xdg-desktop-portal-hyprland-1.3.3-r2 gentoo system

Bill-Klay commented 3 weeks ago

I set the bitdepth to 10 and then it worked. After some time I had to disconnect my laptop from the external monitor and when working solely on my laptop I like to keep the scale to 1.33. Soon after connecting back to the external monitor and setting the scale back to 1.00 and bitdepth to 10 I'm back to this issue persisting. I apparently get the following log: [LOG] [screencopy/pipewire] Out of buffers

For the time being everytime I need to share my screen I run the nuclear script after disconnecting any screencopy required tab like Meet and then re-connect to share my screen. I'm still figuring it out though.