Bug 438363

Summary: [Wayland/Nvidia] Kwin does not start anymore on wayland after latest changes on git master
Product: [Plasma] kwin Reporter: Simon Spinner <simon.spinner>
Component: eglAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: nate, xaver.hugl
Priority: NOR Keywords: regression
Version First Reported In: git master   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Wayland session log
Wayland session log (including fixes)

Description Simon Spinner 2021-06-09 20:23:21 UTC
Created attachment 139167 [details]
Wayland session log

SUMMARY
Wayland session was working until recently. With the latest changes to git master, I only get a black screen with a mouse cursor in the center of it. Mouse cursor cannot be moved.

I suspect that https://invent.kde.org/plasma/kwin/-/merge_requests/1008 broke it. Up to this commit the session seems to work, when going beyond it, it is broken.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.22.80
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2021-06-09 22:18:46 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1094
Comment 2 Zamundaaa 2021-06-09 22:20:34 UTC
Thanks for bisecting. The fallback QPainter backend should probably be fixed, too...
Comment 3 Zamundaaa 2021-06-10 11:19:29 UTC
Git commit 3d6659b0d7137e35f4a02bbc29787e5cf92bb414 by Xaver Hugl.
Committed on 10/06/2021 at 11:19.
Pushed by zamundaaa into branch 'master'.

platforms/drm: on NVidia do pageflips with QPainter

Otherwise it's just gonna display a static black screen

M  +3    -3    src/plugins/platforms/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/commit/3d6659b0d7137e35f4a02bbc29787e5cf92bb414
Comment 4 Zamundaaa 2021-06-10 13:07:11 UTC
Git commit 40c485f2a6e3231f2398055987c5497270644e51 by Xaver Hugl.
Committed on 10/06/2021 at 13:06.
Pushed by zamundaaa into branch 'master'.

platforms/drm: fix EglStreamBackend init

M  +6    -9    src/plugins/platforms/drm/egl_stream_backend.cpp

https://invent.kde.org/plasma/kwin/commit/40c485f2a6e3231f2398055987c5497270644e51
Comment 5 Simon Spinner 2021-06-13 19:52:33 UTC
Updated to latest git master that includes your changes. The changes do not solve the issue. I am still seeing a black screen only. This time even without a cursor being drawn. Attaching latest session log.
Comment 6 Simon Spinner 2021-06-13 19:53:21 UTC
Created attachment 139294 [details]
Wayland session log (including fixes)
Comment 7 Zamundaaa 2021-06-13 22:09:05 UTC
Git commit 6561b58d8164978e4b61d129aed6dba84e6a1eea by Xaver Hugl.
Committed on 13/06/2021 at 21:11.
Pushed by zamundaaa into branch 'Plasma/5.22'.

platforms/drm: on NVidia do pageflips with QPainter

Otherwise it's just gonna display a static black screen
(cherry picked from commit 3d6659b0d7137e35f4a02bbc29787e5cf92bb414)

M  +3    -3    src/plugins/platforms/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/commit/6561b58d8164978e4b61d129aed6dba84e6a1eea
Comment 8 Zamundaaa 2021-06-13 22:18:21 UTC
The log looks like everything would be working correctly, it's using OpenGL rendering and pushing frames. I'm not sure what could be going on.

Does locally reverting 2742e5b422a543645467107c1f7e71e9f931a3b4 make a difference?
Comment 9 Simon Spinner 2021-06-14 20:12:14 UTC
Reverting 2742e5b422a543645467107c1f7e71e9f931a3b4 alone does not help. Only in conjunction with reverting 40c485f2a6e3231f2398055987c5497270644e51 too I get a working wayland session again.
Comment 10 Zamundaaa 2021-06-14 21:22:00 UTC
Could you test https://invent.kde.org/plasma/kwin/-/merge_requests/1105?
Comment 11 Simon Spinner 2021-06-15 21:03:35 UTC
Tested the MR. I don't see a difference.
Comment 12 Bug Janitor Service 2021-06-15 21:29:38 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1107
Comment 13 Zamundaaa 2021-06-15 21:32:35 UTC
This should really fix it as it just reverts the part that should be relevant here.
Comment 14 Vlad Zahorodnii 2021-06-16 05:36:01 UTC
Can you please check the logs in .local/share/sddm/wayland-session.log? Maybe kwin prints something useful before quitting. Also, does kwin crash or simply quit?
Comment 15 Simon Spinner 2021-06-16 19:45:48 UTC
Tested https://invent.kde.org/plasma/kwin/-/merge_requests/1107. I got it to work with one additional local change:

diff --git a/src/plugins/platforms/drm/egl_stream_backend.cpp b/src/plugins/platforms/drm/egl_stream_backend.cpp
index f2af3a3c9..ec0db19b7 100644
--- a/src/plugins/platforms/drm/egl_stream_backend.cpp
+++ b/src/plugins/platforms/drm/egl_stream_backend.cpp
@@ -283,7 +283,7 @@ bool EglStreamBackend::initRenderingContext()
 {
     initBufferConfigs();
 
-    if (!createContext() || !makeCurrent()) {
+    if (!createContext()) {
         return false;
     }
 
@@ -291,7 +291,8 @@ bool EglStreamBackend::initRenderingContext()
     for (DrmOutput *drmOutput : outputs) {
         addOutput(drmOutput);
     }
-    return true;
+
+    return makeCurrent();
 }
 
 bool EglStreamBackend::resetOutput(Output &o, DrmOutput *drmOutput)
Comment 16 Vlad Zahorodnii 2021-06-17 05:50:36 UTC
@Simon that's very interesting. Does kwin start if you remove all setSurface() calls in egl_stream_backend.cpp?
Comment 17 Simon Spinner 2021-06-17 18:42:34 UTC
Tested latest version of merge request without setSurface. Looks good. Thanks a lot!
Comment 18 Zamundaaa 2021-06-21 14:34:18 UTC
Git commit 7552b530662da556a20ef32688b0be0043041b80 by Xaver Hugl.
Committed on 21/06/2021 at 12:49.
Pushed by zamundaaa into branch 'master'.

partially revert 2742e5b422a543645467107c1f7e71e9f931a3b4

It seems like without a surface creation of the scene fails somehow. At
least until the exact problem is solved, update outputs for EglStream
gpus before creating the EglStreamBackend.

M  +4    -0    src/plugins/platforms/drm/drm_backend.cpp
M  +2    -2    src/plugins/platforms/drm/egl_stream_backend.cpp

https://invent.kde.org/plasma/kwin/commit/7552b530662da556a20ef32688b0be0043041b80