remotion-dev/remotion · error · Error

Failed to create levels vertex array

Error message

Failed to create levels vertex array

What it means

Thrown by `setupLevels()` when `gl.createVertexArray()` returns `null`. A VAO allocation failing indicates the WebGL2 context is lost or out of object memory; the effect's geometry bindings cannot be captured and setup aborts.

Source

Thrown at packages/effects/src/levels.ts:228

	return texture;
};

const setupLevels = (target: HTMLCanvasElement): LevelsState => {
	const gl = target.getContext('webgl2', {
		premultipliedAlpha: true,
		alpha: true,
		preserveDrawingBuffer: true,
	});
	if (!gl) {
		throw createWebGL2ContextError('levels effect');
	}

	gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);

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

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

	gl.bindVertexArray(vao);
	gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
	gl.bufferData(
		gl.ARRAY_BUFFER,
		new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1]),
		gl.STATIC_DRAW,
	);

	const aPos = gl.getAttribLocation(program, 'aPos');
	const aUv = gl.getAttribLocation(program, 'aUv');
	gl.enableVertexAttribArray(aPos);

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Lower concurrency and reuse/dispose VAOs to avoid object-slot exhaustion.
  2. Handle `webglcontextlost` and rebuild the effect after restore.
  3. Restart Chrome/GPU process to clear leaked objects.
  4. Render on a GPU-backed environment rather than a constrained software renderer.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  levels({...})(...);
} catch (err) {
  if (/Failed to create levels vertex array/.test(String(err))) {
    console.warn('levels() VAO unavailable', err);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Context lost before VAO creation; too many VAOs allocated across concurrent effects; a non-VAO-supporting WebGL2 fallback (rare, since VAOs are core in WebGL2).

Common situations: Concurrent renders each spinning up their own VAO; a suspended/backgrounded tab whose context was torn down; VRAM/object-slot exhaustion.

Related errors


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