remotion-dev/remotion · critical · Error
Failed to create WebGL vertex array
Error message
Failed to create WebGL vertex array
What it means
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.
Source
Thrown at packages/effects/src/paper.ts:792
const setupPaper = (target: HTMLCanvasElement): PaperState => {
const gl = target.getContext('webgl2', {
premultipliedAlpha: true,
alpha: true,
preserveDrawingBuffer: true,
});
if (!gl) {
throw createWebGL2ContextError('paper effect');
}
const vs = compileShader(gl, gl.VERTEX_SHADER, PAPER_VS);
const fs = compileShader(gl, gl.FRAGMENT_SHADER, PAPER_FS);
const program = linkProgram(gl, vs, fs);
gl.deleteShader(vs);
gl.deleteShader(fs);
const vao = gl.createVertexArray();
if (!vao) {
throw new Error('Failed to create WebGL vertex array');
}
gl.bindVertexArray(vao);
const data = new Float32Array([
-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,
]);
const vbo = gl.createBuffer();
if (!vbo) {
throw new Error('Failed to create WebGL buffer');
}
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
const aPos = gl.getAttribLocation(program, 'aPos');
const aUv = gl.getAttribLocation(program, 'aUv');View on GitHub (pinned to 78fe4bb3fd)
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.
Example fix
// before
const vao = gl.createVertexArray(); // null -> throws
// after
if (gl.isContextLost()) {
throw new Error('WebGL2 context lost; cannot create paper VAO');
} Defensive patterns
Strategy: try-catch
Validate before calling
function canCreatePaperVao(): boolean {
try {
const c = document.createElement('canvas');
const gl = c.getContext('webgl2');
if (!gl || gl.isContextLost()) return false;
const v = gl.createVertexArray();
const ok = !!v;
if (v) gl.deleteVertexArray(v);
return ok;
} catch {
return false;
}
} Try / catch
try {
scene.push(paper({amount: 1}));
} catch (err) {
if (/Failed to create WebGL vertex array/.test(String(err?.message))) {
// VAO budget exhausted or context lost: omit the effect
} else throw err;
} Prevention
- Delete VAOs via cleanup between usages.
- Cap concurrent WebGL2 effects.
- Handle webglcontextlost and re-run setup after restore.
When it happens
Trigger: setupPaper creating the VAO on a lost context or after too many live VAOs; running many paper/WebGL2 effects concurrently without disposing their VAOs.
Common situations: Context loss mid-render; long Studio sessions leaking VAOs; GPU memory pressure on integrated graphics; headless render without a real GPU.
Related errors
- Failed to create WebGL vertex array
- Failed to create WebGL shader
- Failed to create WebGL program
- Failed to create WebGL texture
- Failed to create WebGL noise texture
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/2b3e9c64aaeb127a.
Report an issue: GitHub.