remotion-dev/remotion · error · Error
Failed to create WebGL texture
Error message
Failed to create WebGL texture
What it means
Thrown inside createRgbaTexture() in evolve.ts when gl.createTexture() returns null during setupEvolve(). A null return means the GL implementation could not allocate another texture object — typically because the context is lost or GPU texture memory/object pools are exhausted. No texture can be created, so evolve setup aborts.
Source
Thrown at packages/effects/src/evolve.ts:237
throw new Error('Failed to create WebGL program');
}
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const log = gl.getProgramInfoLog(program);
gl.deleteProgram(program);
throw new Error(`Evolve program link failed: ${log ?? '(no log)'}`);
}
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;
};
const setupEvolve = (target: HTMLCanvasElement): EvolveState => {
const gl = target.getContext('webgl2', {
premultipliedAlpha: true,
alpha: true,
preserveDrawingBuffer: true,
});
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Ensure effects are torn down: rely on Remotion's effect lifecycle so cleanup() runs (it calls gl.deleteTexture); avoid holding references to old effect states.
- Render with --gl=angle (CLI) / chromiumOptions: { gl: 'angle' } (SSR) / Angle backend (Studio) for more reliable texture allocation under SwiftShader.
- Reduce the count of concurrent evolve() instances in the composition and reuse identical param combinations so calculateKey collapses them onto one canvas.
- Handle webglcontextlost on the canvas and trigger a context-restoration flow before retrying the render.
- Move rendering to a host with more GPU memory, or run a software GL fallback consistently.
Example fix
// before
const texture = gl.createTexture();
if (!texture) {
throw new Error('Failed to create WebGL texture');
}
// after (caller-side health check before evolve setup)
if (gl.isContextLost()) {
// wait for webglcontextrestored before re-applying evolve()
return;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Health check before driving evolve on a canvas you control.
const canAllocateTexture = (gl: WebGL2RenderingContext): boolean => {
if (gl.isContextLost()) return false;
const probe = gl.createTexture();
if (!probe) return false;
gl.deleteTexture(probe);
return true;
}; Try / catch
try {
// declarative usage; for a custom canvas:
// const state = setupEvolve(canvas);
} catch (err) {
if (err instanceof Error && err.message === 'Failed to create WebGL texture') {
// likely context loss or exhaustion: free other effects, restore context, retry
throw err;
}
throw err;
} Prevention
- Render with the Angle backend (--gl=angle / chromiumOptions.gl='angle').
- Let Remotion's effect lifecycle manage cleanup() so textures are deleted, not leaked.
- Avoid stacking many evolve() instances in one composition; reuse identical params.
- Monitor webglcontextlost on long-running Studio sessions and restore the context.
When it happens
Trigger: evolve() effect setup runs after a webglcontextlost event (the spec forces createTexture to return null while lost), or when the page has exhausted the driver's texture-object limit by leaking textures across many effect canvases. The check is the bare `if (!texture)` at evolve.ts:236.
Common situations: Long-running Studio sessions where old effect canvases were not cleaned up (cleanup() not called); rendering many simultaneous evolve layers in one composition; headless render hosts with limited GPU memory; a prior crash of the GPU process leaving contexts in a lost state.
Related errors
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
- Failed to create exposure texture
- Failed to create WebGL texture
- Evolve program link failed: ${log ?? '(no log)'}
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/3b2348128a2a7cec.
Report an issue: GitHub.