remotion-dev/remotion · error · Error

Failed to create WebGL buffer

Error message

Failed to create WebGL buffer

What it means

Zigzag setup allocates a vertex buffer (gl.createBuffer) to upload the fullscreen-quad vertices; a null return means the GL context refused another buffer object, so the effect throws before configuring attributes. Like the other null-resource throws, it reflects a lost/limited GL context rather than any parameter.

Source

Thrown at packages/effects/src/zigzag.ts:443

	gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);

	const program = createProgram(gl, ZIGZAG_VS, ZIGZAG_FS);

	const vao = gl.createVertexArray();
	if (!vao) {
		throw new Error('Failed to create WebGL vertex array');
	}

	gl.bindVertexArray(vao);

	const data = new Float32Array([
		-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,
	]);

	const vbo = gl.createBuffer();
	if (!vbo) {
		throw new Error('Failed to create WebGL buffer');
	}

	gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
	gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);

	const aPos = gl.getAttribLocation(program, 'aPos');
	const aUv = gl.getAttribLocation(program, 'aUv');
	gl.enableVertexAttribArray(aPos);
	gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
	gl.enableVertexAttribArray(aUv);
	gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);

	gl.bindVertexArray(null);

	const colorCanvas = document.createElement('canvas');
	colorCanvas.width = 1;
	colorCanvas.height = 1;
	const colorCtx = colorCanvas.getContext('2d', {willReadFrequently: true});

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Ensure the render browser exposes a working WebGL2 context that is not lost.
  2. Render with Remotion's bundled Chromium (CLI/Lambda) with the software GPU path enabled.
  3. Reduce concurrent WebGL contexts by rendering effects in fewer parallel compositions.
  4. Recover from webglcontextlost by unmounting and re-mounting the composition.
  5. Update GPU drivers / backend where allocation fails.
Defensive patterns

Strategy: try-catch

Validate before calling

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

Type guard

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

Try / catch

try {
  return <VideoEffects effects={[zigzag({colors: ['#ff0000', '#00ff00']})]} />;
} catch (err) {
  if (err instanceof Error && err.message === 'Failed to create WebGL buffer') {
    return <Video />;
  }
  throw err;
}

Prevention

When it happens

Trigger: setupZigzag calls gl.createBuffer() and receives null on the first zigzag frame.

Common situations: Headless render farm without working GPU acceleration; long-running session leaking GL objects; many effects each holding their own context; VM/Remote-Desktop GPU forwarding dropping buffer allocation.

Related errors


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