{"record":{"id":"73262781fff79e0a","repo":"remotion-dev/remotion","slug":"failed-to-create-lut-source-texture","errorCode":null,"errorMessage":"Failed to create LUT source texture","messagePattern":"Failed to create LUT source texture","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/effects/src/lut/lut-runtime.ts","lineNumber":75,"sourceCode":"\tgl.attachShader(program, vertexShader);\n\tgl.attachShader(program, fragmentShader);\n\tgl.linkProgram(program);\n\tgl.deleteShader(vertexShader);\n\tgl.deleteShader(fragmentShader);\n\n\tif (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n\t\tconst log = gl.getProgramInfoLog(program);\n\t\tgl.deleteProgram(program);\n\t\tthrow new Error(`LUT shader link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\nconst createSourceTexture = (gl: WebGL2RenderingContext): WebGLTexture => {\n\tconst texture = gl.createTexture();\n\tif (!texture) {\n\t\tthrow new Error('Failed to create LUT source 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 createLutTexture = (gl: WebGL2RenderingContext): WebGLTexture => {\n\tconst texture = gl.createTexture();\n\tif (!texture) {\n\t\tthrow new Error('Failed to create LUT texture');\n\t}\n\n\tgl.bindTexture(gl.TEXTURE_3D, texture);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/effects/src/lut/lut-runtime.ts#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Listen for 'webglcontextlost' on the canvas and re-initialize the effect once 'webglcontextrestored' fires","Check gl.isContextLost() before rendering and recreate the context/figure if lost","Reduce the number of concurrent GL resources/effects so the context is not exhausted","Reload the page or recreate the canvas to obtain a fresh WebGL2 context"],"exampleFix":"// before: calling the effect on a possibly-dead context\napplyLut(state, content);\n// after: guard against context loss\nif (state.gl.isContextLost()) {\n  throw new Error('WebGL context lost - recreate before applying LUT');\n}\napplyLut(state, content);","handlingStrategy":"try-catch","validationCode":"if (gl.isContextLost()) {\n  throw new Error('WebGL context lost; cannot create LUT source texture');\n}","typeGuard":null,"tryCatchPattern":"try {\n  state = setupLut({ gl, width, height, lutContent });\n} catch (e) {\n  if (e.message === 'Failed to create LUT source texture') {\n    canvas.addEventListener('webglcontextrestored', () => reinit(), { once: true });\n  }\n}","preventionTips":["Register 'webglcontextlost' (preventDefault) and 'webglcontextrestored' handlers on the canvas","Check gl.isContextLost() before each render pass","Avoid leaking GL textures across effect re-mounts","Test long sessions on mobile browsers where context loss is common"],"tags":["webgl","texture","context-lost","lut"],"backgroundTag":"module-init-failed","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}