{"record":{"id":"5d8a16e4ceeaf31f","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-5d8a16","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/dot-grid.ts","lineNumber":158,"sourceCode":"\tprogram: WebGLProgram;\n\tvao: WebGLVertexArrayObject;\n\tvbo: WebGLBuffer;\n\ttexture: WebGLTexture;\n\tuSource: WebGLUniformLocation | null;\n\tuResolution: WebGLUniformLocation | null;\n\tuDotSize: WebGLUniformLocation | null;\n\tuGridSize: WebGLUniformLocation | null;\n\tuInvert: WebGLUniformLocation | null;\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(`Dot grid 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":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/dot-grid.ts#L140-L176","documentation":"Thrown by dot-grid's compileShader helper when gl.createShader() returns null. A null shader means the WebGL2 context could not allocate a new shader object — almost always a sign of a lost, destroyed, or resource-exhausted context rather than a code defect, because the bundled GLSL has not yet been uploaded at this point.","triggerScenarios":"The WebGL2 context was lost (tab backgrounded, GPU reset, too many contexts), the GPU driver crashed, the browser is running in a headless environment without GPU acceleration, or the device hit its per-context shader limit. The throw happens inside dotGrid()'s setup() the first time the effect is mounted.","commonSituations":"Running Remotion Lambda or headless Chromium without SwiftShader/software GL flags; long-running Studio sessions that leaked contexts; CI without --enable-webgl or --use-gl=swiftshader; VMs with no GPU; laptops in battery-saver mode that suspended the GPU.","solutions":["Verify WebGL2 is supported on the target before mounting: const gl = canvas.getContext('webgl2'); if (!gl) fallback();","For headless rendering (Lambda/CI), run Chrome with --use-gl=angle --use-angle=swiftshader (or the equivalent WebGL software renderer for your Chromium build).","Close other tabs / free GPU memory and reload; if the context was lost it may recover.","Update GPU drivers and the browser to the latest stable version.","Report a Remotion issue if the error reproduces on a freshly booted, WebGL2-capable desktop browser."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const supportsWebGL2 = () => {\n  try {\n    const c = document.createElement('canvas');\n    return !!c.getContext('webgl2');\n  } catch {\n    return false;\n  }\n};\n\nif (!supportsWebGL2()) {\n  // omit the dotGrid() effect or render a static fallback layer\n}","typeGuard":null,"tryCatchPattern":"let state;\ntry {\n  state = dotGrid().setup(canvas);\n} catch (err) {\n  if (err instanceof Error && /WebGL/.test(err.message)) {\n    // log, fall back to a non-WebGL layer, or surface a user-facing message\n    console.error('dot-grid unavailable on this device:', err.message);\n  } else {\n    throw err;\n  }\n}","preventionTips":["Feature-detect WebGL2 before mounting effects that use it.","Run headless rendering with a software GL backend (SwiftShader) and adequate memory.","Keep total simultaneously mounted WebGL2 effects low; ensure cleanup runs on unmount.","Update GPU drivers and the browser to a stable version."],"tags":["webgl2","dot-grid","shader","gpu","runtime","headless"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}