remotion-dev/remotion · error · Error

Failed to create program

Error message

Failed to create program

What it means

White noise setup calls gl.createProgram to link its vertex+fragment shaders; a null return means the GL context could not allocate the program object, so the effect cannot form a runnable pipeline and throws. The shader objects themselves compiled fine — this is purely a context/resource allocation failure (lost context, program-object limit, software renderer).

Source

Thrown at packages/effects/src/white-noise.ts:133

	if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
		const info = gl.getShaderInfoLog(shader) ?? 'Unknown shader compile error';
		gl.deleteShader(shader);
		throw new Error(info);
	}

	return shader;
};

const createProgram = (
	gl: WebGL2RenderingContext,
	vertexSource: string,
	fragmentSource: string,
): WebGLProgram => {
	const vertex = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
	const fragment = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
	const program = gl.createProgram();
	if (!program) {
		throw new Error('Failed to create program');
	}

	gl.attachShader(program, vertex);
	gl.attachShader(program, fragment);
	gl.linkProgram(program);
	gl.deleteShader(vertex);
	gl.deleteShader(fragment);

	if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
		const info = gl.getProgramInfoLog(program) ?? 'Unknown program link error';
		gl.deleteProgram(program);
		throw new Error(info);
	}

	return program;
};

const createWhiteNoiseState = (

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Verify WebGL2 context health (non-null getContext('webgl2'), isContextLost() false) before rendering.
  2. Use Remotion's bundled Chrome for headless rendering; avoid disabling the software GPU.
  3. Reduce the number of simultaneously active WebGL effects to free program-object slots.
  4. Recreate the composition on webglcontextlost so setup re-runs cleanly.
  5. Update GPU drivers or move to a host with a fully conformant WebGL2 implementation.
Defensive patterns

Strategy: try-catch

Validate before calling

const gl = document.createElement('canvas').getContext('webgl2');
const webglOk = gl != null && gl.createProgram() != null && !gl.isContextLost();

Type guard

const canCreateProgram = (): boolean => {
  const gl = document.createElement('canvas').getContext('webgl2');
  return gl != null && !gl.isContextLost() && gl.createProgram() != null;
};

Try / catch

try {
  return <VideoEffects effects={[whiteNoise({amount: 0.4})]} />;
} catch (err) {
  if (err instanceof Error && err.message === 'Failed to create program') {
    return <Video />;
  }
  throw err;
}

Prevention

When it happens

Trigger: createProgram in white-noise.ts: gl.createProgram() returns null after both shaders compiled successfully.

Common situations: Context lost between shader compile and program create; too many program objects alive across many concurrent effects; headless renderer with incomplete WebGL2 program allocation; GPU memory pressure.

Related errors


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