{"record":{"id":"77fa167f5486e483","repo":"remotion-dev/remotion","slug":"failed-to-acquire-2d-context-for-color-parsing-77fa16","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/light-trail/light-trail-runtime.ts","lineNumber":145,"sourceCode":"\t\tthrow new Error('Failed to create WebGL buffer');\n\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 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: createRgbaTexture(gl),\n\t\tuniforms: {\n\t\t\tuSource: gl.getUniformLocation(program, 'uSource'),\n\t\t\tuDirection: gl.getUniformLocation(program, 'uDirection'),\n\t\t\tuTexelSize: gl.getUniformLocation(program, 'uTexelSize'),\n\t\t\tuColor: gl.getUniformLocation(program, 'uColor'),\n\t\t\tuDistance: gl.getUniformLocation(program, 'uDistance'),\n\t\t\tuIntensity: gl.getUniformLocation(program, 'uIntensity'),\n\t\t\tuDecay: gl.getUniformLocation(program, 'uDecay'),\n\t\t\tuThreshold: gl.getUniformLocation(program, 'uThreshold'),\n\t\t\tuSamples: gl.getUniformLocation(program, 'uSamples'),","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/light-trail/light-trail-runtime.ts#L127-L163","documentation":"Thrown when a 1x1 helper canvas's `getContext('2d', {willReadFrequently:true})` returns null. This offscreen 2D context exists only to parse the effect's `color` string into RGBA via the browser color parser; it has nothing to do with the WebGL output path.","triggerScenarios":"Running in an environment without a 2D canvas implementation (some test/jsdom setups); browser limits on total canvas contexts exceeded; a hardened CSP/security flag disabling 2D canvas.","commonSituations":"jsdom-based unit tests that do not polyfill CanvasRenderingContext2D; extremely long-lived pages hitting the per-page canvas context cap; sandboxed iframes blocking canvas.","solutions":["In jsdom tests, install a canvas polyfill (e.g. `canvas` npm package configured for jsdom) or skip this effect.","Close unused canvases/contexts in long-running apps to stay under the browser context cap.","Relax the sandbox/CSP so 2D canvas is available, or run the effect in a non-sandboxed render worker.","Ensure the render runtime is a real browser engine (Chromium) and not a minimal DOM shim."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const has2dContext = (): boolean => {\n  try {\n    const c = document.createElement('canvas');\n    return !!c.getContext('2d', { willReadFrequently: true });\n  } catch {\n    return false;\n  }\n};","typeGuard":"const canParseColors = (): boolean => {\n  try {\n    return !!document.createElement('canvas').getContext('2d');\n  } catch {\n    return false;\n  }\n};","tryCatchPattern":null,"preventionTips":["Run lightTrail in a real browser engine, not jsdom without a canvas polyfill.","Free unused canvas contexts to stay under the per-page cap.","Whitelist 2D canvas in sandbox/CSP for the render worker."],"tags":["canvas","light-trail","effects","environment","color-parsing"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}