{"record":{"id":"14f6bfdd0ec16e79","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-buffer-14f6bf","errorCode":null,"errorMessage":"Failed to create WebGL buffer","messagePattern":"Failed to create WebGL buffer","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/shrinkwrap.ts","lineNumber":479,"sourceCode":"\t\tconst fs = compileShader(gl, gl.FRAGMENT_SHADER, SHRINKWRAP_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');\n\t\tgl.enableVertexAttribArray(aPos);\n\t\tgl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);\n\t\tgl.enableVertexAttribArray(aUv);\n\t\tgl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);\n\n\t\tgl.bindVertexArray(null);\n\n\t\tconst texture = gl.createTexture();\n\t\tif (!texture) {\n\t\t\tthrow new Error('Failed to create WebGL texture');\n\t\t}","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/shrinkwrap.ts#L461-L497","documentation":"The shrinkwrap() effect's setup function calls gl.createBuffer() to allocate a VBO for the fullscreen quad vertices. If the WebGL2 driver returns null, the effect throws this Error. A null buffer means GPU memory allocation failed despite a successfully created context.","triggerScenarios":"Calling shrinkwrap() when GPU memory is exhausted or the driver is degraded — common with software rendering backends, high concurrency, or post-context-loss states.","commonSituations":"SwiftShader-based CI environments; Remotion Lambda with insufficient GPU resources; rendering at large resolutions with multiple effects; leaked buffer objects from improperly cleaned-up instances.","solutions":["Verify GPU acceleration is enabled in the render environment.","Lower concurrency to reduce the number of live WebGL2 buffers.","Ensure proper effect cleanup (cleanup() calls gl.deleteBuffer()) between renders.","Use a runner or Lambda configuration with adequate GPU memory."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Probe buffer allocation capability\nfunction canCreateGlBuffer(canvas: HTMLCanvasElement): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const buf = gl.createBuffer();\n  const ok = buf !== null;\n  if (buf) gl.deleteBuffer(buf);\n  return ok;\n}","typeGuard":"null","tryCatchPattern":"try {\n  shrinkwrap({ amount: 1 });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL buffer') {\n    console.warn('WebGL2 buffer allocation failed for shrinkwrap');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Reduce concurrency to limit simultaneous GPU buffer allocations.","Ensure proper effect cleanup to release buffers.","Verify GPU acceleration in the render environment.","Monitor for context-loss events."],"tags":["webgl2","gpu","resource-allocation","buffer","memory"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}