{"record":{"id":"055ffd70c84d09e8","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-program-055ffd","errorCode":null,"errorMessage":"Failed to create WebGL program","messagePattern":"Failed to create WebGL program","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/gridlines.ts","lineNumber":386,"sourceCode":"\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(`Gridlines 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 => {\n\tconst program = gl.createProgram();\n\tif (!program) {\n\t\tthrow new Error('Failed to create WebGL program');\n\t}\n\n\tgl.attachShader(program, vs);\n\tgl.attachShader(program, fs);\n\tgl.linkProgram(program);\n\tif (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n\t\tconst log = gl.getProgramInfoLog(program);\n\t\tgl.deleteProgram(program);\n\t\tthrow new Error(`Gridlines program link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\nconst rgbaToUniform = (\n\trgba: ParsedColorRgba,\n): readonly [number, number, number, number] => {\n\tconst [r, g, b, a] = rgba;","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/gridlines.ts#L368-L404","documentation":"Thrown by gridlines' linkProgram (gridlines.ts:386) when gl.createProgram() returns null. A null program means WebGL could not allocate the program object — the same class of failure as a null shader: context loss or GPU resource exhaustion. The library throws because attachShader/linkProgram would fail on null.","triggerScenarios":"Called during Gridlines setup after both shaders compiled successfully. Triggered by a lost WebGL2 context, or cumulative resource exhaustion where the driver refuses to allocate another program object.","commonSituations":"Long renders leaking GL objects; many simultaneous WebGL effects/compositions; GPU reset mid-render; running on constrained integrated GPUs or software renderers.","solutions":["Handle webglcontextlost on the canvas and tear down/rebuild effect state on restore.","Ensure effect cleanup() deletes programs/buffers/textures so they do not accumulate.","Limit concurrent WebGL compositions; render sequentially if GPU memory is constrained.","Restart the browser/GPU; update drivers if the failure is persistent."],"exampleFix":"// before: programs accumulate because cleanup is never invoked\nconst run = () => gridlinesEffect.setup(canvas); // called repeatedly\n\n// after: pair every setup with cleanup\nconst state = gridlinesEffect.setup(canvas);\n// ... use ...\ngridlinesEffect.cleanup(state); // frees the GL program","handlingStrategy":"try-catch","validationCode":"if (gl.isContextLost()) {\n  throw new Error('WebGL2 context lost; cannot create program');\n}","typeGuard":"null","tryCatchPattern":"try {\n  gridlines.setup(canvas);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL program') {\n    // context loss / resource exhaustion\n  }\n  throw e;\n}","preventionTips":["Handle context loss and rebuild on restore.","Free programs in cleanup().","Limit concurrent WebGL effects/compositions.","Restart browser/GPU when allocation failures become persistent."],"tags":["webgl","gridlines-effect","program","gpu","resource-exhaustion"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}