remotion-dev/remotion · critical · Error

Failed to create WebGL program

Error message

Failed to create WebGL program

What it means

A plain Error thrown by linkProgram in the Lines effect when gl.createProgram() returns null. Like createShader, the WebGL2 spec permits null under resource exhaustion or context loss; the Lines effect fails fast rather than proceeding with a null program.

Source

Thrown at packages/effects/src/lines.ts:328

	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(`Lines 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(`Lines program link failed: ${log ?? '(no log)'}`);
	}

	return program;
};

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

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Lower concurrency in the render (fewer parallel browser pages / Chromium instances).
  2. Restart the render if a one-off context-loss event corrupted GPU state.
  3. Verify the host has adequate GPU memory / a stable software GL backend for headless runs.
Defensive patterns

Strategy: try-catch

Validate before calling

function canAllocateProgram(): boolean {
  const c = document.createElement('canvas');
  const gl = c.getContext('webgl2');
  if (!gl) return false;
  return !!gl.createProgram();
}

Try / catch

try {
  lines(...);
} catch (err) {
  if (err instanceof Error && /WebGL program/.test(err.message)) {
    // reduce concurrency, restart the page/context, then retry
  } else throw err;
}

Prevention

When it happens

Trigger: The WebGL2 context is alive but cannot allocate a program object — typically GPU memory exhaustion, too many live programs, or a recently lost context. Occurs after the vertex and fragment shaders have already compiled successfully.

Common situations: Running many concurrent Remotion browser contexts that each compile WebGL programs; long-running render sessions that leak programs; headless environments with constrained software GL.

Related errors


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