Bug 448944

Summary: xdg-desktop-portal only shows a black screen when trying to screenshare a whole screen in Wayland with Pipewire (NVIDIA GBM)
Product: [Plasma] kwin Reporter: JesusXD88 <diegobere32>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Severity: major CC: aleixpol, bugs.kde.org, eva, james, jgrulich, nate, nicolas.fella, postix, sampingu02, supgesu, theivorytower
Priority: NOR Keywords: wayland
Version: 5.23.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screensharing a whole screen only shows a black screen
OBS Studio log file

Description JesusXD88 2022-01-22 12:43:14 UTC
Created attachment 145744 [details]
Screensharing a whole screen only shows a black screen

Trying to screenshare/screenrecord a whole screen on Wayland only shows a black screen with the cursor inside it. When selecting a single application the window shows fine in the stream, but the cursor isn't shown. xdg-desktop-portal-kde seems to be running according to System monitor.

1. Open any screenshare/screenrecord application like Firefox, OBS Studio or even the xdg-desktop-portal-kde testing utility (https://invent.kde.org/libraries/xdg-portal-test-kde).
2. Choose to screenshare/screenrecord a whole screen or single window.
3. Select a screen or single window in the xdg-desktop-portal-kde dialog.

Black screen with only a cursor when screensharing a whole screen, and the window content when screensharing a single window but whith no cursor. Below are attached some screenshots

When selecting a whole screen the whole screen should be seen in the stream (or in the screencapture app like OBS Studio) with the cursor and when selecting a single window that window should be seen in the stream o app with the cursor.

Operating System: Arch Linux
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.1-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 12 × Intel® Core™ i7-8750H CPU @ 2.20GHz
Memory: 15.5 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 2060/PCIe/SSE2
NVIDIA Driver Version: 495.46

On GNOME scrensharing on Wayland with xdg-desktop-portal-gnome works fine when sharing a whole screen or a single window, with cursor being captured in both cases.
Comment 1 Amine Hassane 2022-01-24 15:30:10 UTC
The error occurs here: https://invent.kde.org/plasma/kwin/-/blob/c31288d2ad570d69bfa49268e7fb282169f24542/src/plugins/platforms/drm/egl_gbm_backend.cpp#L713

Kwin logs "kwin_wayland_drm: Failed to record frame: Error creating EGLImageKHR -  12300 " after switching glGetError() to eglGetError(), which is EGL_BAD_PARAMETER. Already tried using EGL_NO_CONTEXT like it suggests in the spec for EGL_NATIVE_PIXMAP_KHR but still see the same error.
Comment 2 Samuel 2022-01-31 16:33:47 UTC
Created attachment 146100 [details]
OBS Studio log file

Can confirm. Occurs in my computer too in Arch Linux with NVIDIA.
Comment 3 Elias 2022-02-10 21:49:53 UTC
This is still broken with new Plasma 5.24.0 update and Nvidia drivers v510.47.03 :/
Comment 4 Elias 2022-03-25 19:57:06 UTC
Lately (or only in my case?) this is not KDE specific. I tested on Gnome on Fedora 36. Screencapture is also black there.
Comment 5 Samuel 2022-04-04 17:55:17 UTC
(In reply to Elias from comment #4)
> Lately (or only in my case?) this is not KDE specific. I tested on Gnome on
> Fedora 36. Screencapture is also black there.

Yup it's affecting all DEs.
Comment 6 Nicolas Fella 2022-04-08 16:27:24 UTC

*** This bug has been marked as a duplicate of bug 448839 ***