remotion-dev/remotion · critical · Error
Failed to create WebGL shader
Error message
Failed to create WebGL shader
What it means
Thrown by compileShader (packages/effects/src/noise.ts:148) when gl.createShader(type) returns null while compiling the noise effect's vertex or fragment shader. A null shader object indicates a lost WebGL2 context or exhausted GL object budget; the shader source itself is not yet involved at this line.
Source
Thrown at packages/effects/src/noise.ts:148
return;
}
float noise = random(gl_FragCoord.xy) - 0.5;
vec3 rgb = texColor.rgb / alpha;
vec3 noiseLayer = uPremultiply ? rgb * noise : vec3(noise);
rgb = clamp(rgb + noiseLayer * uAmount, 0.0, 1.0);
fragColor = vec4(rgb * alpha, alpha);
}
`;
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(`Noise 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 on a GPU-capable host / GPU-enabled headless Chrome so createShader can allocate.
- Handle 'webglcontextlost' and re-run setup after 'webglcontextrestored' instead of reusing a dead context.
- Reduce concurrent WebGL2 effects so the shader-object budget is not exhausted.
Example fix
// before
const vs = compileShader(gl, gl.VERTEX_SHADER, NOISE_VS); // createShader() returned null
// after: verify the context is alive before compiling
if (gl.isContextLost()) {
throw new Error('WebGL2 context lost before noise setup; retry after restore');
} Defensive patterns
Strategy: try-catch
Validate before calling
function canCompileNoiseShader(): boolean {
try {
const c = document.createElement('canvas');
const gl = c.getContext('webgl2');
if (!gl || gl.isContextLost()) return false;
const s = gl.createShader(gl.VERTEX_SHADER);
const ok = !!s;
if (s) gl.deleteShader(s);
return ok;
} catch {
return false;
}
} Try / catch
try {
scene.push(noise({amount: 0.2}));
} catch (err) {
if (/Failed to create WebGL shader/.test(String(err?.message))) {
// context unhealthy: skip noise and retry render after restore
} else throw err;
} Prevention
- Render on a GPU host with WebGL enabled in headless Chrome.
- Handle webglcontextlost and re-create the effect after webglcontextrestored.
- Avoid reusing a context after a loss without re-running setup.
When it happens
Trigger: setupNoise compiling NOISE_VS/NOISE_FS on a canvas whose WebGL2 context was just lost or whose GPU resources are exhausted; compiling after a prior context-loss event that was not handled.
Common situations: GPU process crash mid-render; rendering on a host without usable WebGL2; context lost during a heavy parallel render and never restored.
Related errors
- Noise shader compile failed: ${log ?? '(no log)'}
- 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/3c882f78e8f3ca37.
Report an issue: GitHub.