remotion-dev/remotion · error · Error
Failed to create WebGL shader
Error message
Failed to create WebGL shader
What it means
The speckle() effect's compileShader() in packages/effects/src/speckle.ts calls gl.createShader(), which returned null. Identical root cause to the skew case: the WebGL2 context is lost, resource-exhausted, or non-conformant, so speckle cannot build the SPECKLE_VS/SPECKLE_FS shaders it needs. The context was acquired (createWebGL2ContextError did not fire), so this is an allocation failure during setup.
Source
Thrown at packages/effects/src/speckle.ts:166
program: WebGLProgram;
vao: WebGLVertexArrayObject;
vbo: WebGLBuffer;
texture: WebGLTexture;
uSource: WebGLUniformLocation | null;
uResolution: WebGLUniformLocation | null;
uDensity: WebGLUniformLocation | null;
uSize: WebGLUniformLocation | null;
uRandomness: WebGLUniformLocation | null;
};
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(`Speckle shader compile failed: ${log ?? '(no log)'}`);
}
return shader;
};
const linkProgram = (
gl: WebGL2RenderingContext,
vs: WebGLShader,
fs: WebGLShader,
): WebGLProgram => {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Render with ANGLE (--gl=angle / chromiumOptions.gl='angle' / Studio OpenGL=angle).
- Reduce concurrency and the number of WebGL2 effects stacked per frame to stay under the active-context cap.
- Make sure each effect's cleanup runs so contexts/shaders are released before new effects initialize.
- Verify the target environment has working WebGL2 (supported GPU and current drivers).
Example fix
// before npx remotion render main MyComp out.mp4 // after npx remotion render main MyComp out.mp4 --gl=angle
Defensive patterns
Strategy: try-catch
Validate before calling
function supportsWebGL2Effect(): boolean {
try {
return !!document.createElement('canvas').getContext('webgl2');
} catch {
return false;
}
}
if (!supportsWebGL2Effect()) {
throw new Error('speckle() requires WebGL2, which is unavailable in this environment');
} Try / catch
try {
await renderMedia({ composition, codec: 'h264', chromiumOptions: { gl: 'angle' } });
} catch (err) {
if (err instanceof Error && /Failed to create WebGL shader/.test(err.message)) {
console.error('WebGL2 shader allocation failed for speckle(). Use --gl=angle and/or lower concurrency.', err);
throw err;
}
throw err;
} Prevention
- Render WebGL2 effects with the ANGLE backend.
- Keep concurrency and stacked WebGL2-effect counts under the live-context cap.
- Verify cleanup runs so contexts/shaders are freed.
- Render on hosts with supported GPUs and current drivers.
When it happens
Trigger: Applying speckle() while the WebGL2 context is in a lost state, or once the process has exceeded the browser's live WebGL-context limit so new contexts are immediately unusable; also possible under GPU memory pressure or a driver reset between getContext() and createShader().
Common situations: Headless/CI rendering without --gl=angle; many parallel frames each stacking multiple WebGL2 effects; SwiftShader/llvmpipe software fallback under load; hosts with failing or absent GPU drivers.
Related errors
- Failed to create WebGL program
- Failed to create WebGL buffer
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create WebGL vertex array
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/0ce7b03516c4488b.
Report an issue: GitHub.