remotion-dev/remotion · critical · Error
Failed to create WebGL program
Error message
Failed to create WebGL program
What it means
Thrown by linkProgram (packages/effects/src/paper.ts:678) when gl.createProgram() returns null before attaching the paper shaders. Null signals a lost WebGL2 context or exhausted program-object budget, independent of the shader sources.
Source
Thrown at packages/effects/src/paper.ts:678
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
const log = gl.getShaderInfoLog(shader);
gl.deleteShader(shader);
throw new Error(`Paper 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(`Paper program link failed: ${log ?? '(no log)'}`);
}
return program;
};
const createSourceTexture = (gl: WebGL2RenderingContext): WebGLTexture => {
const texture = gl.createTexture();
if (!texture) {
throw new Error('Failed to create WebGL texture');View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Ensure cleanup runs gl.deleteProgram between usages and cap concurrent WebGL2 effects.
- Render with a healthy GPU context (GPU-enabled headless Chrome) and handle context-loss events.
- Probe gl.isContextLost() before setup and skip/retry when true.
Example fix
// before
const program = linkProgram(gl, vs, fs); // createProgram() returned null
// after
if (gl.isContextLost()) {
throw new Error('Cannot link paper program: WebGL2 context lost');
} Defensive patterns
Strategy: try-catch
Validate before calling
function canCreatePaperProgram(): boolean {
try {
const c = document.createElement('canvas');
const gl = c.getContext('webgl2');
if (!gl || gl.isContextLost()) return false;
const p = gl.createProgram();
const ok = !!p;
if (p) gl.deleteProgram(p);
return ok;
} catch {
return false;
}
} Try / catch
try {
scene.push(paper({amount: 1}));
} catch (err) {
if (/Failed to create WebGL program/.test(String(err?.message))) {
// program budget exhausted or context lost: reduce effects and retry
} else throw err;
} Prevention
- Delete programs via cleanup between usages.
- Cap concurrent WebGL2 effects.
- Render on a GPU host and handle context-loss events.
When it happens
Trigger: setupPaper linking on a lost context or after too many program objects were allocated without cleanup; compiling into a dead context.
Common situations: Render farms running many paper/WebGL2 effects without deleting programs; context loss during a batch; GPU memory pressure.
Related errors
- Failed to create WebGL program
- Failed to create WebGL shader
- Paper program link failed: ${log ?? '(no log)'}
- Failed to create WebGL texture
- Failed to create WebGL noise texture
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/caf47815dde2be12.
Report an issue: GitHub.