{"record":{"id":"722d333275fcf4b7","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-vertex-array-722d33","errorCode":null,"errorMessage":"Failed to create WebGL vertex array","messagePattern":"Failed to create WebGL vertex array","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/color-key.ts","lineNumber":272,"sourceCode":"};\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) {\n\t\tthrow createWebGL2ContextError('color key effect');\n\t}\n\n\tgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);\n\n\tconst program = createProgram(gl, COLOR_KEY_VS, COLOR_KEY_FS);\n\n\tconst vao = gl.createVertexArray();\n\tif (!vao) {\n\t\tthrow new Error('Failed to create WebGL vertex array');\n\t}\n\n\tgl.bindVertexArray(vao);\n\n\tconst data = new Float32Array([\n\t\t-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,\n\t]);\n\n\tconst vbo = gl.createBuffer();\n\tif (!vbo) {\n\t\tthrow new Error('Failed to create WebGL buffer');\n\t}\n\n\tgl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n\tgl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);\n\n\tconst aPos = gl.getAttribLocation(program, 'aPos');\n\tconst aUv = gl.getAttribLocation(program, 'aUv');","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/color-key.ts#L254-L290","documentation":"Thrown by setupColorKey when gl.createVertexArray() returns null after the program was built. A null VAO means the GL context cannot allocate a vertex-array object, pointing to resource exhaustion or context loss. The color key effect cannot bind vertex attributes without it, so setup fails.","triggerScenarios":"At color-key.ts:272 inside setupColorKey, before the VBO is created. gl.createVertexArray() yields null under GL object-limit/memory pressure or after context loss; independent of colorKey() parameters.","commonSituations":"Many concurrent WebGL2 contexts each holding VAOs, software GL (SwiftShader) with low VAO limits, GPU memory pressure, or a long render that lost its context.","solutions":["Lower render concurrency to reduce the number of live VAOs/contexts.","Render on a GPU-accelerated environment rather than software GL.","Update GPU drivers and Chrome; retry if context loss was transient.","Reduce the number of WebGL effects rendered in parallel."],"exampleFix":"// before\nremotion render main --concurrency=8\n\n// after\nremotion render main --concurrency=1","handlingStrategy":"retry","validationCode":"function webgl2VaoAvailable(): boolean {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl) return false;\n    const v = gl.createVertexArray();\n    const ok = v !== null;\n    if (v) gl.deleteVertexArray(v);\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 vertex array/i.test(String(err))) {\n    await renderMedia({...opts, concurrency: 1});\n  } else {\n    throw err;\n  }\n}","preventionTips":["Cap render concurrency to limit live VAOs across contexts.","Prefer GPU-enabled environments over software GL.","Keep drivers/Chromium updated; retry after transient context loss.","Stack fewer WebGL effects per frame."],"tags":["webgl","gpu-resource-exhaustion","color-key","vertex-array","rendering","environment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}