{"record":{"id":"755f3ecfc28a5c4d","repo":"siyuan-note/siyuan","slug":"canvas-2d-is-unavailable","errorCode":null,"errorMessage":"Canvas 2D is unavailable","messagePattern":"Canvas 2D is unavailable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/src/layout/dock/graph/canvasRenderer.ts","lineNumber":11,"sourceCode":"import {getGraphNodeColor, IGraphRenderer, IGraphRenderState} from \"./renderer\";\nimport {getGraphArrowGeometry, getGraphArrowLength, getGraphEdgeOpacity, MIN_GRAPH_EDGE_WIDTH} from \"./core\";\n\nexport class GraphCanvasRenderer implements IGraphRenderer {\n    private readonly canvas: HTMLCanvasElement;\n    private readonly context: CanvasRenderingContext2D;\n\n    constructor(canvas: HTMLCanvasElement) {\n        const context = canvas.getContext(\"2d\");\n        if (!context) {\n            throw new Error(\"Canvas 2D is unavailable\");\n        }\n        this.canvas = canvas;\n        this.context = context;\n    }\n\n    public render(state: IGraphRenderState) {\n        const width = Math.max(1, Math.round(state.width * state.devicePixelRatio));\n        const height = Math.max(1, Math.round(state.height * state.devicePixelRatio));\n        if (this.canvas.width !== width || this.canvas.height !== height) {\n            this.canvas.width = width;\n            this.canvas.height = height;\n        }\n        const context = this.context;\n        context.setTransform(state.devicePixelRatio, 0, 0, state.devicePixelRatio, 0, 0);\n        context.clearRect(0, 0, state.width, state.height);\n        context.lineWidth = Math.max(MIN_GRAPH_EDGE_WIDTH, state.options.linkWidth * state.camera.scale);\n        context.lineCap = \"round\";\n        this.drawEdgeGroup(state, false, false);","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/src/layout/dock/graph/canvasRenderer.ts#L1-L29","documentation":"GraphCanvasRenderer constructor guard: canvas.getContext(\"2d\") returned null, so no 2D rendering context could be created for the relation graph canvas. The browser denied the context (context lost, too many contexts, headless/software rendering unavailable), and the fallback canvas renderer cannot operate.","triggerScenarios":"Thrown at app/src/layout/dock/graph/canvasRenderer.ts:11 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Free other canvas contexts in the page and retry creating the renderer","Verify GPU/blacklist status in the browser (about:gpu or chrome://gpu)","Switch to a browser/environment that supports Canvas 2D"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}