remotion-dev/remotion · error · Error

Failed to create WebGL texture

Error message

Failed to create WebGL texture

What it means

pattern() allocates a texture to receive the source image. gl.createTexture() returns null when the context is lost or the driver refuses the allocation (e.g. texture limits hit). This guard fails before bindTexture/texParameteri would operate on null.

Source

Thrown at packages/effects/src/pattern.ts:495

		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');
		}

		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 {
			gl,
			program,
			vao,
			vbo,
			texture,
			uniforms: {
				uSource: gl.getUniformLocation(program, 'uSource'),
				uResolution: gl.getUniformLocation(program, 'uResolution'),

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Keep a live WebGL2 context (handle webglcontextlost/restored).
  2. Reduce the number of textures loaded simultaneously in the composition.
  3. Lower source image resolutions where possible.
  4. Use a GPU/SwiftShader backend with adequate texture limits in headless rendering.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  initPattern(canvas); // allocates the source texture
} catch (err) {
  if (isContextLost(canvas)) waitForRestore(canvas).then(initPattern);
  else throw err;
}

Prevention

When it happens

Trigger: Reached in pattern()'s initializer after the VAO/VBO are set up and unbound. gl.createTexture() returns null due to context loss or because the composition has exhausted the driver's texture budget.

Common situations: Compositions with many image/effect layers exceeding texture limits; context loss during render; headless GPU with a low texture cap; long-running Studio sessions.

Related errors


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