{"record":{"id":"2c2fe986e32f8cbd","repo":"remotion-dev/remotion","slug":"failed-to-create-lut-texture","errorCode":null,"errorMessage":"Failed to create LUT texture","messagePattern":"Failed to create LUT texture","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/effects/src/lut/lut-runtime.ts","lineNumber":90,"sourceCode":"const 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);\n\tgl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n\tgl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n\tgl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\tgl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\tgl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE);\n\tgl.bindTexture(gl.TEXTURE_3D, null);\n\treturn texture;\n};\n\nexport const setupLut = (target: HTMLCanvasElement): LutState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,\n\t\tpreserveDrawingBuffer: true,\n\t});","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/effects/src/lut/lut-runtime.ts#L72-L108","documentation":"createLutTexture() calls gl.createTexture() to allocate the TEXTURE_3D object that holds the parsed .cube LUT data. If the WebGL2 implementation returns null it cannot create the texture object, and this Error is thrown. As with other null returns from gl.create*, throwing early prevents operating on an invalid handle.","triggerScenarios":"setupLut runs on a lost or resource-starved WebGL2 context; the browser/driver fails to allocate 3D texture objects; a stub/gl-mock returns null from createTexture.","commonSituations":"GPU reset during a long render; mobile browsers evicting GL resources; unit tests running against fake WebGL contexts that return null instead of real handles.","solutions":["Handle 'webglcontextlost'/'webglcontextrestored' events and re-run setupLut after restore","Verify the environment provides a real WebGL2 context (not a partial mock)","Reduce simultaneous GL texture usage in the composition","Recreate the canvas/context if the context remains lost"],"exampleFix":"// before: mock GL in tests\nconst gl = { createTexture: () => null };\n// after: use a real WebGL2 context\nconst gl = canvas.getContext('webgl2');\nif (!gl) throw new Error('WebGL2 unavailable');","handlingStrategy":"try-catch","validationCode":"if (gl.isContextLost()) {\n  throw new Error('WebGL context lost; cannot create LUT texture');\n}","typeGuard":null,"tryCatchPattern":"try {\n  state = setupLut({ gl, width, height, lutContent });\n} catch (e) {\n  if (e.message === 'Failed to create LUT texture') {\n    // recreate context or degrade gracefully without the effect\n  }\n}","preventionTips":["Handle context loss/restored events and re-run setupLut after restore","Use real WebGL2 contexts in tests instead of partial mocks","Keep total GL object count low in the composition","Delete unused textures on unmount"],"tags":["webgl","texture3d","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"}