remotion-dev/remotion · error · Error

Failed to create WebGL program

Error message

Failed to create WebGL program

What it means

Thrown by linkProgram in contour-lines.ts when gl.createProgram() returns null. The WebGL2 context was acquired but could not allocate a program object. Like shader creation failure, this indicates GPU resource exhaustion or a lost context rather than a user input problem.

Source

Thrown at packages/effects/src/contour-lines.ts:376

	if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
		const log = gl.getShaderInfoLog(shader);
		gl.deleteShader(shader);
		throw new Error(
			`Contour 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(`Contour 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. Reduce the number of concurrently active WebGL effects.
  2. Verify the GPU/context is healthy — check gl.isContextLost() before relying on the effect.
  3. Use a rendering environment with adequate GPU resources (hardware-accelerated Chrome rather than a constrained headless setup).
  4. Handle webglcontextlost to reinitialize effects after recovery.
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify context is healthy before applying WebGL effects
const gl = target.getContext('webgl2');
if (gl?.isContextLost()) {
  // defer or skip the effect
}

Try / catch

try {
  contourLines({...})(source, target);
} catch (e) {
  if (e instanceof Error && e.message === 'Failed to create WebGL program') {
    // GPU resource exhaustion or context loss
  }
  throw e;
}

Prevention

When it happens

Trigger: During setupContourLines, after both vertex and fragment shaders compile successfully, gl.createProgram() returns null. This is reached only when the contour-lines effect initializes its WebGL pipeline.

Common situations: Too many WebGL programs allocated across effects in a single render; GPU memory pressure; context lost between shader compilation and program creation; running on a constrained software WebGL implementation in CI or a VM.

Related errors


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