{"record":{"id":"1fb7293fb2f09977","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-1fb729","errorCode":null,"errorMessage":"Failed to create WebGL shader","messagePattern":"Failed to create WebGL shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/waves.ts","lineNumber":367,"sourceCode":"\t\t);\n\t\treturn;\n\t}\n\n\tfragColor = vec4(\n\t\tpremultipliedLine + texColor.rgb * (1.0 - lineAlpha),\n\t\tlineAlpha + texColor.a * (1.0 - lineAlpha)\n\t);\n}\n`;\n\nconst compileShader = (\n\tgl: WebGL2RenderingContext,\n\ttype: number,\n\tsource: string,\n): WebGLShader => {\n\tconst shader = gl.createShader(type);\n\tif (!shader) {\n\t\tthrow new Error('Failed to create WebGL shader');\n\t}\n\n\tgl.shaderSource(shader, source);\n\tgl.compileShader(shader);\n\tif (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n\t\tconst log = gl.getShaderInfoLog(shader);\n\t\tgl.deleteShader(shader);\n\t\tthrow new Error(`Waves shader compile failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn shader;\n};\n\nconst linkProgram = (\n\tgl: WebGL2RenderingContext,\n\tvs: WebGLShader,\n\tfs: WebGLShader,\n): WebGLProgram => {","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/waves.ts#L349-L385","documentation":"Thrown by compileShader() inside the waves effect when gl.createShader(type) returns null. WebGL's createShader returns null on context loss, context destruction, or resource exhaustion. The shader type (vertex or fragment) is passed through from the caller. This prevents the waves effect from building its GLSL program.","triggerScenarios":"Called transitively from setupWaves() at packages/effects/src/waves.ts:446 via createProgram(gl, WAVES_VS, WAVES_FS) which calls compileShader for both vertex and fragment shaders. Fires when the GL context is lost or GPU shader object slots are exhausted. The shader source (WAVES_VS/WAVES_FS) is a static library constant, so user params do not cause this.","commonSituations":"WebGL context loss event during effect setup; long-running render with many effect instances leaking shader objects; constrained GPU environment (mobile, VM, older drivers); GPU process crash mid-setup.","solutions":["Handle 'webglcontextlost'/'webglcontextrestored' events and re-run setupWaves on a fresh canvas.","Ensure cleanup of old effect states (the waves effect cleanup deletes programs but shaders are deleted inline — verify no leaks in custom wrappers).","Reduce concurrent effect instances to lower shader object pressure.","Update GPU drivers or switch render backends (hardware vs SwiftShader)."],"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 shader') {\n    console.warn('Waves shader allocation failed:', (e as Error).message);\n  }\n}","preventionTips":["Handle 'webglcontextlost'/'webglcontextrestored' events.","Ensure waves effect cleanup runs before creating new instances.","Limit concurrent effect instances."],"tags":["webgl","gpu","shader","resource-exhaustion","waves-effect"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}