{"record":{"id":"f2ca8b6452592dcf","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-f2ca8b","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/roughen-edges.ts","lineNumber":342,"sourceCode":"\t\tthrow new Error('Failed to create WebGL program');\n\t}\n\n\tgl.attachShader(program, vs);\n\tgl.attachShader(program, fs);\n\tgl.linkProgram(program);\n\tif (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n\t\tconst log = gl.getProgramInfoLog(program);\n\t\tgl.deleteProgram(program);\n\t\tthrow new Error(`Roughen edges program link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\nconst createSourceTexture = (gl: WebGL2RenderingContext): WebGLTexture => {\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_MIN_FILTER, gl.LINEAR);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\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.bindTexture(gl.TEXTURE_2D, null);\n\treturn texture;\n};\n\nconst initialNoiseState = (seed: number): number => {\n\tconst scaledSeed = Math.round(seed * 1000);\n\tconst mixedState = (0x9e3779b9 ^ Math.imul(scaledSeed, 0x85ebca6b)) >>> 0;\n\treturn mixedState === 0 ? 0x9e3779b9 : mixedState;\n};\n\nconst nextNoiseState = (state: number): number => {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/roughen-edges.ts#L324-L360","documentation":"Internal error from the `roughenEdges()` effect setup: `gl.createTexture()` returned `null` while allocating the source texture (the sampler that receives each effect frame). Environment-level allocation failure, not a param error. The source texture uses LINEAR filtering and CLAMP_TO_EDGE wrapping on the fullscreen quad.","triggerScenarios":"Context loss mid-setup; GPU texture-memory exhaustion from many concurrent effects or very large source frames; software GL backend with strict texture caps.","commonSituations":"Heavy Studio sessions; large-frame renders on memory-constrained GPUs; CI on llvmpipe/SwiftShader.","solutions":["Restart the render or reload the page.","Reduce the number of active effects or the source surface size.","Switch to a hardware-accelerated GPU with current drivers.","Listen for `webglcontextlost` and free textures on teardown."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const canAllocateTexture = (): boolean => {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl) return false;\n    const t = gl.createTexture();\n    if (t) gl.deleteTexture(t);\n    return !!t;\n  } catch {\n    return false;\n  }\n};","typeGuard":null,"tryCatchPattern":"try {\n  roughenEdges()({...});\n} catch (err) {\n  if (err instanceof Error && /Failed to create WebGL texture/.test(err.message)) {\n    // reduce active effects and retry after a short delay or reload\n  } else {\n    throw err;\n  }\n}","preventionTips":["Feature-detect texture allocation before mounting many effects.","Reduce concurrent effect count and source surface size.","Free textures via the effect `cleanup` when unmounting.","Handle context loss to release and re-create textures."],"tags":["webgl2","roughen-edges-effect","effects","gpu","environment","texture","resource-allocation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}