[plasma/kwin/Plasma/6.7] src/opengl: opengl/egldisplay: work around libepoxy failing when GPU resets happen
Xaver Hugl <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit a0371ff242e43b02cc11684fa92d8f03a86c6172 by Xaver Hugl.
Committed on 23/07/2026 at 11:18.
Pushed by zamundaaa into branch 'Plasma/6.7'.
opengl/egldisplay: work around libepoxy failing when GPU resets happen
libepoxy calls glGetString(GL_VERSION) when resolving OpenGL functions, which
returns nullptr after a GPU reset.
When that happens, it assumes the OpenGL version is zero, and aborts because
nothing is supported with OpenGL version zero.
To avoid these random crashes, just set our own handler for when resolving
functions fails. It prints about the failure, so we still find out if anything
actually misbehaves, but doesn't abort on GPU resets.
BUG: 500114
BUG: 519263
(cherry picked from commit 86ba65c5f3f4ab32bf63be9f4a170446ca69dd66)
M +17 -0 src/opengl/egldisplay.cpp
https://invent.kde.org/plasma/kwin/-/commit/a0371ff242e43b02cc11684fa92d8f03a86c6172
diff --git a/src/opengl/egldisplay.cpp b/src/opengl/egldisplay.cpp
index 639dd0699c8..067e92ec137 100644
--- a/src/opengl/egldisplay.cpp
+++ b/src/opengl/egldisplay.cpp
@@ -34,11 +34,28 @@ bool EglDisplay::shouldUseOpenGLES()
return QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES;
}
+static void epoxyFailureWorkaround()
+{
+ // do nothing
+}
+
+static epoxy_resolver_stub_t epoxyFailureHandler(const char *functionName)
+{
+ // Since epoxy calls glGetString(GL_VERSION) when resolving functions, and
+ // glGetString fails after a GPU reset, failing to resolve functions is expected
+ // and there's nothing we can or should do about it other than log it and move on.
+ qCWarning(KWIN_OPENGL, "Failed to resolve OpenGL function %s", functionName);
+ return epoxyFailureWorkaround;
+}
+
std::unique_ptr<EglDisplay> EglDisplay::create(::EGLDisplay display, DrmDevice *drmDevice)
{
if (!display) {
return nullptr;
}
+
+ epoxy_set_resolver_failure_handler(epoxyFailureHandler);
+
EGLint major, minor;
if (eglInitialize(display, &major, &minor) == EGL_FALSE) {
qCWarning(KWIN_OPENGL) << "eglInitialize failed";