remotion-dev/remotion · critical · Error
Failed to create WebGL texture
Error message
Failed to create WebGL texture
What it means
The `createTexture` helper (used by `setupThermalVision` to allocate the source and palette textures) throws when `gl.createTexture()` returns `null`. The WebGL2 context cannot allocate a texture object, indicating context loss or GPU texture-memory exhaustion. The error fires before texture parameters are set.
Source
Thrown at packages/effects/src/thermal-vision.ts:213
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 createTexture = (
gl: WebGL2RenderingContext,
filter: number,
): 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, filter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
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 setupThermalVision = (target: HTMLCanvasElement): ThermalVisionState => {
const gl = target.getContext('webgl2', {
premultipliedAlpha: true,
alpha: true,
preserveDrawingBuffer: true,
});
if (!gl) {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Reduce concurrent webgl2 effects and palette sizes.
- Restart the render/session to free leaked textures and reset the context.
- Ensure `cleanup` runs (`gl.deleteTexture`) so textures are released between renders.
- Handle `webglcontextlost` and rebuild GL state.
Defensive patterns
Strategy: fallback
Try / catch
try {
thermalVision({...params});
} catch (e) {
if (/Failed to create WebGL texture/.test((e as Error).message)) {
renderFallbackFrame();
} else throw e;
} Prevention
- Limit concurrent webgl2 effects and palette sizes to bound texture usage.
- Ensure `cleanup` runs and deletes textures (`gl.deleteTexture`) between renders.
- Handle `webglcontextlost` to rebuild texture state.
When it happens
Trigger: Context lost during setup; GPU texture memory exhausted; too many live GL textures across effects; destroyed GL context.
Common situations: Many concurrent webgl2 effects each allocating textures; large palettes across many instances; leaked textures in long Studio sessions; mobile GPUs with low texture caps.
Related errors
- Failed to create WebGL palette texture
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/0ab169496f8b922f.
Report an issue: GitHub.