remotion-dev/remotion · critical · Error
Failed to acquire 2D context for color parsing
Error message
Failed to acquire 2D context for color parsing
What it means
A plain Error thrown inside setup in the Liquid contours effect when a 1x1 helper canvas's getContext('2d', {willReadFrequently:true}) returns null. The effect uses this offscreen 2D context to parse firstColor/secondColor strings into RGBA via fillStyle + getImageData, so color setup cannot proceed without it.
Source
Thrown at packages/effects/src/liquid-contours.ts:353
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1]),
gl.STATIC_DRAW,
);
const aPos = gl.getAttribLocation(program, 'aPos');
const aUv = gl.getAttribLocation(program, 'aUv');
gl.enableVertexAttribArray(aPos);
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
gl.enableVertexAttribArray(aUv);
gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
gl.bindVertexArray(null);
const colorCanvas = document.createElement('canvas');
colorCanvas.width = 1;
colorCanvas.height = 1;
const colorCtx = colorCanvas.getContext('2d', {willReadFrequently: true});
if (!colorCtx)
throw new Error('Failed to acquire 2D context for color parsing');
return {
gl,
program,
vao,
vbo,
colorCtx,
uniforms: {
uResolution: gl.getUniformLocation(program, 'uResolution'),
uFirstColor: gl.getUniformLocation(program, 'uFirstColor'),
uSecondColor: gl.getUniformLocation(program, 'uSecondColor'),
uSpacing: gl.getUniformLocation(program, 'uSpacing'),
uScale: gl.getUniformLocation(program, 'uScale'),
uComplexity: gl.getUniformLocation(program, 'uComplexity'),
uSmoothness: gl.getUniformLocation(program, 'uSmoothness'),
uSeed: gl.getUniformLocation(program, 'uSeed'),
uOffset: gl.getUniformLocation(program, 'uOffset'),
uPhase: gl.getUniformLocation(program, 'uPhase'),
},View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Run the effect inside a real browser context (Remotion renders via headless Chromium).
- Reduce simultaneously live 2D canvas contexts.
- Confirm 2D canvas is not disabled by the browser/security config.
Defensive patterns
Strategy: try-catch
Validate before calling
function has2dContext(): boolean {
const c = document.createElement('canvas');
return !!c.getContext('2d', {willReadFrequently: true});
} Try / catch
try {
liquidContours(...);
} catch (err) {
if (err instanceof Error && /2D context for color parsing/.test(err.message)) {
// run in a real browser / enable 2D canvas, then retry
} else throw err;
} Prevention
- Run Remotion renders in real headless Chromium, not a DOM shim.
- Do not disable 2D canvas in hardened browser profiles.
- Reduce the number of simultaneously live 2D contexts.
When it happens
Trigger: document.createElement('canvas').getContext('2d') returns null — environment caps 2D contexts, disables canvas, or lacks CanvasRenderingContext2D (e.g. a non-browser DOM shim). Independent of the color values themselves.
Common situations: Headless/test environments with canvas disabled; too many live 2D contexts in the page; hardened browser profiles; SSR/snapshot code that accidentally runs effect setup outside a browser.
Related errors
- Failed to acquire 2D context for color parsing
- Failed to acquire 2D context for color parsing
- Failed to acquire 2D context for color parsing
- Failed to acquire 2D context for color parsing
- Failed to create WebGL shader
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/45303e562483998c.
Report an issue: GitHub.