{"record":{"id":"004bd3dd406344e3","repo":"Comfy-Org/ComfyUI","slug":"eglmakecurrent-failed-egl-error-0x-err-04x","errorCode":null,"errorMessage":"eglMakeCurrent() failed (EGL error: 0x{err:04X})","messagePattern":"eglMakeCurrent\\(\\) failed \\(EGL error: 0x(.+?)\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_glsl.py","lineNumber":309,"sourceCode":"            gl.glBindVertexArray(self._vao)\n\n        except Exception:\n            self._cleanup()\n            raise\n\n        elapsed = (time.perf_counter() - start) * 1000\n\n        renderer = _gl_str(gl.GL_RENDERER)\n        vendor = _gl_str(gl.GL_VENDOR)\n        version = _gl_str(gl.GL_VERSION)\n\n        GLContext._initialized = True\n        logger.info(f\"GLSL context initialized in {elapsed:.1f}ms - EGL {self._egl_major}.{self._egl_minor}, {renderer} ({vendor}), GL {version}\")\n\n    def make_current(self):\n        if not EGL.eglMakeCurrent(self._display, self._surface, self._surface, self._context):\n            err = EGL.eglGetError()\n            raise RuntimeError(f\"eglMakeCurrent() failed (EGL error: 0x{err:04X})\")\n        if self._vao is not None:\n            gl.glBindVertexArray(self._vao)\n\n    def _cleanup(self):\n        if not self._display:\n            return\n        try:\n            if self._vao is not None:\n                gl.glDeleteVertexArrays(1, [self._vao])\n                self._vao = None\n        except Exception:\n            pass\n        try:\n            EGL.eglMakeCurrent(self._display, EGL.EGL_NO_SURFACE, EGL.EGL_NO_SURFACE, EGL.EGL_NO_CONTEXT)\n        except Exception:\n            pass\n        try:\n            if self._context:","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_glsl.py#L291-L327","documentation":"Raised by GLContext.make_current() when re-binding the singleton's surface/context on the calling thread fails, with the raw EGL error code included (e.g. 0x3009 EGL_BAD_MATCH, 0x3006 EGL_BAD_CONTEXT). Unlike the init-time variant, this happens after the context already worked once, so the usual cause is concurrent use from multiple threads or a display/context that was invalidated (GPU reset, driver teardown).","triggerScenarios":"Two GLSL nodes (or two worker threads) executing GL work simultaneously so make_current() races on the same context; the context was destroyed by a driver/GPU reset and the singleton still holds stale handles; calling make_current() from a thread where another context is current.","commonSituations":"Parallel prompt execution in ComfyUI running several GLSL node instances at once; long-running processes that survived a GPU reset.","solutions":["Force serial execution of the GLSL nodes (run one at a time; avoid parallel branch execution that fans out into GLSL nodes).","Restart the ComfyUI process to rebuild the singleton GL context after a GPU reset.","Update drivers if EGL_BAD_MATCH / EGL_BAD_ACCESS appears consistently on rebind.","If concurrency is required, route GL work through a single dedicated thread that owns the context."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = run_glsl_node(...)\nexcept RuntimeError as e:\n    if \"eglMakeCurrent() failed (EGL error\" in str(e):\n        # context likely invalidated (GPU reset) or raced across threads:\n        # serialize GL work and/or restart the process, then retry once\n        result = run_glsl_node_serialized(...)\n    else:\n        raise","preventionTips":["Execute GLSL nodes one at a time; do not fan out into parallel GLSL branches.","Decode the hex EGL code in the message (0x3006 bad context, 0x3009 bad match) to guide the fix.","Restart ComfyUI after GPU resets instead of reusing the stale GL context."],"tags":["egl","opengl","threading","concurrency","glsl"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}