[plasma/kwin] 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 86ba65c5f3f4ab32bf63be9f4a170446ca69dd66 by Xaver Hugl.
Committed on 23/07/2026 at 07:42.
Pushed by zamundaaa into branch 'master'.
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
M +17 -0 src/opengl/egldisplay.cpp
https://invent.kde.org/plasma/kwin/-/commit/86ba65c5f3f4ab32bf63be9f4a170446ca69dd66
diff --git a/src/opengl/egldisplay.cpp b/src/opengl/egldisplay.cpp
index d543d5f64d6..efc312659da 100644
--- a/src/opengl/egldisplay.cpp
+++ b/src/opengl/egldisplay.cpp
@@ -26,11 +26,28 @@
namespace KWin
{
+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";