{"record":{"id":"81d5a8da28fe3fea","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-81d5a8","errorCode":null,"errorMessage":"Failed to create WebGL texture","messagePattern":"Failed to create WebGL texture","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/contour-lines.ts","lineNumber":407,"sourceCode":"};\n\nconst createProgram = (\n\tgl: WebGL2RenderingContext,\n\tvertexSource: string,\n\tfragmentSource: string,\n): WebGLProgram => {\n\tconst vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);\n\tconst fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);\n\tconst program = linkProgram(gl, vs, fs);\n\tgl.deleteShader(vs);\n\tgl.deleteShader(fs);\n\treturn program;\n};\n\nconst createTexture = (gl: WebGL2RenderingContext): WebGLTexture => {\n\tconst texture = gl.createTexture();\n\tif (!texture) {\n\t\tthrow new Error('Failed to create WebGL texture');\n\t}\n\n\tgl.bindTexture(gl.TEXTURE_2D, texture);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\tgl.bindTexture(gl.TEXTURE_2D, null);\n\treturn texture;\n};\n\nconst setupContourLines = (target: HTMLCanvasElement): ContourLinesState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,\n\t\tpreserveDrawingBuffer: true,\n\t});\n\tif (!gl) {","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/contour-lines.ts#L389-L425","documentation":"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.","triggerScenarios":"During setupContourLines, createTexture(gl) is called to allocate the source texture, and gl.createTexture() returns null.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check context health before applying textured effects\nconst gl = target.getContext('webgl2');\nif (gl?.isContextLost()) {\n  // defer or skip\n}","typeGuard":null,"tryCatchPattern":"try {\n  contourLines({...})(source, target);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL texture') {\n    // reduce concurrent texture-using effects or use a better GPU environment\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["webgl","effects","contour-lines","gpu","resource-exhaustion","texture"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}