{"record":{"id":"2b3e9c64aaeb127a","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-vertex-array-2b3e9c","errorCode":null,"errorMessage":"Failed to create WebGL vertex array","messagePattern":"Failed to create WebGL vertex array","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/paper.ts","lineNumber":792,"sourceCode":"const setupPaper = (target: HTMLCanvasElement): PaperState => {\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('paper effect');\n\t}\n\n\tconst vs = compileShader(gl, gl.VERTEX_SHADER, PAPER_VS);\n\tconst fs = compileShader(gl, gl.FRAGMENT_SHADER, PAPER_FS);\n\tconst program = linkProgram(gl, vs, fs);\n\tgl.deleteShader(vs);\n\tgl.deleteShader(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":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/paper.ts#L774-L810","documentation":"Thrown by setupPaper (packages/effects/src/paper.ts:792) when gl.createVertexArray() returns null while building the VAO that binds the paper effect's quad attributes. Null indicates a lost WebGL2 context or an exhausted per-context VAO budget.","triggerScenarios":"setupPaper creating the VAO on a lost context or after too many live VAOs; running many paper/WebGL2 effects concurrently without disposing their VAOs.","commonSituations":"Context loss mid-render; long Studio sessions leaking VAOs; GPU memory pressure on integrated graphics; headless render without a real GPU.","solutions":["Run effect cleanup (gl.deleteVertexArray) between usages and limit concurrent WebGL2 effects.","Render on a GPU-capable host with WebGL enabled in headless Chrome.","Check gl.isContextLost() before setup and retry after restoration."],"exampleFix":"// before\nconst vao = gl.createVertexArray(); // null -> throws\n\n// after\nif (gl.isContextLost()) {\n  throw new Error('WebGL2 context lost; cannot create paper VAO');\n}","handlingStrategy":"try-catch","validationCode":"function canCreatePaperVao(): boolean {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl || gl.isContextLost()) return false;\n    const v = gl.createVertexArray();\n    const ok = !!v;\n    if (v) gl.deleteVertexArray(v);\n    return ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  scene.push(paper({amount: 1}));\n} catch (err) {\n  if (/Failed to create WebGL vertex array/.test(String(err?.message))) {\n    // VAO budget exhausted or context lost: omit the effect\n  } else throw err;\n}","preventionTips":["Delete VAOs via cleanup between usages.","Cap concurrent WebGL2 effects.","Handle webglcontextlost and re-run setup after restore."],"tags":["webgl","gpu","paper","effects","vao","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}