Bug 476602 - Gstreamer's pipewiresrc capturing from XDG screencast portal produces a black screen on Wayland
Summary: Gstreamer's pipewiresrc capturing from XDG screencast portal produces a black...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.8
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 477130 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-11-05 20:39 UTC by kde
Modified: 2024-01-16 22:26 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test python script that shows either the capture screen (works) or black window (doesn't work) (3.66 KB, text/x-python)
2023-11-05 20:39 UTC, kde
Details
The issue still occuring on plasma 5.27.10 (97.96 KB, image/png)
2023-12-23 10:28 UTC, kodatarule
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kde 2023-11-05 20:39:27 UTC
Created attachment 162886 [details]
Test python script that shows either the capture screen (works) or black window (doesn't work)

SUMMARY
Getting the `streamID` & `filedescriptor` parameters from the org.freedesktop.portal.ScreenCast portal and then using a gstreamer pipeline with `pipelinesrc` and the aforementioned `streamID` & `filedescriptor` parameters produces a black screen instead of the contents the stream should be capturing.

Why I think it is a KDE Plasma issue: I am running an atomic distribution (rpm-ostree based), rebased on Gnome, and the test script works. Everything else besides the DE is the same.


STEPS TO REPRODUCE
1. Run test script via `python3 xdp-screen-cast.py`
2. Select which screen/window to share in the Screen share popup 
3. Observe the demo window which has opened

OBSERVED RESULT
Demo window shows all-black

EXPECTED RESULT
Demo window shows the contents of the capture

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.11

Using NVIDIA GPU, but like I said, the same works on Gnome.
Comment 1 dannkunt 2023-11-08 17:35:51 UTC
Related to

https://github.com/NVIDIA/open-gpu-kernel-modules/issues/467
Comment 2 kde 2023-11-09 16:50:18 UTC
Update: the black demo window only happens when screencasting a screen. It does not happen when screencasting a window.
Both work on gnome though.
Comment 3 dannkunt 2023-11-11 16:43:35 UTC
Try in telegram desktop.  It always black canvas with cursor
Comment 4 David Edmundson 2023-11-11 22:11:21 UTC
Can you confirm other streaming mechanisms, such as:
 - spectacle
 - taskmanager thumbnails
 -  visiting this site in Firefox: https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/
Comment 5 kde 2023-11-12 01:19:00 UTC
(In reply to David Edmundson from comment #4)
> Can you confirm other streaming mechanisms, such as:
>  - spectacle
>  - taskmanager thumbnails
>  -  visiting this site in Firefox:
> https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/

webrtc link in firefox: sharing a window works, but sharing a screen produces an all black canvas, only the mouse pointer showing. (Both work well in gnome)
taskmanager thumbnails: flaky, most of the time they don't show up at first, but retrying hovering a few times makes them appear
spectacle: recording a window and a screen both work well
Comment 6 Zamundaaa 2023-11-18 16:37:20 UTC
*** Bug 477130 has been marked as a duplicate of this bug. ***
Comment 7 dannkunt 2023-11-29 08:15:05 UTC
Fixed in plasma 6 or in plasma 5.27.10?
Comment 8 Alessandro Astone 2023-11-29 14:26:03 UTC
(In reply to dannkunt from comment #7)
> Fixed in plasma 6 or in plasma 5.27.10?

5.27.10, as mentioned in the bug metadata
Also simultaneously fixed in an upcoming nvidia driver bugfix release
Comment 9 kde 2023-12-02 16:40:49 UTC
It looks like it was fixed in the 545 nvidia driver too, since the reproducer script now works correctly in Plasma 5.27.9.

Using the wayland session, nvidia driver 545.29.06, released 2023.11.22.

I guess it really was a simple fix for them and the report to upstream got it going!

Since it was fixed in the driver, this comment can now be acted upon - https://invent.kde.org/plasma/kwin/-/blob/f555c3301e22570f5fb211705f6d95073cd521f8/src/plugins/screencast/screencastutils.h#L63
Comment 10 kodatarule 2023-12-15 16:52:15 UTC
Just a quick question, will the fix also be in plasma 6 beta 2 ?
Comment 11 Alessandro Astone 2023-12-15 18:31:03 UTC
(In reply to kodatarule from comment #10)
> Just a quick question, will the fix also be in plasma 6 beta 2 ?

It is already in beta 1.
But there are new issues with screen sharing: https://bugs.kde.org/show_bug.cgi?id=478309
Comment 12 kodatarule 2023-12-23 10:28:26 UTC
Created attachment 164399 [details]
The issue still occuring on plasma 5.27.10

Additionally it also crashes OBS Studio

Operating System: EndeavourOS 
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.113.0
Qt Version: 5.15.11
Kernel Version: 6.6.8-x64v3-xanmod1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X3D 8-Core Processor
Memory: 31,3 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3090/PCIe/SSE2
Comment 13 kodatarule 2023-12-23 21:17:30 UTC
Apologies, I've had some more time to debug and turns out the explicit sync patches break pipewire on 5.27.10, thank you