{"record":{"id":"ac0cfbfa88339d1b","repo":"remotion-dev/remotion","slug":"failed-to-acquire-2d-context-for-color-parsing-ac0cfb","errorCode":null,"errorMessage":"Failed to acquire 2D context for color parsing","messagePattern":"Failed to acquire 2D context for color parsing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/vignette.ts","lineNumber":378,"sourceCode":"\t}\n\n\tgl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n\tgl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);\n\n\tgl.enableVertexAttribArray(0);\n\tgl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);\n\tgl.enableVertexAttribArray(1);\n\tgl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);\n\n\tgl.bindVertexArray(null);\n\n\tconst textureSource = createRgbaTexture(gl);\n\tconst colorCanvas = document.createElement('canvas');\n\tcolorCanvas.width = 1;\n\tcolorCanvas.height = 1;\n\tconst colorCtx = colorCanvas.getContext('2d', {willReadFrequently: true});\n\tif (!colorCtx) {\n\t\tthrow new Error('Failed to acquire 2D context for color parsing');\n\t}\n\n\treturn {\n\t\tgl,\n\t\tprogram,\n\t\tvao,\n\t\tvbo,\n\t\ttextureSource,\n\t\tuniforms: {\n\t\t\tuSource: gl.getUniformLocation(program, 'uSource'),\n\t\t\tuAmount: gl.getUniformLocation(program, 'uAmount'),\n\t\t\tuRadius: gl.getUniformLocation(program, 'uRadius'),\n\t\t\tuFeather: gl.getUniformLocation(program, 'uFeather'),\n\t\t\tuRoundness: gl.getUniformLocation(program, 'uRoundness'),\n\t\t\tuColor: gl.getUniformLocation(program, 'uColor'),\n\t\t\tuMode: gl.getUniformLocation(program, 'uMode'),\n\t\t\tuCenter: gl.getUniformLocation(program, 'uCenter'),\n\t\t},","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/vignette.ts#L360-L396","documentation":"Thrown by setupVignette when a freshly created 1x1 canvas's getContext('2d', {willReadFrequently: true}) returns null. Vignette uses this 2D context to parse the color string into RGBA each time the color changes. A null 2D context is rare and indicates an environment without 2D canvas support or an exhausted canvas/context budget.","triggerScenarios":"setupVignette creates an offscreen 1x1 canvas and asks for a 2D context; the host returns null. Happens in environments that disable 2D canvas, or when the browser's canvas/context budget is exhausted.","commonSituations":"Hardened/embedded runtimes that disable 2D canvas; too many live canvas contexts; very old or non-standard browser engines; some headless configurations that restrict 2D canvas.","solutions":["Run in a browser/headless Chrome that supports the 2D canvas context (the default for Chrome).","Reduce the number of simultaneously-live canvases/effects.","Update the browser/runtime to one with full canvas support.","If embedding in a restricted runtime, enable 2D canvas in its configuration."],"exampleFix":"// before\nconst effect = vignette({amount: 0.6, color: '#000000'}); // 2D context missing\n\n// after - fall back when the host lacks a 2D canvas\nconst effect = (() => {\n  try { return vignette({amount: 0.6, color: '#000000'}); } catch { return null; }\n})();","handlingStrategy":"try-catch","validationCode":"const has2dContext = () => {\n  try {\n    const c = document.createElement('canvas');\n    return !!c.getContext('2d');\n  } catch {\n    return false;\n  }\n};","typeGuard":null,"tryCatchPattern":"let effect = null;\ntry {\n  effect = vignette({amount: 0.6, color: '#000000'});\n} catch (err) {\n  console.warn('vignette needs a 2D canvas for color parsing; skipping', err);\n}","preventionTips":["Run in a browser/headless Chrome with 2D canvas support (Chrome default).","Avoid environments that disable 2D canvas for the color-parsing path.","Keep the number of live canvases/effects low to stay under context budgets.","If embedding in a restricted runtime, enable 2D canvas in its config."],"tags":["webgl2","canvas","environment","vignette"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}