{"record":{"id":"5d730f9503877a3b","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-5d730f","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/waves.ts","lineNumber":422,"sourceCode":"\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 createTexture = (\n\tgl: WebGL2RenderingContext,\n\tfilter: number,\n): 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, filter);\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);\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 setupWaves = (target: HTMLCanvasElement): WavesState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,\n\t\tpreserveDrawingBuffer: true,\n\t});\n\tif (!gl) {","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/waves.ts#L404-L440","documentation":"Thrown by createTexture() inside the waves effect when gl.createTexture() returns null. The waves effect creates two textures (source and palette) with configurable min/mag filters. createTexture returns null on context loss, context destruction, or GPU resource exhaustion.","triggerScenarios":"Called from setupWaves() at packages/effects/src/waves.ts:489 (sourceTexture: createTexture(gl, gl.LINEAR)) and line 490 (paletteTexture: createTexture(gl, gl.NEAREST)). Fires when the GL context cannot allocate a texture object — typically context loss or texture pool exhaustion.","commonSituations":"Context loss during setup; many concurrent waves effect instances without cleanup; long render sessions leaking textures; constrained GPU memory on mobile or VM environments.","solutions":["Handle 'webglcontextlost'/'webglcontextrestored' and recreate the effect.","Ensure waves effect cleanup (which deletes both textures) runs before creating new instances.","Reduce the number of concurrent effect canvases.","Recycle render worker processes in long-running server-side rendering to free GPU resources."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const gl = canvas.getContext('webgl2');\nif (!gl || gl.isContextLost()) {\n  return;\n}\ntry {\n  const state = setupWaves(canvas);\n} catch (e) {\n  if ((e as Error).message === 'Failed to create WebGL texture') {\n    console.warn('Waves texture allocation failed:', (e as Error).message);\n  }\n}","preventionTips":["Ensure waves effect cleanup (deletes both textures) runs before creating new instances.","Handle context loss/restoration events.","Limit concurrent effect canvases to reduce texture pressure."],"tags":["webgl","gpu","texture","resource-exhaustion","waves-effect"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}