{"record":{"id":"4bee02e79be7a6e7","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader","errorCode":null,"errorMessage":"Failed to create WebGL shader","messagePattern":"Failed to create WebGL shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/brand/src/effects/metallic-swirl-effect.ts","lineNumber":462,"sourceCode":"\t\tuBackgroundColor,\n\t\tcolor,\n\t\tclamp(luminance * 6.0, 0.0, 1.0)\n\t);\n\tvec3 result = uMode == 1 ? generated : mix(sourceRgb, generated, uOpacity);\n\tfloat alpha = uMode == 1 ? source.a * uOpacity : source.a;\n\n\tfragColor = vec4(result * 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(\n\t\t\t`Metallic swirl shader compile failed: ${log ?? '(no log)'}`,\n\t\t);\n\t}\n\n\treturn shader;\n};\n\nconst linkProgram = (\n\tgl: WebGL2RenderingContext,\n\tvs: WebGLShader,","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/brand/src/effects/metallic-swirl-effect.ts#L444-L480","documentation":"In `compileShader`, `gl.createShader(type)` returned `null`. The WebGL2 spec returns null only on context loss or when arguments are invalid; here the type is always a valid constant. Practically this means the WebGL2 context is lost, the GPU resources are exhausted, or the context is in a broken state. This is an environment/resource failure, not a code bug in your call.","triggerScenarios":"Rendering on a machine without working WebGL2 drivers; GPU memory exhausted after creating many effects/canvases; context lost due to a driver crash, system sleep/wake, or too many contexts; headless rendering without GPU support (e.g. software WebGL fallback failing).","commonSituations":"Long-running Studio sessions that leak contexts; rendering farms or CI without GPU; older drivers or virtual machines; many simultaneous metallic-swirl effects across multiple sequences.","solutions":["Verify WebGL2 is available in the target browser/machine (run a getContext('webgl2') check).","Reduce the number of simultaneously mounted effects to free GPU resources.","Update GPU drivers / use a hardware-accelerated browser.","For headless rendering, ensure the renderer uses a GPU-backed Chrome (Remotion's headless shell) rather than a software-only fallback."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Probe WebGL2 availability before mounting the effect.\nconst supportsWebGL2 = (): boolean => {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    return !!gl;\n  } catch {\n    return false;\n  }\n};\nif (!supportsWebGL2()) {\n  // show a fallback or skip the effect\n}","typeGuard":"const hasHealthyWebGL2 = (canvas: HTMLCanvasElement): boolean => {\n  const gl = canvas.getContext('webgl2');\n  return !!gl && !gl.isContextLost();\n};","tryCatchPattern":"try {\n  metallicSwirl({speed: 1})(...);\n} catch (err) {\n  if (err instanceof Error && /Failed to create WebGL shader/.test(err.message)) {\n    // fall back to a non-WebGL effect or notify the user\n  } else {\n    throw err;\n  }\n}","preventionTips":["Verify WebGL2 is available and healthy before mounting metallic-swirl effects.","Limit the number of simultaneously mounted WebGL2 effects to avoid GPU resource exhaustion.","Dispose/unmount effects when sequences end to free shader slots.","Use a hardware-accelerated browser with up-to-date GPU drivers."],"tags":["brand","metallic-swirl","webgl","gpu","environment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}