{"record":{"id":"8d79882f16c64b40","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-8d7988","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/fisheye/fisheye-runtime.ts","lineNumber":30,"sourceCode":"\ttextureSource: WebGLTexture;\n\tuniforms: {\n\t\tuSource: WebGLUniformLocation | null;\n\t\tuCenter: WebGLUniformLocation | null;\n\t\tuFieldOfView: WebGLUniformLocation | null;\n\t\tuRadius: WebGLUniformLocation | null;\n\t\tuZoom: WebGLUniformLocation | null;\n\t\tuAspect: WebGLUniformLocation | null;\n\t};\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(`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":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/fisheye/fisheye-runtime.ts#L12-L48","documentation":"Thrown inside compileShader() in fisheye-runtime.ts when gl.createShader(type) returns null (fisheye-runtime.ts:29-31). A null shader handle means the GL driver refused to allocate a shader object — context lost or shader-object pool exhausted. Without a handle, neither FISHEYE_VS nor FISHEYE_FS can be built, so fisheye setup aborts.","triggerScenarios":"setupFisheye() -> createProgram() -> compileShader() runs while the WebGL2 context is lost (createShader must return null per spec) or after the driver's shader-object limit is reached from leaked/un-cleaned fisheye programs.","commonSituations":"Rendering on a host whose GPU process crashed leaving the context lost; long-running apps that call setupFisheye() directly without a matching cleanupFisheye(); CI with software GL and a low shader-object ceiling; many concurrent fisheye() instances.","solutions":["Render with the Angle backend (--gl=angle CLI / chromiumOptions.gl='angle' SSR / Angle in Studio).","If using fisheye-runtime directly, always pair setupFisheye() with cleanupFisheye() so shaders/programs are freed.","Reduce simultaneous WebGL2 effects and reuse identical fisheye() params so calculateKey reuses one setup.","Check gl.isContextLost() and restore the context before retrying.","Update GPU drivers or use a host with adequate GL resources."],"exampleFix":"// before\nconst shader = gl.createShader(type);\nif (!shader) {\n  throw new Error('Failed to create WebGL shader');\n}\n\n// after (when using the runtime directly)\nimport {setupFisheye, cleanupFisheye} from '@remotion/effects/fisheye-runtime';\nconst state = setupFisheye(canvas);\ntry { /* applyFisheye(...) */ } finally { cleanupFisheye(state); }","handlingStrategy":"try-catch","validationCode":"const canAllocateShader = (gl: WebGL2RenderingContext): boolean => {\n  if (gl.isContextLost()) return false;\n  const probe = gl.createShader(gl.VERTEX_SHADER);\n  if (!probe) return false;\n  gl.deleteShader(probe);\n  return true;\n};","typeGuard":null,"tryCatchPattern":"import {setupFisheye, cleanupFisheye} from '@remotion/effects/fisheye-runtime';\n\nlet state;\ntry {\n  state = setupFisheye(canvas);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Failed to create WebGL shader') {\n    // context lost or shader pool exhausted; retry on Angle after cleanup\n    throw err;\n  }\n  throw err;\n}\ntry { /* applyFisheye(state, ...) */ } finally { cleanupFisheye(state); }","preventionTips":["When using fisheye-runtime directly, always pair setupFisheye() with cleanupFisheye() so shaders/programs are freed.","Render with Angle (--gl=angle / chromiumOptions.gl='angle').","Limit simultaneous WebGL2 effects; reuse identical fisheye() params via calculateKey.","Handle webglcontextlost and restore before retrying."],"tags":["webgl","shader","resource-allocation","gpu","fisheye","setup"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}