remotion-dev/remotion · critical · Error

Failed to create WebGL buffer

Error message

Failed to create WebGL buffer

What it means

In the `setup` callback, `gl.createBuffer()` returned `null`. WebGL2 returns null on context loss or resource exhaustion; the vertex array was created just before this, so it is an environment/resource failure. The buffer holds the fullscreen-quad vertex data.

Source

Thrown at packages/brand/src/effects/metallic-swirl-effect.ts:563

		const fs = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
		const program = linkProgram(gl, vs, fs);
		gl.deleteShader(vs);
		gl.deleteShader(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 texture = gl.createTexture();
		if (!texture) {
			throw new Error('Failed to create WebGL texture');
		}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Reduce the number of simultaneously mounted WebGL2 effects.
  2. Ensure effects are unmounted/disposed so GL resources are freed.
  3. Update GPU drivers / use a hardware-accelerated browser.
  4. Verify the WebGL2 context is healthy before mounting many effects.
Defensive patterns

Strategy: try-catch

Validate before calling

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

Type guard

const hasHealthyWebGL2 = (canvas: HTMLCanvasElement): boolean => {
  const gl = canvas.getContext('webgl2');
  return !!gl && !gl.isContextLost();
};

Try / catch

try {
  metallicSwirl({speed: 1})(...);
} catch (err) {
  if (err instanceof Error && /Failed to create WebGL buffer/.test(err.message)) {
    // reduce effect count or fall back
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: WebGL2 context lost mid-setup; GPU buffer/object limit reached after many effects; software WebGL2 backend that cannot allocate buffers; driver instability.

Common situations: Many simultaneous WebGL2 effects; leaked buffers across remounts; long sessions; under-resourced or virtualized GPUs.

Related errors


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