{"record":{"id":"65f6368efb48804b","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-65f636","errorCode":null,"errorMessage":"Failed to create WebGL shader","messagePattern":"Failed to create WebGL shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/halftone.ts","lineNumber":357,"sourceCode":"\tcolorCtx: CanvasRenderingContext2D;\n\tcachedColorStr: string;\n\tcachedColorRgba: ParsedColorRgba;\n};\n\nconst SHAPE_INDEX: Record<HalftoneShape, number> = {\n\tcircle: 0,\n\tsquare: 1,\n\tline: 2,\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(`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 => {","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/halftone.ts#L339-L375","documentation":"Thrown by the compileShader() helper of the halftone WebGL2 effect when gl.createShader(type) returns null. A null shader means the GL implementation refused to allocate a shader object — object-budget exhaustion or context loss — before any source is even attached. The effect has not yet attempted to compile, so no info log exists.","triggerScenarios":"setup() of the halftone effect running when the GL context is lost or its shader object budget is exhausted; rendering on a GPU/driver whose shader object limit is unusually low.","commonSituations":"Long render sessions allocating many WebGL2 effects; GPU process crash leaving a zombie context; integrated GPUs under heavy load.","solutions":["Check gl.isContextLost() and restart the render if true.","Reduce the number of WebGL2 effects in flight per render.","Render on a machine with a healthier GPU/driver.","Restart Chrome/Studio to clear leaked GL objects."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Probe whether the context will allocate a shader object.\nfunction canCreateShader(canvas: HTMLCanvasElement): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const s = gl.createShader(gl.VERTEX_SHADER);\n  const ok = s !== null;\n  if (s) gl.deleteShader(s);\n  return ok;\n}","typeGuard":null,"tryCatchPattern":"try {\n  // ...use halftone()\n} catch (e) {\n  if (e instanceof Error && /Failed to create WebGL shader/.test(e.message)) {\n    // shader object budget exhausted or context lost; restart render\n  } else throw e;\n}","preventionTips":["Keep concurrent WebGL2 effect count within the GPU's shader object budget.","Watch for context-loss events and restart the worker.","Reuse effect state across frames instead of re-creating shaders each frame."],"tags":["webgl","halftone","gpu-resources","shader","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}