{"record":{"id":"8601a2eb944953f4","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-program-8601a2","errorCode":null,"errorMessage":"Failed to create WebGL program","messagePattern":"Failed to create WebGL program","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/pixelate.ts","lineNumber":108,"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(`Pixelate 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(`Pixelate program link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\nconst createPixelateState = (gl: WebGL2RenderingContext): PixelateState => {\n\tconst vs = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);\n\tconst fs = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);\n\tconst program = linkProgram(gl, vs, fs);","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/pixelate.ts#L90-L126","documentation":"Thrown by linkProgram in pixelate.ts when gl.createProgram() returns null. A program object is the container that links vertex+fragment shaders; a null return means the GL implementation cannot allocate the program — almost always because the context is lost or exhausted. The guard prevents attachShader/linkProgram from receiving null.","triggerScenarios":"pixelate setup calls linkProgram after both shaders compiled successfully; gl.createProgram() returns null. Because shaders succeeded, the cause is GL object allocation, not source correctness.","commonSituations":"Context lost between the shader compiles and the program creation; many effects holding live programs in one tab; SwiftShader under load on Lambda; a virtualized GPU with a low program-object cap.","solutions":["Check `gl.isContextLost()` before mounting and remount the effect on restore.","Reduce concurrent WebGL2 effects — each pixelate holds one compiled program for its lifetime.","On Lambda, use the correct Chrome for Testing layer and adequate function memory.","Reproduce with stable desktop Chrome to confirm the environment is at fault.","Free other GPU resources before applying pixelate."],"exampleFix":"// before\nimport {pixelate} from '@remotion/effects';\nconst effect = pixelate();\n\n// after — confirm program allocation is possible\nfunction glCanCreateProgram(gl: WebGL2RenderingContext): boolean {\n  if (gl.isContextLost()) return false;\n  const p = gl.createProgram();\n  const ok = p !== null;\n  if (p) gl.deleteProgram(p);\n  return ok;\n}","handlingStrategy":"try-catch","validationCode":"function glCanCreateProgram(gl: WebGL2RenderingContext): boolean {\n  if (gl.isContextLost()) return false;\n  const p = gl.createProgram();\n  if (p) gl.deleteProgram(p);\n  return p !== null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  pixelate();\n} catch (err) {\n  if (/Failed to create WebGL program/.test((err as Error).message)) {\n    // free GPU resources or remount on context restore\n  }\n  throw err;\n}","preventionTips":["Check gl.isContextLost() before mounting; remount on restore.","Keep concurrent WebGL2 effects low to stay under program-object caps.","Use the correct Lambda Chrome layer.","Reproduce on stable desktop Chrome to confirm environment."],"tags":["webgl","gpu","pixelate","program","environment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}