{"record":{"id":"f577e375863d7e12","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-vertex-array-f577e3","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/halftone-linear-gradient.ts","lineNumber":454,"sourceCode":"\t\tif (!gl) {\n\t\t\tthrow createWebGL2ContextError('halftone linear gradient 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, HALFTONE_LINEAR_GRADIENT_VS);\n\t\tconst fs = compileShader(\n\t\t\tgl,\n\t\t\tgl.FRAGMENT_SHADER,\n\t\t\tHALFTONE_LINEAR_GRADIENT_FS,\n\t\t);\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":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/halftone-linear-gradient.ts#L436-L472","documentation":"Thrown in the setup() of the halftone-linear-gradient WebGL2 effect when gl.createVertexArray() returns null. WebGL2 returns null from resource-creation calls only when the implementation has run out of addressable GL objects or the context is lost; the library treats a null VAO as fatal because the effect cannot bind vertex attributes without it.","triggerScenarios":"Instantiating many halftone-linear-gradient effect instances (or other WebGL2 effects) in one render session until the context's object budget is exhausted; rendering while the GL context is in the process of being lost; rendering on a GPU whose driver caps vertex-array objects very low.","commonSituations":"Long render jobs with hundreds of frames each allocating fresh effect state; combining several WebGL2-backed effects per composition on low-resource GPUs; GPU process crash in Chrome leaving the context zombie.","solutions":["Reduce the number of simultaneous WebGL2 effects in the composition, or ensure effects are reused via the effect-state cache rather than re-created each frame.","Check for WebGL context-loss: if gl.isContextLost() is true before setup, the GPU process is gone — restart the render.","Render on a machine with a healthier GPU/driver (hardware acceleration on, or a newer headless Chromium).","Update the GPU driver; very old OpenGL drivers misreport VAO limits."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Best-effort pre-check: probe whether the context can still hand out a VAO before relying on the effect.\nfunction canCreateVao(canvas: HTMLCanvasElement): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const vao = gl.createVertexArray();\n  const ok = vao !== null;\n  if (vao) gl.deleteVertexArray(vao);\n  gl.deleteProgram(gl.createProgram()); // touch\n  return ok;\n}","typeGuard":null,"tryCatchPattern":"try {\n  // ...use halftoneLinearGradient()\n} catch (e) {\n  if (e instanceof Error && /Failed to create WebGL vertex array/.test(e.message)) {\n    // most likely context loss; restart the render process\n  } else throw e;\n}","preventionTips":["Limit the number of WebGL2 effects instantiated concurrently in a single render session.","Watch for WebGL context-lost events and restart the worker instead of continuing on a dead context.","Render on hardware with adequate GL object budgets."],"tags":["webgl","halftone-linear-gradient","gpu-resources","context-loss","rendering"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}