{"record":{"id":"aad66bfea2c6ab15","repo":"remotion-dev/remotion","slug":"failed-to-acquire-2d-context-for-color-parsing-aad66b","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":"critical","filePath":"packages/effects/src/lines.ts","lineNumber":421,"sourceCode":"\n\tgl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n\tgl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);\n\n\tconst aPos = gl.getAttribLocation(program, 'aPos');\n\tconst aUv = gl.getAttribLocation(program, 'aUv');\n\tgl.enableVertexAttribArray(aPos);\n\tgl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);\n\tgl.enableVertexAttribArray(aUv);\n\tgl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);\n\n\tgl.bindVertexArray(null);\n\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\tsourceTexture: createTexture(gl, gl.LINEAR),\n\t\tpaletteTexture: createTexture(gl, gl.NEAREST),\n\t\tcolorCtx,\n\t\tuniforms: {\n\t\t\tuSource: gl.getUniformLocation(program, 'uSource'),\n\t\t\tuPalette: gl.getUniformLocation(program, 'uPalette'),\n\t\t\tuResolution: gl.getUniformLocation(program, 'uResolution'),\n\t\t\tuNumColors: gl.getUniformLocation(program, 'uNumColors'),\n\t\t\tuDirection: gl.getUniformLocation(program, 'uDirection'),\n\t\t\tuThickness: gl.getUniformLocation(program, 'uThickness'),\n\t\t\tuSpacing: gl.getUniformLocation(program, 'uSpacing'),","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/lines.ts#L403-L439","documentation":"A plain Error thrown inside setupLines when a 1x1 helper canvas's getContext('2d', {willReadFrequently:true}) returns null. The Lines effect uses this offscreen 2D context to parse color strings into RGBA via fillStyle + getImageData, so it cannot translate the palette without it.","triggerScenarios":"document.createElement('canvas').getContext('2d') returns null — happens when the environment limits 2D canvas contexts, has a hardened browser config that disables 2D canvases, or is a non-browser DOM shim lacking CanvasRenderingContext2D.","commonSituations":"Headless/test environments with canvas disabled; browsers with too many live 2D contexts; security-hardened browser profiles; SSR/snapshot runs that accidentally execute effect setup outside a real browser.","solutions":["Ensure the render runs in a real browser context (Remotion renders via headless Chromium by default).","Reduce the number of simultaneously alive 2D canvas contexts.","If using a custom browser config, confirm 2D canvas is not disabled."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function has2dContext(): boolean {\n  const c = document.createElement('canvas');\n  return !!c.getContext('2d', {willReadFrequently: true});\n}","typeGuard":null,"tryCatchPattern":"try {\n  lines(...);\n} catch (err) {\n  if (err instanceof Error && /2D context for color parsing/.test(err.message)) {\n    // run in a real browser / enable 2D canvas, then retry\n  } else throw err;\n}","preventionTips":["Run Remotion renders in a real headless Chromium, not a DOM shim.","Avoid disabling 2D canvas in hardened browser profiles.","Reduce the number of simultaneously live 2D contexts."],"tags":["webgl2","lines-effect","canvas2d","environment","color-parsing"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}