Comfy-Org/ComfyUI · error · RuntimeError
Shader compilation failed:\n{error}
Error message
Shader compilation failed:\n{error} What it means
Raised by _compile_shader() when glGetShaderiv(GL_COMPILE_STATUS) is false; the raised message embeds the driver's info log. This is a user-code error: the GLSL source string supplied to the GLSL node (vertex or, almost always, fragment code) does not compile under the context's GLSL ES 3.00 profile.
Source
Thrown at comfy_extras/nodes_glsl.py:354
try:
EGL.eglTerminate(self._display)
except Exception:
pass
self._display = None
def _compile_shader(source: str, shader_type: int) -> int:
"""Compile a shader and return its ID."""
shader = gl.glCreateShader(shader_type)
gl.glShaderSource(shader, source)
gl.glCompileShader(shader)
if not gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS):
error = gl.glGetShaderInfoLog(shader)
if isinstance(error, bytes):
error = error.decode(errors="replace")
gl.glDeleteShader(shader)
raise RuntimeError(f"Shader compilation failed:\n{error}")
return shader
def _create_program(vertex_source: str, fragment_source: str) -> int:
"""Create and link a shader program."""
vertex_shader = _compile_shader(vertex_source, gl.GL_VERTEX_SHADER)
try:
fragment_shader = _compile_shader(fragment_source, gl.GL_FRAGMENT_SHADER)
except RuntimeError:
gl.glDeleteShader(vertex_shader)
raise
program = gl.glCreateProgram()
gl.glAttachShader(program, vertex_shader)
gl.glAttachShader(program, fragment_shader)
gl.glLinkProgram(program)
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Read the info log embedded in the error text — it names the line and the syntax problem.
- Start the shader with '#version 300 es' and use in/out instead of attribute/varying, and an explicit 'precision highp float;' in the fragment shader.
- Replace legacy calls: texture2D(s, uv) -> texture(s, uv), gl_FragColor -> a declared out vec4.
- Verify the shader on a site like shadertoy-ish ES validators or with glslangValidator before pasting it in.
Example fix
// before
varying vec2 v_uv;
void main() { gl_FragColor = texture2D(img, v_uv); }
// after
precision highp float;
in vec2 v_uv;
uniform sampler2D img;
out vec4 fragColor;
void main() { fragColor = texture(img, v_uv); } Defensive patterns
Strategy: validation
Validate before calling
import re
def glsl_es300_ok(src: str) -> bool:
src = re.sub(r"/\*.*?\*/", "", src, flags=re.S).split("#version")[-1]
bad = re.findall(r"\b(?:varying|attribute|texture2D|texture3D|gl_FragColor)\b", src)
return not bad and ("300 es" in src or "#version" not in src)
assert glsl_es300_ok(fragment_code), "shader uses desktop-GLSL syntax rejected by GLES3" Try / catch
try:
out = run_glsl(fragment_code, ...)
except RuntimeError as e:
if "Shader compilation failed" in str(e):
show_shader_editor_error(str(e)) # surface driver info log with line numbers to the user
raise Prevention
- Start every fragment shader with '#version 300 es' and 'precision highp float;'.
- Convert Shadertoy ports: texture2D -> texture, gl_FragColor -> out vec4.
- Validate with glslangValidator before pasting into the node.
- Read the embedded info log — it names the exact line.
When it happens
Trigger: Writing desktop GLSL (e.g. #version 330 core, texture2D, gl_FragColor, varying) instead of GLSL ES 300 syntax (in/out, texture(), precision qualifiers); missing precision qualifier for float in fragment shader; undefined variables/functions; integer/float literal mix-ups (1 instead of 1.0).
Common situations: Porting Shadertoy or desktop GLSL shaders into the node without converting to ES 3.00; typos in uniform names; using functions from extensions the driver does not expose.
Related errors
- Program linking failed:\n{error}
- eglCreatePbufferSurface() failed
- eglCreateContext() failed
- eglMakeCurrent() failed
- eglMakeCurrent() failed (EGL error: 0x{err:04X})
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/5f9bf6c9481d50dd.
Report an issue: GitHub.