remotion-dev/remotion · error · Error
Failed to create WebGL texture
Error message
Failed to create WebGL texture
What it means
Thrown by createTexture in contour-lines.ts when gl.createTexture() returns null. The WebGL2 context was acquired but could not allocate a texture object. This is a GPU resource issue, not related to user parameters.
Source
Thrown at packages/effects/src/contour-lines.ts:407
};
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 createTexture = (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 setupContourLines = (target: HTMLCanvasElement): ContourLinesState => {
const gl = target.getContext('webgl2', {
premultipliedAlpha: true,
alpha: true,
preserveDrawingBuffer: true,
});
if (!gl) {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Reduce the number of simultaneously active texture-using WebGL effects.
- Ensure GPU resources are adequate for the rendering environment.
- Check gl.isContextLost() and handle context restoration.
- Use hardware-accelerated Chrome for headless rendering rather than a minimal software fallback.
Defensive patterns
Strategy: try-catch
Validate before calling
// Check context health before applying textured effects
const gl = target.getContext('webgl2');
if (gl?.isContextLost()) {
// defer or skip
} Try / catch
try {
contourLines({...})(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
- Reduce the number of simultaneously active texture-using WebGL effects.
- Monitor gl.isContextLost().
- Use a rendering environment with adequate GPU texture resources.
- Handle webglcontextlost for recovery.
When it happens
Trigger: During setupContourLines, createTexture(gl) is called to allocate the source texture, and gl.createTexture() returns null.
Common situations: Exceeding the maximum number of texture objects on the GPU; context lost; memory pressure from many simultaneously active textured effects; constrained software WebGL in CI/VM environments.
Related errors
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create WebGL vertex array
- Failed to create WebGL buffer
- Failed to create WebGL texture
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/81d5a8da28fe3fea.
Report an issue: GitHub.