remotion-dev/remotion · error · Error

Failed to create WebGL program

Error message

Failed to create WebGL program

What it means

Thrown by the drop-shadow runtime's linkProgram helper when gl.createProgram() returns null. As with the shader case, a null program means the WebGL2 context could not allocate another program — context loss or per-context resource exhaustion. The drop-shadow runtime builds four programs, so the first allocation that fails throws.

Source

Thrown at packages/effects/src/drop-shadow/drop-shadow-runtime.ts:79

	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 => {
	const program = gl.createProgram();
	if (!program) {
		throw new Error('Failed to create WebGL program');
	}

	gl.attachShader(program, vs);
	gl.attachShader(program, fs);
	gl.linkProgram(program);
	if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
		const log = gl.getProgramInfoLog(program);
		gl.deleteProgram(program);
		throw new Error(`Drop shadow program link failed: ${log ?? '(no log)'}`);
	}

	return program;
};

const createProgram = (
	gl: WebGL2RenderingContext,
	vertexSource: string,
	fragmentSource: string,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Ensure every drop-shadow instance has cleanupDropShadow invoked (the framework runs cleanup on unmount; do not short-circuit the effect lifecycle).
  2. Reduce the number of simultaneously mounted drop-shadow effects.
  3. Reload to release leaked programs; update GPU drivers.
  4. For headless runs, use a software renderer with adequate memory.
Defensive patterns

Strategy: try-catch

Validate before calling

const supportsWebGL2 = () => {
  try {
    return !!document.createElement('canvas').getContext('webgl2');
  } catch {
    return false;
  }
};

Try / catch

try {
  state = setupDropShadow(canvas);
} catch (err) {
  if (err instanceof Error && /WebGL program/i.test(err.message)) {
    console.error('Drop-shadow program allocation failed:', err.message);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Lost WebGL2 context, exhausted program limit, or GPU memory pressure. Reached inside setupDropShadow() via createProgram() after shaders compile.

Common situations: Many drop-shadow instances leaking programs (cleanup skipped); long Studio sessions; GPU driver crash; headless rendering with a constrained software GL backend.

Related errors


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