{"record":{"id":"77d578545c760bf2","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-program-77d578","errorCode":null,"errorMessage":"Failed to create WebGL program","messagePattern":"Failed to create WebGL program","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/halftone.ts","lineNumber":378,"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(`Halftone 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(`Halftone program link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\n// Halftone effect (WebGL2). Converts luminance into a grid of dots, squares,\n// or lines. Each fragment determines its nearest grid cell and whether it falls\n// inside a dot, so edge dots are never culled. `dotSpacing` sets the grid pitch\n// (defaults to `dotSize`). `sampling` controls texture interpolation when","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/halftone.ts#L360-L396","documentation":"Thrown by the linkProgram() helper of the halftone effect when gl.createProgram() returns null. As with other null-resource returns, this indicates object-budget exhaustion or context loss; no program could be created to attach shaders to.","triggerScenarios":"setup() of the halftone effect running under GL object-budget pressure or after context loss; specifically the shaders compiled but the program pool is exhausted.","commonSituations":"Heavy compositions with many WebGL2 effects; long render sessions; GPU process crash leaving the context degraded.","solutions":["Check gl.isContextLost(); restart the render if true.","Reduce simultaneous WebGL2 effect count or share effect state.","Render on a machine with more GPU/driver headroom.","Restart Chrome/Studio to clear leaked GL objects."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Probe whether the context still hands out program objects.\nfunction canCreateProgram(canvas: HTMLCanvasElement): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const p = gl.createProgram();\n  const ok = p !== null;\n  if (p) gl.deleteProgram(p);\n  return ok;\n}","typeGuard":null,"tryCatchPattern":"try {\n  // ...use halftone()\n} catch (e) {\n  if (e instanceof Error && /Failed to create WebGL program/.test(e.message)) {\n    // program object budget exhausted or context lost; restart render\n  } else throw e;\n}","preventionTips":["Limit simultaneous WebGL2 effects per render session.","Reuse effect state across frames instead of re-creating programs each frame.","Restart the worker after a context-lost event."],"tags":["webgl","halftone","gpu-resources","context-loss","rendering"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}