remotion-dev/remotion · error · Error
Failed to create WebGL shader
Error message
Failed to create WebGL shader
What it means
Thrown by dot-grid's compileShader helper when gl.createShader() returns null. A null shader means the WebGL2 context could not allocate a new shader object — almost always a sign of a lost, destroyed, or resource-exhausted context rather than a code defect, because the bundled GLSL has not yet been uploaded at this point.
Source
Thrown at packages/effects/src/dot-grid.ts:158
program: WebGLProgram;
vao: WebGLVertexArrayObject;
vbo: WebGLBuffer;
texture: WebGLTexture;
uSource: WebGLUniformLocation | null;
uResolution: WebGLUniformLocation | null;
uDotSize: WebGLUniformLocation | null;
uGridSize: WebGLUniformLocation | null;
uInvert: 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(`Dot grid shader compile failed: ${log ?? '(no log)'}`);
}
return shader;
};
const linkProgram = (
gl: WebGL2RenderingContext,
vs: WebGLShader,
fs: WebGLShader,
): WebGLProgram => {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Verify WebGL2 is supported on the target before mounting: const gl = canvas.getContext('webgl2'); if (!gl) fallback();
- For headless rendering (Lambda/CI), run Chrome with --use-gl=angle --use-angle=swiftshader (or the equivalent WebGL software renderer for your Chromium build).
- Close other tabs / free GPU memory and reload; if the context was lost it may recover.
- Update GPU drivers and the browser to the latest stable version.
- Report a Remotion issue if the error reproduces on a freshly booted, WebGL2-capable desktop browser.
Defensive patterns
Strategy: try-catch
Validate before calling
const supportsWebGL2 = () => {
try {
const c = document.createElement('canvas');
return !!c.getContext('webgl2');
} catch {
return false;
}
};
if (!supportsWebGL2()) {
// omit the dotGrid() effect or render a static fallback layer
} Try / catch
let state;
try {
state = dotGrid().setup(canvas);
} catch (err) {
if (err instanceof Error && /WebGL/.test(err.message)) {
// log, fall back to a non-WebGL layer, or surface a user-facing message
console.error('dot-grid unavailable on this device:', err.message);
} else {
throw err;
}
} Prevention
- Feature-detect WebGL2 before mounting effects that use it.
- Run headless rendering with a software GL backend (SwiftShader) and adequate memory.
- Keep total simultaneously mounted WebGL2 effects low; ensure cleanup runs on unmount.
- Update GPU drivers and the browser to a stable version.
When it happens
Trigger: The WebGL2 context was lost (tab backgrounded, GPU reset, too many contexts), the GPU driver crashed, the browser is running in a headless environment without GPU acceleration, or the device hit its per-context shader limit. The throw happens inside dotGrid()'s setup() the first time the effect is mounted.
Common situations: Running Remotion Lambda or headless Chromium without SwiftShader/software GL flags; long-running Studio sessions that leaked contexts; CI without --enable-webgl or --use-gl=swiftshader; VMs with no GPU; laptops in battery-saver mode that suspended the GPU.
Related errors
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
- Failed to create WebGL texture
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/5d8a16e4ceeaf31f.
Report an issue: GitHub.