remotion-dev/remotion · critical · Error

Failed to create WebGL buffer

Error message

Failed to create WebGL buffer

What it means

Thrown by setupNoise (packages/effects/src/noise.ts:215) when gl.createBuffer() returns null while allocating the quad vertex buffer for the noise effect. Null indicates a lost WebGL2 context or exhausted buffer/GPU-memory budget.

Source

Thrown at packages/effects/src/noise.ts:215

	const fs = compileShader(gl, gl.FRAGMENT_SHADER, NOISE_FS);
	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. Ensure gl.deleteBuffer runs in cleanup between compositions and cap concurrent WebGL2 effects.
  2. Render on a GPU host with WebGL enabled in headless Chrome.
  3. Handle 'webglcontextlost' and re-render after restore.

Example fix

// before
const vbo = gl.createBuffer(); // null -> throws

// after
if (gl.isContextLost()) {
  throw new Error('WebGL2 context lost; cannot create noise buffer');
}
Defensive patterns

Strategy: try-catch

Validate before calling

function canCreateNoiseBuffer(): boolean {
  try {
    const c = document.createElement('canvas');
    const gl = c.getContext('webgl2');
    if (!gl || gl.isContextLost()) return false;
    const b = gl.createBuffer();
    const ok = !!b;
    if (b) gl.deleteBuffer(b);
    return ok;
  } catch {
    return false;
  }
}

Try / catch

try {
  scene.push(noise({amount: 0.2}));
} catch (err) {
  if (/Failed to create WebGL buffer/.test(String(err?.message))) {
    // buffer budget exhausted or context lost: omit the effect
  } else throw err;
}

Prevention

When it happens

Trigger: Applying noise() when the context is lost or GPU memory is full; many concurrent noise/WebGL2 effects past the per-context buffer limit.

Common situations: GPU-less headless CI under SwiftShader pressure; leaked buffers across a long session; GPU process crash during render.

Related errors


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