remotion-dev/remotion · error · Error

Failed to create WebGL texture

Error message

Failed to create WebGL texture

What it means

Thrown by pixelDissolve setup when gl.createTexture() returns null after the program, VAO, VBO, and attribute wiring all succeeded. Textures are typically the most memory-hungry GL resource, so this is the most common allocation to fail when the GPU is under texture-memory pressure.

Source

Thrown at packages/effects/src/pixel-dissolve.ts:308

		const vs = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);
		const fs = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
		const program = linkProgram(gl, vs, fs);
		gl.deleteShader(vs);
		gl.deleteShader(fs);

		const {vao, vbo} = createFullscreenQuad(gl);
		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');
		}

		gl.bindTexture(gl.TEXTURE_2D, texture);
		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.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
		gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
		gl.bindTexture(gl.TEXTURE_2D, null);

		return {
			gl,
			program,
			vao,
			vbo,
			texture,
			uSource: gl.getUniformLocation(program, 'uSource'),
			uProgress: gl.getUniformLocation(program, 'uProgress'),
			uColumns: gl.getUniformLocation(program, 'uColumns'),

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Lower the composition resolution or the source asset dimensions and re-render — texture allocation scales with frame pixel count.
  2. Check `gl.getParameter(gl.MAX_TEXTURE_SIZE)` against your source dimensions and downscale assets that exceed it.
  3. Increase Remotion Lambda function memory so SwiftShader has more texture budget.
  4. Run fewer simultaneous texture-backed effects in one composition.
  5. Verify the context is not lost with `gl.isContextLost()` and remount the effect if it is.

Example fix

// before
import {pixelDissolve} from '@remotion/effects';
const effect = pixelDissolve();

// after — gate on texture-size limits before mounting
function supportsTextureForSize(w: number, h: number): boolean {
  const c = document.createElement('canvas');
  const gl = c.getContext('webgl2');
  if (!gl) return false;
  const maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) as number;
  return w <= maxSize && h <= maxSize && !gl.isContextLost();
}
Defensive patterns

Strategy: try-catch

Validate before calling

function textureFitsMax(gl: WebGL2RenderingContext, w: number, h: number): boolean {
  if (gl.isContextLost()) return false;
  const max = gl.getParameter(gl.MAX_TEXTURE_SIZE) as number;
  return w <= max && h <= max;
}
// also probe allocation:
function glCanCreateTexture(gl: WebGL2RenderingContext): boolean {
  const t = gl.createTexture();
  if (t) gl.deleteTexture(t);
  return t !== null;
}

Try / catch

try {
  pixelDissolve();
} catch (err) {
  if (/Failed to create WebGL texture/.test((err as Error).message)) {
    // downscale source asset or reduce composition resolution, then retry
  }
  throw err;
}

Prevention

When it happens

Trigger: pixelDissolve setup reaches createTexture() in the final block of the setup function; all earlier GL objects were created successfully but the texture unit cannot allocate. Often paired with large source video frames being uploaded to the same context.

Common situations: Rendering high-resolution (4K+) video where each frame uploads a fresh texture; many effects sharing a context; mobile or integrated GPUs with small VRAM; SwiftShader on Lambda with a memory-starved function; the source image exceeds MAX_TEXTURE_SIZE on the implementation.

Related errors


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