{"record":{"id":"a8ed932cfe9d7d91","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-a8ed93","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/color-key.ts","lineNumber":244,"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 createRgbaTexture = (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 setupColorKey = (target: HTMLCanvasElement): ColorKeyState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,\n\t\tpreserveDrawingBuffer: true,\n\t});\n\tif (!gl) {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/color-key.ts#L226-L262","documentation":"Thrown by createRgbaTexture in the color key effect when gl.createTexture() returns null. The GL context cannot allocate another texture object, indicating resource/memory exhaustion or context loss. The color key effect needs the source texture for frame pixels, so setup aborts.","triggerScenarios":"At color-key.ts:244 inside setupColorKey (createRgbaTexture) after the program, VAO, and VBO are built. gl.createTexture() returns null under GL object/memory pressure or a lost context; not caused by colorKey() params.","commonSituations":"High render concurrency, software GL with low texture limits, GPU memory pressure, or context loss during a long render.","solutions":["Reduce render concurrency so fewer textures are live.","Render with GPU acceleration instead of software GL.","Update drivers/Chrome and retry for transient context loss.","Fewer concurrent WebGL effects reduces texture allocation."],"exampleFix":"// before\nremotion render main --concurrency=8\n\n// after\nremotion render main --concurrency=1","handlingStrategy":"retry","validationCode":"function webgl2TextureAvailable(): boolean {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl) return false;\n    const t = gl.createTexture();\n    const ok = t !== null;\n    if (t) gl.deleteTexture(t);\n    return ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await renderMedia({...});\n} catch (err) {\n  if (/Failed to create WebGL texture/i.test(String(err))) {\n    await renderMedia({...opts, concurrency: 1});\n  } else {\n    throw err;\n  }\n}","preventionTips":["Lower render concurrency to reduce live GL texture objects.","Use GPU-accelerated render environments rather than software GL.","Update drivers and Chromium; retry on transient context loss.","Reduce the number of WebGL effects active per frame."],"tags":["webgl","gpu-resource-exhaustion","color-key","texture","rendering","environment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}