{"record":{"id":"2a029e449d5a3c19","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-program-2a029e","errorCode":null,"errorMessage":"Failed to create WebGL program","messagePattern":"Failed to create WebGL program","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/noise.ts","lineNumber":169,"sourceCode":"\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(`Noise 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 => {\n\tconst program = gl.createProgram();\n\tif (!program) {\n\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(`Noise program link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\nconst setupNoise = (target: HTMLCanvasElement): NoiseState => {\n\tconst gl = target.getContext('webgl2', {\n\t\tpremultipliedAlpha: true,\n\t\talpha: true,","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/noise.ts#L151-L187","documentation":"Thrown by linkProgram (packages/effects/src/noise.ts:169) when gl.createProgram() returns null before attaching the noise shaders. As with other null GL-object returns, it signals a lost WebGL2 context or an exhausted program-object budget, not a problem with the shaders themselves.","triggerScenarios":"setupNoise calling linkProgram after the context was lost or after too many program objects were allocated without cleanup; compiling shaders into a context that is already dead.","commonSituations":"Render farms running many noise/WebGL2 effects without disposing programs; context loss during a batch render; GPU memory pressure.","solutions":["Ensure cleanup runs (gl.deleteProgram) between effect usages and cap concurrent WebGL2 effects.","Render with a healthy GPU context (GPU-enabled headless Chrome) and handle context-loss events.","Probe gl.isContextLost() before setup and skip/retry the effect when true."],"exampleFix":"// before\nconst program = linkProgram(gl, vs, fs); // createProgram() returned null\n\n// after\nif (gl.isContextLost()) {\n  throw new Error('Cannot link noise program: WebGL2 context lost');\n}","handlingStrategy":"try-catch","validationCode":"function canCreateNoiseProgram(): boolean {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl || gl.isContextLost()) return false;\n    const p = gl.createProgram();\n    const ok = !!p;\n    if (p) gl.deleteProgram(p);\n    return ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  scene.push(noise({amount: 0.2}));\n} catch (err) {\n  if (/Failed to create WebGL program/.test(String(err?.message))) {\n    // program budget exhausted or context lost: reduce effects and retry\n  } else throw err;\n}","preventionTips":["Delete programs via cleanup between effect usages.","Cap concurrent WebGL2 effects.","Render on a GPU host and handle context-loss events."],"tags":["webgl","gpu","noise","effects","program","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}