{"record":{"id":"38f3a243e8fc05ff","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-vertex-array-38f3a2","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/barrel-distortion/barrel-distortion-runtime.ts","lineNumber":110,"sourceCode":"export const setupBarrelDistortion = (\n\ttarget: HTMLCanvasElement,\n): BarrelDistortionState => {\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('barrel distortion effect');\n\t}\n\n\tgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);\n\n\tconst program = createProgram(gl, BARREL_DISTORTION_VS, BARREL_DISTORTION_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\tgl.enableVertexAttribArray(0);\n\tgl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/barrel-distortion/barrel-distortion-runtime.ts#L92-L128","documentation":"Thrown by `setupBarrelDistortion` when `gl.createVertexArray()` returns `null`. The VAO holds the fullscreen-quad vertex attribute binding for the distortion pass. A null result means the GL implementation could not allocate the VAO object — typically a context-loss or resource-limit condition rather than a usage mistake.","triggerScenarios":"Fires at barrel-distortion setup (line 108-110) when `gl.createVertexArray()` yields null, immediately after the program is created and before the VBO.","commonSituations":"The WebGL2 context was lost mid-setup (GPU reset, tab crash, too many contexts); the GL driver enforces a low VAO cap that has been exhausted by other effects/canvases sharing the process.","solutions":["Check `gl.isContextLost()` before setup; if true, await context restoration and retry.","Limit the number of concurrently active WebGL2 effects so VAO allocations are not exhausted.","Call `cleanupBarrelDistortion` on unused effect states to free their VAOs.","Verify hardware acceleration is available in the rendering environment."],"exampleFix":"if (gl.isContextLost()) {\n  // wait for webglcontextrestored, then re-run setupBarrelDistortion\n} else {\n  const state = setupBarrelDistortion(canvas);\n}","handlingStrategy":"try-catch","validationCode":"if (gl.isContextLost()) { /* skip setup */ }","typeGuard":null,"tryCatchPattern":"try {\n  const state = setupBarrelDistortion(canvas);\n} catch (err) {\n  if (/Failed to create WebGL vertex array/.test(err.message)) {\n    // await context restore, then reinitialize\n  } else { throw err; }\n}","preventionTips":["Free VAOs via cleanup on unused states.","Handle webglcontextlost to avoid setup during a lost context.","Cap concurrent active effects."],"tags":["webgl2","vao","gpu-memory","barrel-distortion","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}