remotion-dev/remotion · critical · Error
Failed to create WebGL program
Error message
Failed to create WebGL program
What it means
Thrown by halftone-linear-gradient's linkProgram (halftone-linear-gradient.ts:399) when gl.createProgram() returns null. Like the null-shader case, a null program indicates a lost WebGL2 context or severe resource exhaustion; the library cannot call attachShader/linkProgram on null.
Source
Thrown at packages/effects/src/halftone-linear-gradient.ts:399
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
const log = gl.getShaderInfoLog(shader);
gl.deleteShader(shader);
throw new Error(
`Halftone linear gradient shader compile failed: ${log ?? '(no log)'}`,
);
}
return shader;
};
const linkProgram = (
gl: WebGL2RenderingContext,
vs: WebGLShader,
fs: WebGLShader,
): WebGLProgram => {
const program = gl.createProgram();
if (!program) {
throw new Error('Failed to create WebGL program');
}
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const log = gl.getProgramInfoLog(program);
gl.deleteProgram(program);
throw new Error(
`Halftone linear gradient program link failed: ${log ?? '(no log)'}`,
);
}
return program;
};
export const halftoneLinearGradient = createEffect<
HalftoneLinearGradientParams,View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Handle webglcontextlost; recreate state on webglcontextrestored.
- Ensure cleanup() deletes programs (halftone cleanup frees the program).
- Limit concurrent WebGL2 effects; render sequentially.
- Restart browser/GPU; update drivers if the failure is reproducible.
Example fix
// before: setup per render, no teardown -> programs leak -> null
const state = halftone.setup(canvas);
// after: setup once, pair with cleanup
useEffect(() => {
const state = halftone.setup(canvas);
return () => halftone.cleanup(state);
}, []); Defensive patterns
Strategy: try-catch
Validate before calling
if (gl.isContextLost()) {
throw new Error('WebGL2 context lost; cannot create program');
} Type guard
null
Try / catch
try {
halftoneLinearGradient.setup(canvas);
} catch (e) {
if (e instanceof Error && e.message === 'Failed to create WebGL program') {
// context loss / resource exhaustion
}
throw e;
} Prevention
- Handle context loss and rebuild on restore.
- Free programs in cleanup().
- Limit concurrent WebGL effects/compositions.
- Restart browser/GPU when allocation failures become persistent.
When it happens
Trigger: Called during setup after both shaders compiled successfully (line 448). Triggered by a lost context, or by accumulated GL objects exhausting the driver's program budget.
Common situations: Long renders leaking programs; many concurrent WebGL effects/compositions; GPU reset mid-render; constrained software renderer.
Related errors
- Failed to create WebGL program
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create white balance shader program
- Failed to create WebGL program
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/ebb74334fa5955cb.
Report an issue: GitHub.