remotion-dev/remotion · error · Error

Failed to create levels texture

Error message

Failed to create levels texture

What it means

Thrown by `createTexture()` in the levels effect when `gl.createTexture()` returns `null`. The WebGL2 context cannot allocate another texture object — usually because the context is lost or the GPU has run out of texture memory/object slots.

Source

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

	gl.attachShader(program, vertexShader);
	gl.attachShader(program, fragmentShader);
	gl.linkProgram(program);
	gl.deleteShader(vertexShader);
	gl.deleteShader(fragmentShader);

	if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
		const log = gl.getProgramInfoLog(program);
		gl.deleteProgram(program);
		throw new Error(`Levels shader link failed: ${log ?? '(no log)'}`);
	}

	return program;
};

const createTexture = (gl: WebGL2RenderingContext): WebGLTexture => {
	const texture = gl.createTexture();
	if (!texture) {
		throw new Error('Failed to create levels texture');
	}

	gl.bindTexture(gl.TEXTURE_2D, texture);
	gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
	gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
	gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
	gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
	gl.bindTexture(gl.TEXTURE_2D, null);
	return texture;
};

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

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Reduce per-frame texture pressure: fewer concurrent effects, lower concurrency.
  2. Ensure prior WebGL resources are disposed so textures aren't leaked across frames.
  3. Handle context-loss events and recreate the effect on restore.
  4. Render on an instance with more GPU VRAM.
Defensive patterns

Strategy: try-catch

Try / catch

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

Prevention

When it happens

Trigger: Context loss mid-setup; excessive simultaneous texture allocations across many effects/frames; GPU VRAM exhaustion on large-frame renders.

Common situations: High-resolution renders with many layered effects; long-running renders that leak textures; CI instances with limited video memory.

Related errors


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