{"record":{"id":"e7a83699c946f77a","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-e7a836","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/shine.ts","lineNumber":194,"sourceCode":"\n\tfloat dist = dot(px - center, uBandNormal) - uBandT;\n\tfloat halo = exp(-(dist * dist) / (uHaloSigma * uHaloSigma)) * uHaloIntensity;\n\tfloat core = exp(-(dist * dist) / (uCoreSigma * uCoreSigma)) * uCoreIntensity;\n\tfloat intensity = clamp(halo + core, 0.0, 1.0);\n\n\tvec3 finalPremult = source.rgb * (1.0 - intensity) + intensity * source.a;\n\tfragColor = vec4(finalPremult, source.a);\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(`Shine 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":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/shine.ts#L176-L212","documentation":"The shine() effect's compileShader helper calls gl.createShader() and throws this generic Error when the WebGL2 driver returns null. This means the context was created but the driver cannot allocate even a shader object, signaling severe GPU resource starvation or a context in a lost state.","triggerScenarios":"Calling shine() in a setup where the WebGL2 context is degraded — headless Chrome with software rendering, a GPU in a reset/recovery state, or too many live GL contexts exhausting the driver's object budget. Distinct from a compile failure (which produces a different error with the info log).","commonSituations":"SwiftShader-based CI runners under memory pressure; Remotion Lambda with insufficient GPU libraries; a browser tab that accumulated leaked shader objects; running effects immediately after a context-loss event before the context is restored.","solutions":["Ensure hardware-accelerated WebGL2 is available in the render environment.","Reduce the number of concurrent shine() or other WebGL2 effect instances.","Check the canvas for 'webglcontextlost' events and re-render after restoration.","Update or replace the GPU driver / Chrome layer if the issue persists across workloads."],"exampleFix":"// before — fails on a context that cannot allocate shaders\nimport { shine } from '@remotion/effects';\nshine({ progress: 0.5 });\n\n// after — guard for environments without reliable WebGL2\ntry {\n  shine({ progress: 0.5 });\n} catch (e) {\n  // fall back to a CSS-based or non-WebGL approach\n  console.error('WebGL2 unavailable, skipping shine effect', e);\n}","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  shine({ progress: 0.5 });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL shader') {\n    // GPU cannot allocate shader objects — fall back\n    console.warn('WebGL2 shader allocation failed');\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-12T23:17:12.415Z"}