{"record":{"id":"0ab169496f8b922f","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-0ab169","errorCode":null,"errorMessage":"Failed to create WebGL texture","messagePattern":"Failed to create WebGL texture","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/thermal-vision.ts","lineNumber":213,"sourceCode":"\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 = (\n\tgl: WebGL2RenderingContext,\n\tfilter: number,\n): 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, filter);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);\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 setupThermalVision = (target: HTMLCanvasElement): ThermalVisionState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,\n\t\tpreserveDrawingBuffer: true,\n\t});\n\tif (!gl) {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/thermal-vision.ts#L195-L231","documentation":"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.","triggerScenarios":"Context lost during setup; GPU texture memory exhausted; too many live GL textures across effects; destroyed GL context.","commonSituations":"Many concurrent webgl2 effects each allocating textures; large palettes across many instances; leaked textures in long Studio sessions; mobile GPUs with low texture caps.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  thermalVision({...params});\n} catch (e) {\n  if (/Failed to create WebGL texture/.test((e as Error).message)) {\n    renderFallbackFrame();\n  } else throw e;\n}","preventionTips":["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."],"tags":["thermal-vision","webgl2","gpu","resource-exhaustion","context-lost","texture","setup"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}