{"record":{"id":"44e3ef6c98adf6df","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-44e3ef","errorCode":null,"errorMessage":"Failed to create WebGL texture","messagePattern":"Failed to create WebGL texture","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/gridlines.ts","lineNumber":467,"sourceCode":"\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}\n\n\t\tgl.bindTexture(gl.TEXTURE_2D, texture);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\t\tgl.bindTexture(gl.TEXTURE_2D, null);\n\n\t\tconst colorCanvas = document.createElement('canvas');\n\t\tcolorCanvas.width = 1;\n\t\tcolorCanvas.height = 1;\n\t\tconst colorCtx = colorCanvas.getContext('2d', {willReadFrequently: true});\n\t\tif (!colorCtx) {\n\t\t\tthrow new Error('Failed to acquire 2D context for color parsing');\n\t\t}\n\n\t\treturn {","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/gridlines.ts#L449-L485","documentation":"Thrown during Gridlines setup when gl.createTexture() returns null. This texture is the source sampler the effect uploads each frame into. A null return again points to context loss or texture-budget exhaustion.","triggerScenarios":"Called once per setup (gridlines.ts:465) after the buffer/VAO are configured. Happens under a lost context, when the GPU's texture budget is exceeded, or when too many concurrent WebGL effects are alive.","commonSituations":"Large/source frames combined with many live textures; leaked textures; GPU reset; software renderer with a low texture cap.","solutions":["Handle webglcontextlost; recreate on restore.","Ensure cleanup() deletes textures (Gridlines cleanup frees the texture).","Reduce concurrent compositions/effects; lower frame resolution.","Restart browser/GPU; update drivers if persistent."],"exampleFix":"// before: many effects live, textures never freed -> null\ncomps.forEach(c => c.effects.gridlines.setup(canvas));\n\n// after: free on teardown\nuseEffect(() => {\n  const s = gridlines.setup(canvas);\n  return () => gridlines.cleanup(s);\n}, []);","handlingStrategy":"try-catch","validationCode":"if (gl.isContextLost()) {\n  throw new Error('WebGL2 context lost; cannot create texture');\n}","typeGuard":"null","tryCatchPattern":"try {\n  gridlines.setup(canvas);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL texture') {\n    // context loss / texture budget exhausted\n  }\n  throw e;\n}","preventionTips":["Free textures in cleanup().","Handle context loss and recreate on restore.","Reduce concurrent compositions/large frames on constrained GPUs.","Avoid setting up effects in a loop without teardown."],"tags":["webgl","gridlines-effect","texture","gpu","resource-exhaustion"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}