{"record":{"id":"7c950c212192c746","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-7c950c","errorCode":null,"errorMessage":"Failed to create WebGL texture","messagePattern":"Failed to create WebGL texture","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/pixelate.ts","lineNumber":160,"sourceCode":"\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\tconst aUv = gl.getAttribLocation(program, 'aUv');\n\tgl.enableVertexAttribArray(aPos);\n\tgl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);\n\tgl.enableVertexAttribArray(aUv);\n\tgl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);\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);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\tgl.bindTexture(gl.TEXTURE_2D, null);\n\n\treturn {\n\t\tgl,\n\t\tprogram,\n\t\tvao,\n\t\tvbo,\n\t\ttexture,\n\t\tuSource: gl.getUniformLocation(program, 'uSource'),\n\t\tuResolution: gl.getUniformLocation(program, 'uResolution'),\n\t\tuBlockSize: gl.getUniformLocation(program, 'uBlockSize'),","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/pixelate.ts#L142-L178","documentation":"Thrown by createPixelateState when gl.createTexture() returns null after VAO, VBO, and attribute wiring all succeeded. Textures are the largest GL resource pixelate allocates, so this is the most likely allocation to fail under memory pressure. The guard prevents bindTexture/texParameteri from operating on null.","triggerScenarios":"pixelate setup reaches the final block; gl.createTexture() returns null.","commonSituations":"Large source frames being uploaded each tick; many texture-backed effects in one composition; mobile/integrated GPUs with limited VRAM; SwiftShader on a low-memory Lambda function; source exceeding MAX_TEXTURE_SIZE.","solutions":["Compare source dimensions to `gl.getParameter(gl.MAX_TEXTURE_SIZE)` and downscale if exceeded.","Lower composition resolution.","Reduce concurrent texture-backed effects.","Increase Lambda function memory.","Confirm `gl.isContextLost()` is false and remount if true."],"exampleFix":"// before\nimport {pixelate} from '@remotion/effects';\nconst effect = pixelate();\n\n// after — verify texture capacity for the source size\nfunction textureFits(gl: WebGL2RenderingContext, w: number, h: number): boolean {\n  const max = gl.getParameter(gl.MAX_TEXTURE_SIZE) as number;\n  return w <= max && h <= max && !gl.isContextLost();\n}","handlingStrategy":"try-catch","validationCode":"function textureCapacityOk(gl: WebGL2RenderingContext, w: number, h: number): boolean {\n  if (gl.isContextLost()) return false;\n  const max = gl.getParameter(gl.MAX_TEXTURE_SIZE) as number;\n  if (w > max || h > max) return false;\n  const t = gl.createTexture();\n  if (t) gl.deleteTexture(t);\n  return t !== null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  pixelate();\n} catch (err) {\n  if (/Failed to create WebGL texture/.test((err as Error).message)) {\n    // downscale source / reduce resolution, then retry\n  }\n  throw err;\n}","preventionTips":["Keep source dimensions under MAX_TEXTURE_SIZE.","Render at the lowest acceptable resolution.","Limit concurrent texture-backed effects.","Give Lambda enough memory for SwiftShader texture budget."],"tags":["webgl","gpu","pixelate","texture","memory","environment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}