remotion-dev/remotion · error

Failed to create LUT source texture

Error message

Failed to create LUT source texture

What it means

createSourceTexture() calls gl.createTexture() to allocate the 2D texture that receives the source frame. WebGL's createTexture returns null when the context cannot allocate a new texture object (most commonly because the context is lost or resources are exhausted). The library throws this Error instead of silently continuing with an invalid texture.

Solutions

  1. Listen for 'webglcontextlost' on the canvas and re-initialize the effect once 'webglcontextrestored' fires
  2. Check gl.isContextLost() before rendering and recreate the context/figure if lost
  3. Reduce the number of concurrent GL resources/effects so the context is not exhausted
  4. Reload the page or recreate the canvas to obtain a fresh WebGL2 context

Example fix

// before: calling the effect on a possibly-dead context
applyLut(state, content);
// after: guard against context loss
if (state.gl.isContextLost()) {
  throw new Error('WebGL context lost - recreate before applying LUT');
}
applyLut(state, content);
Defensive patterns

Strategy: try-catch

Validate before calling

if (gl.isContextLost()) {
  throw new Error('WebGL context lost; cannot create LUT source texture');
}

Try / catch

try {
  state = setupLut({ gl, width, height, lutContent });
} catch (e) {
  if (e.message === 'Failed to create LUT source texture') {
    canvas.addEventListener('webglcontextrestored', () => reinit(), { once: true });
  }
}

Prevention

When it happens

Trigger: setupLut runs while the WebGL2 context is lost (GPU reset, tab backgrounded on mobile, 'webglcontextlost' fired) or after the context has hit its object-count/resource limits.

Common situations: Mobile Safari/Chrome killing GPU processes of backgrounded tabs; GPU driver crashes mid-render; extremely long-running sessions accumulating leaked GL objects; running inside a headless browser with a stub GL implementation returning null.

Related errors


AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18). Data as JSON: /api/errors/73262781fff79e0a. Report an issue: GitHub.

Appendix: source

Thrown at packages/effects/src/lut/lut-runtime.ts:75

	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(`LUT shader link failed: ${log ?? '(no log)'}`);
	}

	return program;
};

const createSourceTexture = (gl: WebGL2RenderingContext): WebGLTexture => {
	const texture = gl.createTexture();
	if (!texture) {
		throw new Error('Failed to create LUT source 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 createLutTexture = (gl: WebGL2RenderingContext): WebGLTexture => {
	const texture = gl.createTexture();
	if (!texture) {
		throw new Error('Failed to create LUT texture');
	}

	gl.bindTexture(gl.TEXTURE_3D, texture);

View on GitHub (pinned to 46a3a6bf13)