{"record":{"id":"6ece539f817b9c9e","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-buffer-6ece53","errorCode":null,"errorMessage":"Failed to create WebGL buffer","messagePattern":"Failed to create WebGL buffer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/effects/src/tear.ts","lineNumber":242,"sourceCode":"\tconst program = linkProgram(gl, vs, fs);\n\tgl.deleteShader(vs);\n\tgl.deleteShader(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((MESH_ROWS + 1) * 4);\n\tfor (let row = 0; row <= MESH_ROWS; row++) {\n\t\tdata.set([0, row / MESH_ROWS, 1, row / MESH_ROWS], row * 4);\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\tconst aPos = gl.getAttribLocation(program, 'aPos');\n\tgl.enableVertexAttribArray(aPos);\n\tgl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 8, 0);\n\n\tgl.bindVertexArray(null);\n\n\tconst texture = gl.createTexture();\n\tif (!texture) {\n\t\tthrow new Error('Failed to create WebGL texture');\n\t}\n\n\tgl.bindTexture(gl.TEXTURE_2D, texture);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/effects/src/tear.ts#L224-L260","documentation":"When initializing the Tear effect's geometry, gl.createBuffer() returned null, so no vertex buffer object could be allocated for the tear mesh. The WebGL2 spec permits null here when the context is lost or resources are exhausted; the library throws immediately to avoid a null dereference later during rendering.","triggerScenarios":"gl.createBuffer() returning null in createTearState — the WebGL2 context became lost (GPU reset/driver crash) between shader setup and buffer allocation, or the context is out of buffer objects/memory.","commonSituations":"Long-running renders where the GPU resets mid-session; many concurrent WebGL canvases exhausting browser GPU memory; headless/CI software GL with strict resource limits; driver bugs failing allocations.","solutions":["Check gl.isContextLost() and recreate the canvas/context, then retry the effect","Reduce concurrent WebGL usage (other tabs, effects, compositions) to free GPU memory","Restart the browser/render process to reset GPU allocations","Test the context with a trivial gl.createBuffer() call to confirm the environment supports allocations"],"exampleFix":"// before\nconst vbo = gl.createBuffer();\nif (!vbo) throw new Error('Failed to create WebGL buffer');\n// after\nconst vbo = gl.createBuffer();\nif (!vbo) {\n  if (gl.isContextLost()) { recreateContext(); }\n  throw new Error('WebGL buffer allocation failed — context lost or out of GPU memory');\n}","handlingStrategy":"try-catch","validationCode":"const gl = canvas.getContext('webgl2');\nif (!gl) throw new Error('WebGL2 unavailable');\nif (gl.isContextLost()) throw new Error('Context lost before render');\nconst probe = gl.createBuffer();\nif (!probe) throw new Error('GPU buffer allocation unavailable');\ngl.deleteBuffer(probe);","typeGuard":"function canAllocateBuffers(gl: WebGL2RenderingContext): boolean {\n  const buf = gl.createBuffer();\n  if (buf) { gl.deleteBuffer(buf); return true; }\n  return false;\n}","tryCatchPattern":"try {\n  renderWithTear(...);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Failed to create WebGL buffer') {\n    if (gl.isContextLost()) { recreateContext(); }\n    // free other GPU resources, then retry the render\n  } else throw err;\n}","preventionTips":["Monitor gl.isContextLost() during long renders","Avoid many simultaneous WebGL canvases that exhaust GPU memory","Use hardware GL in CI/headless rather than limited software rasterizers","Retry renders once after a context restore instead of failing the whole job"],"tags":["webgl","buffer","context-lost","gpu-memory"],"backgroundTag":"webgl-context-lost","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}