remotion-dev/remotion · error · Error

Failed to create WebGL texture

Error message

Failed to create WebGL texture

What it means

Thrown by createRgbaTexture in corner-pin-runtime.ts when gl.createTexture() returns null. The WebGL2 context was acquired but could not allocate a texture object for the source image. This is a GPU resource issue, not related to corner-pin parameters.

Source

Thrown at packages/effects/src/corner-pin/corner-pin-runtime.ts:81

};

const createProgram = (
	gl: WebGL2RenderingContext,
	vertexSource: string,
	fragmentSource: string,
): WebGLProgram => {
	const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
	const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
	const program = linkProgram(gl, vs, fs);
	gl.deleteShader(vs);
	gl.deleteShader(fs);
	return program;
};

const createRgbaTexture = (gl: WebGL2RenderingContext): WebGLTexture => {
	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 texture;
};

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

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Reduce the number of simultaneously active texture-using WebGL effects.
  2. Check gl.isContextLost() and handle restoration.
  3. Use a rendering environment with adequate GPU resources.
  4. Ensure hardware-accelerated Chrome for headless rendering.
Defensive patterns

Strategy: try-catch

Validate before calling

// Check context health before applying corner pin
const gl = target.getContext('webgl2');
if (gl?.isContextLost()) {
  // defer or skip
}

Try / catch

try {
  cornerPin({...})(source, target);
} catch (e) {
  if (e instanceof Error && e.message === 'Failed to create WebGL texture') {
    // reduce concurrent texture-using effects or use a better GPU environment
  }
  throw e;
}

Prevention

When it happens

Trigger: During setupCornerPin, createRgbaTexture(gl) is called to allocate the source texture, and gl.createTexture() returns null.

Common situations: Exceeding maximum texture object count on the GPU; context lost; memory pressure from many simultaneous textured effects; constrained software WebGL in CI/VM/headless environments.

Related errors


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