{"record":{"id":"2f8383525aedf35b","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-program-2f8383","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/shrinkwrap.ts","lineNumber":424,"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(`Shrinkwrap 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(`Shrinkwrap program link failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn program;\n};\n\nexport const shrinkwrap = createEffect<ShrinkwrapParams, ShrinkwrapState>({\n\ttype: 'dev.remotion.effects.shrinkwrap',\n\tlabel: 'shrinkwrap()',\n\tdocumentationLink: 'https://www.remotion.dev/docs/effects/shrinkwrap',","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/shrinkwrap.ts#L406-L442","documentation":"The shrinkwrap() effect's linkProgram helper calls gl.createProgram() during setup. If the WebGL2 driver returns null, the effect throws this generic Error. The context was created successfully but cannot allocate a program object, indicating extreme GPU resource exhaustion or a degraded/lost context.","triggerScenarios":"Calling shrinkwrap() when the WebGL2 context is under severe resource pressure — too many live program objects across effect instances, GPU memory exhaustion, or a context-loss event between getContext and createProgram.","commonSituations":"High-concurrency renders creating many simultaneous WebGL2 programs; software rendering backends with hard object limits; leaked program objects from prior effect instances that bypassed cleanup; transient context loss during setup.","solutions":["Reduce render concurrency to limit the number of live WebGL2 program objects.","Ensure the effect cleanup lifecycle runs properly — cleanup() calls gl.deleteProgram().","Verify GPU acceleration in the render environment.","Retry after confirming context health (no 'webglcontextlost' event)."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Probe whether the WebGL2 context can allocate a program object\nfunction canCreateProgram(canvas: HTMLCanvasElement): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const program = gl.createProgram();\n  const ok = program !== null;\n  if (program) gl.deleteProgram(program);\n  return ok;\n}","typeGuard":"null","tryCatchPattern":"try {\n  shrinkwrap({ amount: 1 });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to create WebGL program') {\n    console.warn('WebGL2 program allocation failed for shrinkwrap');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Reduce concurrency to limit simultaneous program objects.","Ensure effect cleanup() runs to release GPU program objects.","Verify GPU acceleration in the render environment.","Handle context-loss events and retry after restoration."],"tags":["webgl2","gpu","resource-allocation","program","memory"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}