remotion-dev/remotion · error · Error
Failed to create WebGL shader
Error message
Failed to create WebGL shader
What it means
pattern() compiles fixed GLSL shaders during WebGL2 setup. gl.createShader() returns null only when the context is lost or the driver refuses allocation. Because the shader source is fixed in the library, this null almost always indicates a dead/lost context rather than a code defect.
Source
Thrown at packages/effects/src/pattern.ts:402
if (sampleCell(cell + vec2(float(x), float(y)), fragPx, cropStart, tileSize, pitch, originPx, color)) {
fragColor = color;
return;
}
}
}
fragColor = vec4(0.0);
}
`;
const compileShader = (
gl: WebGL2RenderingContext,
type: number,
source: string,
): WebGLShader => {
const shader = gl.createShader(type);
if (!shader) {
throw new Error('Failed to create WebGL shader');
}
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 => {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Ensure a stable WebGL2 context before rendering (GPU available / SwiftShader in CI).
- Handle 'webglcontextlost' and re-initialize the effect on 'webglcontextrestored'.
- Avoid stacking many GPU effects in one composition during heavy renders.
- Update GPU drivers or switch to a software WebGL backend.
Defensive patterns
Strategy: try-catch
Try / catch
try {
initPattern(canvas); // compiles pattern shaders
} catch (err) {
if (isContextLost(canvas)) {
waitForRestore(canvas).then(initPattern); // retry on restore
} else {
throw err;
}
} Prevention
- Render on a verified WebGL2-capable environment (real GPU or SwiftShader).
- Register webglcontextlost/restored handlers and re-run shader setup on restore.
- Avoid stacking many GPU effects so the driver does not refuse allocations.
- Keep GPU drivers current.
When it happens
Trigger: Reached in compileShader() during pattern effect setup, before any user-visible frame. The context returned a valid WebGL2 object from getContext but createShader now returns null (context lost between acquisition and compile).
Common situations: GPU reset mid-setup; context eviction in a long render; headless rendering with an unstable GPU; concurrent renders saturating driver resources.
Related errors
- Failed to create WebGL program
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
- Failed to create WebGL texture
- Failed to create WebGL shader
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/946628b9d20a6f93.
Report an issue: GitHub.