remotion-dev/remotion · error · Error
Failed to create WebGL program
Error message
Failed to create WebGL program
What it means
pattern() links the compiled vertex and fragment shaders into a program. gl.createProgram() returns null only when the GL context is lost or the driver refuses the allocation. This guard fails fast instead of calling attachShader/linkProgram on null.
Source
Thrown at packages/effects/src/pattern.ts:423
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(`Pattern 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(`Pattern program link failed: ${log ?? '(no log)'}`);
}
return program;
};
export const pattern = createEffect<PatternParams, PatternState>({
type: 'dev.remotion.effects.pattern',
label: 'pattern()',
documentationLink: 'https://www.remotion.dev/docs/effects/pattern',View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Guarantee a live WebGL2 context (handle webglcontextlost/restored).
- Reduce concurrent GPU effects per composition.
- Use a stable GPU/SwiftShader backend in headless rendering.
- Update GPU drivers.
Defensive patterns
Strategy: try-catch
Try / catch
try {
initPattern(canvas); // links the pattern program
} catch (err) {
if (isContextLost(canvas)) waitForRestore(canvas).then(initPattern);
else throw err;
} Prevention
- Maintain a live WebGL2 context (handle webglcontextlost/restored).
- Limit concurrent GPU effects per composition to stay under driver limits.
- Render with a stable GPU or SwiftShader backend.
- Keep GPU drivers current.
When it happens
Trigger: Reached in linkProgram() after both shaders compiled successfully. createProgram returns null because the context was lost between shader compilation and program creation, during pattern effect setup.
Common situations: Context loss mid-setup; driver resource exhaustion on heavy compositions; GPU reset during a render batch.
Related errors
- Failed to create WebGL shader
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
- Failed to create WebGL texture
- Failed to create WebGL program
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/98ac6df2317c32cd.
Report an issue: GitHub.