Comfy-Org/ComfyUI · error · RuntimeError
eglMakeCurrent() failed
Error message
eglMakeCurrent() failed
What it means
Raised during GLContext initialization when eglMakeCurrent() fails right after the surface and context were successfully created. Making a pbuffer surface current on the just-created GLES3 context failed, which typically indicates the context is not compatible with the surface/config pair, the thread already has a current context, or the driver is in a bad state. Initialization aborts and _cleanup() releases the partially built context.
Source
Thrown at comfy_extras/nodes_glsl.py:288
) or n_configs.value == 0:
raise RuntimeError("eglChooseConfig() failed")
self._surface = EGL.eglCreatePbufferSurface(
self._display, config,
_egl_attribs(EGL.EGL_WIDTH, 64, EGL.EGL_HEIGHT, 64),
)
if not self._surface:
raise RuntimeError("eglCreatePbufferSurface() failed")
self._context = EGL.eglCreateContext(
self._display, config, EGL.EGL_NO_CONTEXT,
_egl_attribs(EGL.EGL_CONTEXT_CLIENT_VERSION, 3),
)
if not self._context:
raise RuntimeError("eglCreateContext() failed")
if not EGL.eglMakeCurrent(self._display, self._surface, self._surface, self._context):
raise RuntimeError("eglMakeCurrent() failed")
self._vao = gl.glGenVertexArrays(1)
gl.glBindVertexArray(self._vao)
except Exception:
self._cleanup()
raise
elapsed = (time.perf_counter() - start) * 1000
renderer = _gl_str(gl.GL_RENDERER)
vendor = _gl_str(gl.GL_VENDOR)
version = _gl_str(gl.GL_VERSION)
GLContext._initialized = True
logger.info(f"GLSL context initialized in {elapsed:.1f}ms - EGL {self._egl_major}.{self._egl_minor}, {renderer} ({vendor}), GL {version}")
def make_current(self):View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Isolate the GLSL nodes in a separate process/run so no other library holds an EGL context on the thread.
- Update GPU drivers (this exact make-current failure is a known symptom of older NVIDIA EGL implementations).
- Verify with a minimal script that eglMakeCurrent works with the installed stack; if it fails there too, fix the EGL installation (packages, vendor JSON) rather than the workflow.
- Avoid the GLSL nodes on hosts where only broken software EGL is available.
Defensive patterns
Strategy: try-catch
Try / catch
try:
_ = GLContext() # first GLSL use
except RuntimeError as e:
if "eglMakeCurrent" in str(e) and "EGL error" not in str(e):
log_and_report("EGL context init failed — likely conflicting GL library or driver issue", e)
raise Prevention
- Do not mix other OpenGL-using Python libraries (moderngl, pyrender) into the same process as GLSL nodes.
- Test one GLSL node right after startup so init problems surface early, not mid-batch.
- Keep GPU drivers current.
When it happens
Trigger: Another EGL/GL context is already current on the same thread (e.g. another library initialized OpenGL first); context and surface created from configs with incompatible surface types; driver race during early process lifetime; running under a display server/session where the EGL vendor library requires a platform display that was not the one used.
Common situations: Loading GL-dependent extensions alongside other OpenGL-using Python libraries (e.g. moderngl, pyrender) in the same process; running ComfyUI inside environments where CUDA/EGLOverlay interop has claimed the EGL context.
Related errors
- eglCreatePbufferSurface() failed
- eglCreateContext() failed
- eglBindAPI(EGL_OPENGL_ES_API) failed
- eglChooseConfig() failed
- eglMakeCurrent() failed (EGL error: 0x{err:04X})
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/ed505840837340a5.
Report an issue: GitHub.