{"record":{"id":"6691e9b03417f3e6","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-6691e9","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/duotone.ts","lineNumber":138,"sourceCode":"\t\treturn;\n\t}\n\n\tvec3 rgb = texColor.rgb / alpha;\n\tfloat luminance = dot(rgb, vec3(0.299, 0.587, 0.114));\n\tvec3 duotoneColor = luminance < uThreshold ? uDarkColor : uLightColor;\n\n\tfragColor = vec4(duotoneColor * alpha, alpha);\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(`Duotone 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":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/duotone.ts#L120-L156","documentation":"Thrown by the duotone effect's internal compileShader() when gl.createShader(type) returns null. The WebGL2 context was already acquired successfully (createWebGL2ContextError would have thrown earlier otherwise), so a null shader object means the driver refused to allocate one. Per the WebGL spec, createShader returns null only when the context is lost or the implementation cannot create another resource.","triggerScenarios":"Calling duotone() in a composition that is being rendered or previewed on a Chrome instance whose GPU process is unavailable, has crashed, or has exhausted its WebGL object budget. The failure occurs inside setupDuotone() during the first frame that wires up the duotone program.","commonSituations":"Headless/CI Chrome with no GPU access, hardware acceleration disabled in the local browser, too many simultaneous WebGL contexts (many concurrent render workers or several GPU effects on one frame), a GPU driver reset mid-render.","solutions":["Render with a software/ANGLE WebGL backend, e.g. `npx remotion render <comp> --output out.mp4 --gl=swiftshader` (also try --gl=angle, --gl=swangle).","Enable hardware acceleration in the browser used for Studio preview, or run preview on a machine with a working GPU.","Lower render concurrency (--concurrency) so each frame's WebGL contexts are created and torn down without exhausting GPU resources.","Update the Chromium build Remotion drives (newer builds carry GPU-process fixes); on Lambda, use a current Chrome layer."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Resource-allocation failures are GPU-state dependent and cannot be predicted,\n// so catch the render promise and retry on a different GL backend.\nasync function safeRender(opts) {\n  try {\n    return await renderMedia(opts);\n  } catch (err) {\n    if (/WebGL/.test(String(err?.message ?? ''))) {\n      return await renderMedia({...opts, gl: 'swiftshader'});\n    }\n    throw err;\n  }\n}","preventionTips":["Pin a reliable GL backend for your environment: pass `gl: 'swiftshader'` (or 'angle') to renderMedia/renderMediaOnLambda.","Cap render concurrency so per-frame WebGL contexts are not created faster than the GPU can serve them.","Run Studio preview with hardware acceleration enabled, or on a machine with a working GPU.","Keep the Chromium build Remotion drives current; GPU-process fixes land regularly."],"tags":["webgl","gpu","rendering","effects","runtime"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}