Comfy-Org/ComfyUI · error · RuntimeError
eglCreateContext() failed
Error message
eglCreateContext() failed
What it means
Raised during GLContext initialization when eglCreateContext() with EGL_CONTEXT_CLIENT_VERSION=3 returns EGL_NO_CONTEXT. The display and pbuffer surface were created fine, but the driver refused to create a GLES 3.x context on the chosen config. The GLSL nodes require OpenGL ES 3.0 (MRT rendering to RGBA32F textures), so a GLES2-only stack fails here.
Source
Thrown at comfy_extras/nodes_glsl.py:285
EGL.EGL_BLUE_SIZE, 8, EGL.EGL_ALPHA_SIZE, 8,
),
ctypes.byref(config), 1, ctypes.byref(n_configs),
) 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 = TrueView on GitHub (pinned to 1c6d8d45b3)
Solutions
- Install the GLES3 runtime: apt install libgles3-mesa libegl-mesa0 (or distro equivalent) inside the container/host.
- Confirm ES3 support with eglinfo / es2_info: look for 'OpenGL ES 3.x' in the client APIs string.
- Update the GPU driver to a version with working EGL + GLES3 (especially NVIDIA >= 470 and recent Mesa).
- As a last resort on machines without GLES3, use non-GLSL image-manipulation nodes.
Defensive patterns
Strategy: validation
Validate before calling
# Before using GLSL nodes, confirm ES3 context creation is possible:
# eglinfo -B should list "OpenGL ES 3.x" under client APIs / supported contexts.
import subprocess, sys
r = subprocess.run(["eglinfo", "-B"], capture_output=True, text=True)
if "OpenGL ES 3" not in (r.stdout + r.stderr):
print("Warning: GLES3 not available; GLSL nodes will fail at eglCreateContext") Try / catch
try:
out = glsl_render_node(...)
except RuntimeError as e:
if "eglCreateContext" in str(e):
# fall back to a torch-based equivalent effect node
out = torch_fallback_effect(...)
else:
raise Prevention
- Install libgles3 alongside libgles2 in deployment images.
- Check eglinfo output for ES3 support during environment bring-up.
- Pin recent GPU drivers known to expose ES3 via EGL.
When it happens
Trigger: eglChooseConfig matched a config whose RENDERABLE_TYPE bits allow ES3 but the driver cannot create a version-3 context (driver bug or mismatched vendor); EGL 1.4-only implementations without proper ES3 support; containers with only libgles2 (GLES2) installed while libgles3 is missing.
Common situations: Minimal Docker images that install libgles2 but not libgles3; older embedded/ARM drivers advertising ES3 configs but lacking a working ES3 runtime; mixing Mesa EGL with proprietary GL libraries.
Related errors
- eglChooseConfig() failed
- eglCreatePbufferSurface() failed
- eglMakeCurrent() failed
- eglBindAPI(EGL_OPENGL_ES_API) failed
- eglMakeCurrent() failed (EGL error: 0x{err:04X})
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/893ee773cb0b82c2.
Report an issue: GitHub.