{"record":{"id":"0ce7b03516c4488b","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-0ce7b0","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/speckle.ts","lineNumber":166,"sourceCode":"\tprogram: WebGLProgram;\n\tvao: WebGLVertexArrayObject;\n\tvbo: WebGLBuffer;\n\ttexture: WebGLTexture;\n\tuSource: WebGLUniformLocation | null;\n\tuResolution: WebGLUniformLocation | null;\n\tuDensity: WebGLUniformLocation | null;\n\tuSize: WebGLUniformLocation | null;\n\tuRandomness: 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(`Speckle 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":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/speckle.ts#L148-L184","documentation":"The speckle() effect's compileShader() in packages/effects/src/speckle.ts calls gl.createShader(), which returned null. Identical root cause to the skew case: the WebGL2 context is lost, resource-exhausted, or non-conformant, so speckle cannot build the SPECKLE_VS/SPECKLE_FS shaders it needs. The context was acquired (createWebGL2ContextError did not fire), so this is an allocation failure during setup.","triggerScenarios":"Applying speckle() while the WebGL2 context is in a lost state, or once the process has exceeded the browser's live WebGL-context limit so new contexts are immediately unusable; also possible under GPU memory pressure or a driver reset between getContext() and createShader().","commonSituations":"Headless/CI rendering without --gl=angle; many parallel frames each stacking multiple WebGL2 effects; SwiftShader/llvmpipe software fallback under load; hosts with failing or absent GPU drivers.","solutions":["Render with ANGLE (--gl=angle / chromiumOptions.gl='angle' / Studio OpenGL=angle).","Reduce concurrency and the number of WebGL2 effects stacked per frame to stay under the active-context cap.","Make sure each effect's cleanup runs so contexts/shaders are released before new effects initialize.","Verify the target environment has working WebGL2 (supported GPU and current drivers)."],"exampleFix":"// before\nnpx remotion render main MyComp out.mp4\n// after\nnpx remotion render main MyComp out.mp4 --gl=angle","handlingStrategy":"try-catch","validationCode":"function supportsWebGL2Effect(): boolean {\n  try {\n    return !!document.createElement('canvas').getContext('webgl2');\n  } catch {\n    return false;\n  }\n}\nif (!supportsWebGL2Effect()) {\n  throw new Error('speckle() requires WebGL2, which is unavailable in this environment');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await renderMedia({ composition, codec: 'h264', chromiumOptions: { gl: 'angle' } });\n} catch (err) {\n  if (err instanceof Error && /Failed to create WebGL shader/.test(err.message)) {\n    console.error('WebGL2 shader allocation failed for speckle(). Use --gl=angle and/or lower concurrency.', err);\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Render WebGL2 effects with the ANGLE backend.","Keep concurrency and stacked WebGL2-effect counts under the live-context cap.","Verify cleanup runs so contexts/shaders are freed.","Render on hosts with supported GPUs and current drivers."],"tags":["webgl","gpu","effects","speckle","rendering","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}