Created attachment 138714 [details] Session log with custom debug output SUMMARY 9 out of 10 times the plasma desktop background and latte are not rendered at all in a wayland session on my computer with NVIDIA proprietary driver. Instead of seeing the expected desktop background with icons and the latte dock, only black background is visible. Context menus, etc. of the desktop and latte dock work perfectly. Application windows are rendered correctly. When observing this behavior, the wayland-session.log contains many messages saying: kwin_wayland_drm: Failed to acquire EGL stream frame These messages are not logged in the rare case that plasma desktop background and latte dock are visible in a wayland session. The behavior is stable for a complete session, i.e., if a session starts without desktop/latte visible, it stays that way the complete session. INITIAL ANALYSIS Added additional debug output in egl_stream_backend.cpp: kwin_wayland_drm: Failed to acquire EGL stream frame (rc= 12290 ) The return code 12290 corresponds to EGL_BAD_ACCESS. The documentation of the function "eglStreamConsumerAcquireAttribNV/eglStreamConsumerAcquireKHR" says: - EGL_BAD_ACCESS is generated if there is no GL context current to the calling thread, or if the GL context current to the calling thread does not contain a texture that is connected as the consumer of the EGLStream. Here is an excerpt of the debug messages I added for the texture/stream handling: kwin_wayland_drm: (tid= 30525 , ctx= 0x5611b6d51011 ) Attach stream consumer for 30568 ( "/home/simon/kde/usr/bin/plasmashell" ) kwin_wayland_drm: (tid= 30525 , ctx= 0x5611b6d51011 ) Bind texture 40 of stream consumer for 30568 ( "/home/simon/kde/usr/bin/plasmashell" ) [...] kwin_wayland_drm: (tid= 30525 , ctx= 0x5611b5f84691 ) Create texture 40 for 30568 ( "/home/simon/kde/usr/bin/plasmashell" ) kwin_wayland_drm: Failed to acquire EGL stream frame (rc= 12290 ) ctx=xxx is the pointer to GL context. The first two debug messages are added to EglStreamBackend::attachStreamConsumer and the third message in EglStreamSurfaceTextureWayland::create(). It looks like the texture is bound in a different GL context then the acquire is performed later on which would explain the error code. No idea why the contexts are different. SOFTWARE/OS VERSIONS Linux/KDE Plasma: (available in About System) KDE Plasma Version: 5.21.5 or git master KDE Frameworks Version: 5.82.0 Qt Version: 5.15.2
Thanks for the thorough investigation!
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1030
Could you attach your diff with your debug, it'll help your comments line up.
Created attachment 138734 [details] Diff of added debug output Here are the changes I made for debugging.
Tested the merge request on my machine and I can confirm that it prevents the EGL stream frame failures from happening. Started a couple of wayland sessions with your fix and desktop + latte came up correctly each time. The latte dock still has an annoying black box behind it, but the session log does not contain the warning anymore, so I assume it is a different issue (see also my bug report 437366). Thanks a lot for the quick fix.
Git commit 600c1e0a543554eb44d79e526873c6ebbfcecb72 by David Edmundson. Committed on 24/05/2021 at 13:51. Pushed by davidedmundson into branch 'master'. platforms/drm: Make context current before EGLStreams calls attachStreamConsumer and resetOutput are not called as part of the scene render and as such the context might not be set. All credit goes to Simon Spinner for his investigation. M +6 -0 src/plugins/platforms/drm/egl_stream_backend.cpp https://invent.kde.org/plasma/kwin/commit/600c1e0a543554eb44d79e526873c6ebbfcecb72
Git commit 849bc70853e0cda631ca01c6a3c46947d3f64d94 by David Edmundson. Committed on 24/05/2021 at 13:51. Pushed by davidedmundson into branch 'Plasma/5.22'. platforms/drm: Make context current before EGLStreams calls attachStreamConsumer and resetOutput are not called as part of the scene render and as such the context might not be set. All credit goes to Simon Spinner for his investigation. (cherry picked from commit 600c1e0a543554eb44d79e526873c6ebbfcecb72) M +6 -0 src/plugins/platforms/drm/egl_stream_backend.cpp https://invent.kde.org/plasma/kwin/commit/849bc70853e0cda631ca01c6a3c46947d3f64d94
*** Bug 437366 has been marked as a duplicate of this bug. ***