remotion-dev/remotion · error · Error

Failed to create WebGL shader

Error message

Failed to create WebGL shader

What it means

Thrown by `compileShader()` inside the light-leak effect when `gl.createShader()` returns `null`. The WebGL2 context could not allocate a shader object — context loss, an invalid shader-type enum, or GPU/resource exhaustion. The effect cannot proceed without its shaders.

Source

Thrown at packages/effects/src/light-leak.ts:191

	vbo: WebGLBuffer;
	texture: WebGLTexture;
	uSource: WebGLUniformLocation | null;
	uEvolveProgress: WebGLUniformLocation | null;
	uRetractProgress: WebGLUniformLocation | null;
	uSeed: WebGLUniformLocation | null;
	uRetractSeed: WebGLUniformLocation | null;
	uHueShift: WebGLUniformLocation | null;
	uResolution: 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(`Light leak shader compile failed: ${log ?? '(no log)'}`);
	}

	return shader;
};

const linkProgram = (
	gl: WebGL2RenderingContext,
	vs: WebGLShader,
	fs: WebGLShader,
): WebGLProgram => {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Reduce the count of live WebGL2 contexts (fewer Studio tabs, lower `--concurrency`).
  2. Run headless Chrome with GPU access or a WebGL2-capable software renderer.
  3. Handle `webglcontextlost` and recreate the effect after restore.
  4. Restart the GPU/Chrome process to reclaim leaked objects.
Defensive patterns

Strategy: try-catch

Validate before calling

function glReady(gl: WebGL2RenderingContext | null): boolean {
  if (!gl || gl.isContextLost()) return false;
  const probe = gl.createShader(gl.VERTEX_SHADER);
  if (!probe) return false;
  gl.deleteShader(probe);
  return true;
}

Type guard

const hasWebGL2 = (): boolean =>
  !!document.createElement('canvas').getContext('webgl2');

Try / catch

try {
  lightLeak({...})(...);
} catch (err) {
  if (/Failed to create WebGL shader/.test(String(err))) {
    console.warn('lightLeak() shader unavailable', err);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Context lost before/at shader creation; too many simultaneous WebGL2 contexts (browser cap ~16); GPU unavailable in headless/CI; VRAM/object exhaustion.

Common situations: Many concurrent light-leak/effects previews; headless Chrome with `--disable-gpu`; long-running Studio tabs losing context on suspend; Lambda/CI without a real GPU.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/e71c40b72421bb09. Report an issue: GitHub.