{"record":{"id":"3572a4cd65de10f6","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-3572a4","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/mirror/mirror-runtime.ts","lineNumber":81,"sourceCode":"};\n\nconst createProgram = (\n\tgl: WebGL2RenderingContext,\n\tvertexSource: string,\n\tfragmentSource: string,\n): WebGLProgram => {\n\tconst vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);\n\tconst fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);\n\tconst program = linkProgram(gl, vs, fs);\n\tgl.deleteShader(vs);\n\tgl.deleteShader(fs);\n\treturn program;\n};\n\nconst createRgbaTexture = (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\nexport const setupMirror = (target: HTMLCanvasElement): MirrorState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,\n\t\tpreserveDrawingBuffer: true,\n\t});\n\tif (!gl) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/mirror/mirror-runtime.ts#L63-L99","documentation":"While creating the source texture for the mirror effect, gl.createTexture() returned null. The WebGL2 context is alive but cannot allocate a texture object. This usually signals context loss, GPU memory exhaustion, or an environment with marginal WebGL2 resource support.","triggerScenarios":"During setupMirror, createRgbaTexture calls gl.createTexture() which returns null. This happens late in setup — after shaders, program, VAO, and VBO are already created — so earlier resources succeeded but texture allocation failed.","commonSituations":"GPU memory exhaustion from many simultaneous effects or large textures; context loss between setup steps; headless/CI environments with limited texture allocation; corrupted GPU driver state.","solutions":["Reduce the number of concurrent WebGL effects or the resolution of source textures.","Check for and handle WebGL context loss — retry rendering after context restoration.","Update GPU drivers or use SwiftShader in headless environments.","Ensure the render environment has adequate GPU memory for the composition."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // apply mirror effect\n} catch (e) {\n  if (e instanceof Error && e.message.includes('WebGL texture')) {\n    console.warn('WebGL texture creation failed, skipping mirror effect');\n    // fallback path\n  } else {\n    throw e;\n  }\n}","preventionTips":["Reduce texture resolution or number of concurrent effects to lower GPU memory pressure.","Handle WebGL context loss events and retry.","Ensure the render environment has adequate GPU memory."],"tags":["webgl","gpu","environment","mirror-effect","resource-exhaustion"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}