remotion-dev/remotion · error · Error
Failed to create WebGL shader
Error message
Failed to create WebGL shader
What it means
Thrown by the drop-shadow runtime's compileShader helper when gl.createShader() returns null. Equivalent to the dot-grid case: the WebGL2 context could not allocate a shader object, almost always because the context is lost, destroyed, or resource-exhausted. The drop-shadow effect compiles four shaders (extract, horizontal blur, vertical blur, composite), so the first failing allocation throws.
Source
Thrown at packages/effects/src/drop-shadow/drop-shadow-runtime.ts:58
readonly composite: {
readonly uSource: WebGLUniformLocation | null;
readonly uShadow: WebGLUniformLocation | null;
readonly uOffset: WebGLUniformLocation | null;
readonly uTexelSize: WebGLUniformLocation | null;
};
readonly colorCtx: CanvasRenderingContext2D;
cachedColorStr: string;
cachedColorRgba: ParsedColorRgba;
};
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(`Drop shadow shader compile failed: ${log ?? '(no log)'}`);
}
return shader;
};
const linkProgram = (
gl: WebGL2RenderingContext,
vs: WebGLShader,
fs: WebGLShader,
): WebGLProgram => {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Feature-detect WebGL2 before applying the effect: const gl = canvas.getContext('webgl2'); if (!gl) skip.
- For headless rendering, launch Chrome with --use-gl=angle --use-angle=swiftshader (or the matching software renderer).
- Reduce simultaneous drop-shadow instances; ensure cleanup runs to free shaders/programs.
- Reload to recover from a lost context; update GPU drivers and browser.
- File a Remotion issue if it reproduces on a freshly booted WebGL2-capable desktop browser.
Defensive patterns
Strategy: try-catch
Validate before calling
const supportsWebGL2 = () => {
try {
return !!document.createElement('canvas').getContext('webgl2');
} catch {
return false;
}
};
if (!supportsWebGL2()) {
// omit the drop-shadow effect or render a CSS box-shadow fallback Try / catch
try {
state = setupDropShadow(canvas);
} catch (err) {
if (err instanceof Error && /WebGL shader/i.test(err.message)) {
console.error('Drop-shadow shader allocation failed:', err.message);
// fall back to a CSS box-shadow layer
} else {
throw err;
}
} Prevention
- Feature-detect WebGL2 before applying drop-shadow().
- Run headless rendering with a software GL backend and adequate memory.
- Keep simultaneous drop-shadow instances low; ensure cleanupDropShadow runs.
- Update GPU drivers and the browser.
When it happens
Trigger: Lost WebGL2 context, exhausted shader limit, GPU memory pressure, or headless environment without GPU acceleration. Reached inside setupDropShadow() during initial shader compilation.
Common situations: Headless Chromium without software GL flags; long Studio sessions leaking shaders; GPU driver crash; many drop-shadow instances mounted; remote desktop / VM with passthrough GL.
Related errors
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create WebGL texture
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/184ce24ac079636f.
Report an issue: GitHub.