{"record":{"id":"d218975f9b5bb031","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-vertex-array-d21897","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/gridlines.ts","lineNumber":439,"sourceCode":"\t\t\tpremultipliedAlpha: true,\n\t\t\talpha: true,\n\t\t\tpreserveDrawingBuffer: true,\n\t\t});\n\t\tif (!gl) {\n\t\t\tthrow createWebGL2ContextError('gridlines effect');\n\t\t}\n\n\t\tgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);\n\n\t\tconst vs = compileShader(gl, gl.VERTEX_SHADER, GRIDLINES_VS);\n\t\tconst fs = compileShader(gl, gl.FRAGMENT_SHADER, GRIDLINES_FS);\n\t\tconst program = linkProgram(gl, vs, fs);\n\t\tgl.deleteShader(vs);\n\t\tgl.deleteShader(fs);\n\n\t\tconst vao = gl.createVertexArray();\n\t\tif (!vao) {\n\t\t\tthrow new Error('Failed to create WebGL vertex array');\n\t\t}\n\n\t\tgl.bindVertexArray(vao);\n\n\t\tconst data = new Float32Array([\n\t\t\t-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,\n\t\t]);\n\n\t\tconst vbo = gl.createBuffer();\n\t\tif (!vbo) {\n\t\t\tthrow new Error('Failed to create WebGL buffer');\n\t\t}\n\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);\n\n\t\tconst aPos = gl.getAttribLocation(program, 'aPos');\n\t\tconst aUv = gl.getAttribLocation(program, 'aUv');","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/gridlines.ts#L421-L457","documentation":"Thrown during Gridlines setup when gl.createVertexArray() returns null. Vertex array objects are core in WebGL2, so a null return almost always indicates a lost context or resource exhaustion rather than a missing feature. The library throws because bindVertexArray would fail on null.","triggerScenarios":"Called once per effect setup right after the shaders/program are ready (gridlines.ts:437). Happens when the WebGL2 context was lost, or the driver has exhausted its VAO/object budget.","commonSituations":"Many WebGL effects/compositions alive at once; a leaked context; a GPU reset; running on a constrained software renderer.","solutions":["Handle webglcontextlost and recreate effect state on webglcontextrestored.","Free GL objects via cleanup() so VAOs do not accumulate across renders.","Reduce concurrent WebGL2 effects; render sequentially.","Restart the GPU/browser; update drivers if the failure persists."],"exampleFix":"// before: setup called in a loop without cleanup -> VAOs leak -> null\nframe.forEach(() => gridlines.setup(canvas));\n\n// after: one setup, paired cleanup, context-loss handling\nconst s = gridlines.setup(canvas);\ncanvas.addEventListener('webglcontextlost', (e) => e.preventDefault());\n// ... on restore: gridlines.cleanup(s); s = gridlines.setup(canvas);","handlingStrategy":"try-catch","validationCode":"if (gl.isContextLost()) {\n  throw new Error('WebGL2 context lost; cannot create VAO');\n}","typeGuard":"null","tryCatchPattern":"try {\n  gridlines.setup(canvas);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL vertex array') {\n    // context loss / VAO budget exhausted\n  }\n  throw e;\n}","preventionTips":["Handle context loss and rebuild state on restore.","Ensure cleanup() deletes VAOs.","Limit concurrent WebGL2 effects.","Avoid leaked contexts from repeated setup."],"tags":["webgl","gridlines-effect","vao","gpu","resource-exhaustion"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}