{"record":{"id":"9eea73eabaa1f098","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-9eea73","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/shrinkwrap.ts","lineNumber":403,"sourceCode":"\t);\n\tfloat shadow = clamp((creaseShadow * 0.1 + edge * 0.06) * uAmount, 0.0, 0.25);\n\n\trgb *= 1.0 - shadow;\n\trgb += (1.0 - rgb) * min(highlight, 1.0);\n\trgb += vec3(max(highlight - 1.0, 0.0)) * 0.35;\n\n\tfragColor = vec4(clamp(rgb, 0.0, 1.0) * 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(`Shrinkwrap 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":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/shrinkwrap.ts#L385-L421","documentation":"The shrinkwrap() effect's compileShader helper calls gl.createShader() during setup. If the WebGL2 context returns null, the effect throws this generic Error. This indicates the context was created but cannot allocate a shader object — severe GPU resource starvation or a context in a lost/degraded state.","triggerScenarios":"Calling shrinkwrap() in an environment where WebGL2 exists but shader object allocation fails: headless Chrome with software rendering, GPU memory exhaustion, or a context that lost its resources between getContext and createShader.","commonSituations":"CI runners using SwiftShader under memory pressure; Remotion Lambda with missing GPU libraries; too many concurrent WebGL2 effects exhausting the driver object pool; transient context loss during setup.","solutions":["Ensure hardware-accelerated WebGL2 is available in the render environment.","Reduce the number of concurrent WebGL2-backed effects.","Check for and handle 'webglcontextlost' events on the canvas.","Update GPU drivers or switch to a host with proper WebGL2 support."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Check if the WebGL2 context can allocate a shader object\nfunction canCreateShader(canvas: HTMLCanvasElement): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const shader = gl.createShader(gl.VERTEX_SHADER);\n  const ok = shader !== null;\n  if (shader) gl.deleteShader(shader);\n  return ok;\n}","typeGuard":"null","tryCatchPattern":"try {\n  shrinkwrap({ amount: 1 });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL shader') {\n    console.warn('WebGL2 shader allocation failed for shrinkwrap');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Ensure GPU acceleration is available in the render environment.","Limit concurrent WebGL2 effect instances.","Handle context-loss events gracefully.","Keep GPU drivers updated."],"tags":["webgl2","gpu","resource-allocation","shader","headless"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}