{"record":{"id":"c0fef14a1cea80cc","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-c0fef1","errorCode":null,"errorMessage":"Failed to create WebGL shader","messagePattern":"Failed to create WebGL shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/starburst.ts","lineNumber":238,"sourceCode":"\tuColorPalette: WebGLUniformLocation | null;\n\tuNumRays: WebGLUniformLocation | null;\n\tuRotationOffset: WebGLUniformLocation | null;\n\tuSmoothEdge: WebGLUniformLocation | null;\n\tuResolution: WebGLUniformLocation | null;\n\tuNumColors: WebGLUniformLocation | null;\n\tuOrigin: WebGLUniformLocation | null;\n\tcachedPaletteKey: string;\n\tpalettePixelData: Uint8Array;\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(`Starburst 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":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/starburst.ts#L220-L256","documentation":"During starburst effect `setup`, `gl.createShader()` returned `null`, meaning the WebGL2 implementation could not allocate a new shader object. This typically indicates the GL context has been lost, the GPU/driver is out of resources, or the context is in a degraded state. The error is thrown before any shader source is uploaded.","triggerScenarios":"The WebGL2 context was lost (e.g. tab backgrounded, GPU driver reset) before setup ran; too many shader objects already allocated in the page; running in a headless browser with incomplete WebGL2 support; the canvas's GL context was already destroyed.","commonSituations":"Rendering many starburst (or other webgl2) effect instances concurrently in a single page; long-running Studio sessions where the GPU driver crashes and resets; CI environments using software-rendered WebGL with low resource caps; mobile browsers under memory pressure.","solutions":["Reduce the number of concurrent webgl2 effects in the composition to lower GPU resource pressure.","Restart the render or Studio session to obtain a fresh WebGL2 context.","In headless/CI environments, ensure the browser (e.g. Chrome headless) is launched with GPU/WebGL2 enabled flags like `--use-gl=angle --use-angle=swiftshader`.","Check for and handle `webglcontextlost` events on the canvas to proactively recreate contexts."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Before mounting the effect, probe WebGL2 viability on a scratch canvas.\nconst supportsWebGL2 = (): boolean => {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    const shader = gl?.createShader(gl.VERTEX_SHADER);\n    const ok = !!shader;\n    shader && gl!.deleteShader(shader);\n    return ok;\n  } catch {\n    return false;\n  }\n};\nif (!supportsWebGL2()) { /* skip starburst or use a 2d fallback */ }","typeGuard":null,"tryCatchPattern":"try {\n  starburst({...params});\n} catch (e) {\n  if (/Failed to create WebGL/.test((e as Error).message)) {\n    // context lost / exhausted: skip the effect or requeue the render\n    renderFallbackFrame();\n  } else throw e;\n}","preventionTips":["Limit the number of concurrent webgl2 effects to keep GL resource usage bounded.","Handle `webglcontextlost` on canvases and reinitialize effect state on restore.","In headless/CI, launch Chrome with WebGL2-capable flags and adequate GPU memory."],"tags":["starburst","webgl2","gpu","resource-exhaustion","context-lost","setup"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}