{"record":{"id":"32e3bdebd0213ef6","repo":"remotion-dev/remotion","slug":"failed-to-create-levels-vertex-array","errorCode":null,"errorMessage":"Failed to create levels vertex array","messagePattern":"Failed to create levels vertex array","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/levels.ts","lineNumber":228,"sourceCode":"\treturn texture;\n};\n\nconst setupLevels = (target: HTMLCanvasElement): LevelsState => {\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('levels effect');\n\t}\n\n\tgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);\n\n\tconst program = createProgram(gl);\n\tconst vao = gl.createVertexArray();\n\tif (!vao) {\n\t\tthrow new Error('Failed to create levels vertex array');\n\t}\n\n\tconst vbo = gl.createBuffer();\n\tif (!vbo) {\n\t\tthrow new Error('Failed to create levels vertex buffer');\n\t}\n\n\tgl.bindVertexArray(vao);\n\tgl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n\tgl.bufferData(\n\t\tgl.ARRAY_BUFFER,\n\t\tnew Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1]),\n\t\tgl.STATIC_DRAW,\n\t);\n\n\tconst aPos = gl.getAttribLocation(program, 'aPos');\n\tconst aUv = gl.getAttribLocation(program, 'aUv');\n\tgl.enableVertexAttribArray(aPos);","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/levels.ts#L210-L246","documentation":"Thrown by `setupLevels()` when `gl.createVertexArray()` returns `null`. A VAO allocation failing indicates the WebGL2 context is lost or out of object memory; the effect's geometry bindings cannot be captured and setup aborts.","triggerScenarios":"Context lost before VAO creation; too many VAOs allocated across concurrent effects; a non-VAO-supporting WebGL2 fallback (rare, since VAOs are core in WebGL2).","commonSituations":"Concurrent renders each spinning up their own VAO; a suspended/backgrounded tab whose context was torn down; VRAM/object-slot exhaustion.","solutions":["Lower concurrency and reuse/dispose VAOs to avoid object-slot exhaustion.","Handle `webglcontextlost` and rebuild the effect after restore.","Restart Chrome/GPU process to clear leaked objects.","Render on a GPU-backed environment rather than a constrained software renderer."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  levels({...})(...);\n} catch (err) {\n  if (/Failed to create levels vertex array/.test(String(err))) {\n    console.warn('levels() VAO unavailable', err);\n  } else {\n    throw err;\n  }\n}","preventionTips":["Dispose VAOs when effects unmount to avoid object-slot exhaustion.","Keep concurrent WebGL2 contexts low.","Handle `webglcontextlost` and rebuild on restore."],"tags":["levels","webgl2","gpu","vao","context-loss","resource-exhaustion"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}