Bug 431505 - Kdenlive crashes instantly on Wayland due to EGL format mismatch
Summary: Kdenlive crashes instantly on Wayland due to EGL format mismatch
Status: RESOLVED FIXED
Alias: None
Product: kdenlive
Classification: Applications
Component: User Interface (show other bugs)
Version: 20.12.1
Platform: FreeBSD Ports FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords:
: 433393 438746 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-01-12 14:24 UTC by login.kde
Modified: 2021-06-25 12:37 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:
fritzibaby: Brainstorm+


Attachments
attachment-20422-0.html (1.15 KB, text/html)
2021-06-18 10:36 UTC, Jacques Noé
Details

Note You need to log in before you can comment on or make changes to this bug.
Description login.kde 2021-01-12 14:24:15 UTC
SUMMARY

As soon as the kdenlive window appears, it crashes:

QWaylandGLContext::makeCurrent: eglError: 3009, this: 0xb99e12c94a0

QWaylandGLContext::makeCurrent: eglError: 3009, this: 0xb99e12c9080

QWaylandGLContext::makeCurrent: eglError: 3009, this: 0xb99f643c780

QOpenGLFunctions created with non-current context
ASSERT: "QOpenGLFunctions::isInitialized(d_ptr)" in file /usr/local/include/qt5/QtGui/qopenglfunctions.h, line 949


It seems that Qt (still) doesn't implement pbuffer support on Wayland-EGL, so an invisible wayland surface is used.
This means that the formats of the offscreen surface and the window surface have to match, otherwise EGL refuses to makeCurrent and everything breaks.

Specifically the issue seems to be the lack of depth and stencil buffer.
This patch lets kdenlive work on wayland at least without the GPU engine (that one throws an egl error 3002 - EGL_BAD_ACCESS in makeCurrent):

--- src/monitor/glwidget.cpp.orig       2021-01-12 13:57:33 UTC
+++ src/monitor/glwidget.cpp
@@ -120,7 +120,10 @@ GLWidget::GLWidget(int id, QObject *parent)
     setPersistentSceneGraph(true);
     setClearBeforeRendering(false);
     setResizeMode(QQuickView::SizeRootObjectToView);
-    m_offscreenSurface.setFormat(QOpenGLContext::globalShareContext()->format());
+    auto fmt = QOpenGLContext::globalShareContext()->format();
+    fmt.setDepthBufferSize(format().depthBufferSize());
+    fmt.setStencilBufferSize(format().stencilBufferSize());
+    m_offscreenSurface.setFormat(fmt);
     m_offscreenSurface.create();

     m_refreshTimer.setSingleShot(true);


SOFTWARE/OS VERSIONS
FreeBSD: 13-CURRENT + drm 5.4-lts
Mesa(RadeonSI): master
Wayfire/wlroots: master
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2
Comment 1 Rex Dieter 2021-03-04 03:52:40 UTC
I can confirm the same (or very similar) error on fedora 33, plasma-5.21.2 wayland session

tail end of console output:

QQmlEngine::setContextForObject(): Object already has a QQmlContext
QQmlEngine::setContextForObject(): Object already has a QQmlContext
QWaylandGLContext::makeCurrent: eglError: 3009, this: 0x5626634b3b20 

QWaylandGLContext::makeCurrent: eglError: 3009, this: 0x5626634cd5e0 

QWaylandGLContext::makeCurrent: eglError: 3009, this: 0x7f98d80084d0 

QOpenGLFunctions created with non-current context
The Wayland connection experienced a fatal error: Bad file descriptor
Unable to start Dr. Konqi
Comment 2 emohr 2021-05-01 07:31:02 UTC
Please try with the current Kdenlive AppImage version 21.04.0 to see if there are any packaging issues https://download.kde.org/stable/kdenlive/21.04/linux/
Comment 3 Julius Künzel 2021-05-01 08:24:21 UTC
(In reply to login.kde from comment #0)
> Specifically the issue seems to be the lack of depth and stencil buffer.
> This patch lets kdenlive work on wayland at least without the GPU engine
> (that one throws an egl error 3002 - EGL_BAD_ACCESS in makeCurrent):

Thanks for that! Can you open a merge request at https://invent.kde.org/multimedia/kdenlive/ ?
Comment 4 emohr 2021-05-02 08:11:10 UTC
I think this could be similar to this Bug 433393
Comment 5 Alex 2021-05-03 04:53:30 UTC
*** Bug 433393 has been marked as a duplicate of this bug. ***
Comment 6 geisserml 2021-05-23 20:19:41 UTC
I can confirm this issue with the Kdenlive version that is currently in Neon User.
Comment 7 S-Paliwal 2021-06-17 16:01:19 UTC
*** Bug 438746 has been marked as a duplicate of this bug. ***
Comment 8 Kyrylo Bohdanenko 2021-06-17 19:03:58 UTC
There is a workaround (that defeats the purpose of running. Kdenlive on Wayland)

QT_QPA_PLATFORM=xkb kdenlive
Comment 9 Jacques Noé 2021-06-18 10:36:01 UTC
Created attachment 139478 [details]
attachment-20422-0.html

Hello,

Thank you for the support.
There is a typo in the workaround, it is "QT_QPA_PLATFORM=xcb kdenlive".
kdenlive works well now.

Best regards,

Jacques Noé

Le jeu. 17 juin 2021 à 21:04, Kyrylo Bohdanenko <bugzilla_noreply@kde.org>
a écrit :

> https://bugs.kde.org/show_bug.cgi?id=431505
>
> --- Comment #8 from Kyrylo Bohdanenko <kirill.bogdanenko@gmail.com> ---
> There is a workaround (that defeats the purpose of running. Kdenlive on
> Wayland)
>
> QT_QPA_PLATFORM=xkb kdenlive
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 10 Jean-Baptiste Mardelle 2021-06-18 14:43:07 UTC
Git commit 185b30362f1f2a3cf340e6fbcd92cd41157e2c9d by Jean-Baptiste Mardelle.
Committed on 18/06/2021 at 14:41.
Pushed by mardelle into branch 'master'.

Fix startup crash on Wayland, thanks to login.kde@unrelenting.technology

M  +4    -1    src/monitor/glwidget.cpp

https://invent.kde.org/multimedia/kdenlive/commit/185b30362f1f2a3cf340e6fbcd92cd41157e2c9d
Comment 11 geisserml 2021-06-18 15:16:42 UTC
Thanks for merging the patch, but what about this? (Comment 0)
> that one [the GPU engine] throws an egl error 3002 - EGL_BAD_ACCESS in makeCurrent

Also, I'd like to mention this bug is to some extent a regression, because I remember older versions of kdenlive (i.e. what was in Neon User at the time of Plasma 5.20) worked just fine on Wayland, even in gpu mode.
Comment 12 Rex Dieter 2021-06-18 15:22:15 UTC
remarking resolved, guessing/hoping the prior comment re-opening was unintentional
Comment 13 geisserml 2021-06-18 17:00:38 UTC
It was certainly intentional. If you read my previous comment you should know why.
Comment 14 Jean-Baptiste Mardelle 2021-06-25 12:37:32 UTC
Git commit be5f24f72a6b4189b6069a71bef53041689a330a by Jean-Baptiste Mardelle.
Committed on 25/06/2021 at 12:37.
Pushed by mardelle into branch 'release/21.04'.

Fix startup crash on Wayland, thanks to login.kde@unrelenting.technology

M  +4    -1    src/monitor/glwidget.cpp

https://invent.kde.org/multimedia/kdenlive/commit/be5f24f72a6b4189b6069a71bef53041689a330a