{"record":{"id":"5137fec00cebff4d","repo":"plotly/plotly.js","slug":"error-creating-static-canvas-context-for-image-ser","errorCode":null,"errorMessage":"error creating static canvas/context for image server","messagePattern":"error creating static canvas/context for image server","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/plots/gl3d/scene.js","lineNumber":121,"sourceCode":"        autoScale: true,\n        autoBounds: false,\n        cameraObject: scene.camera,\n        pixelRatio: scene.pixelRatio\n    };\n\n    // for static plots, we reuse the WebGL context\n    //  as WebKit doesn't collect them reliably\n    if(scene.staticMode) {\n        if(!STATIC_CONTEXT) {\n            STATIC_CANVAS = document.createElement('canvas');\n            STATIC_CONTEXT = getContext({\n                canvas: STATIC_CANVAS,\n                preserveDrawingBuffer: true,\n                premultipliedAlpha: true,\n                antialias: true\n            });\n            if(!STATIC_CONTEXT) {\n                throw new Error('error creating static canvas/context for image server');\n            }\n        }\n\n        opts.gl = STATIC_CONTEXT;\n        opts.canvas = STATIC_CANVAS;\n    }\n\n    return opts;\n};\n\nvar firstInit = true;\n\nproto.tryCreatePlot = function() {\n    var scene = this;\n\n    var opts = scene.prepareOptions();\n\n    var success = true;","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/plotly/plotly.js/blob/1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314/src/plots/gl3d/scene.js#L103-L139","documentation":"WebGL setup guard for gl3d scenes in staticMode (used when rendering images server-side or via toImage). Plotly creates one shared offscreen canvas and reuses its WebGL context across static plots because WebKit does not reliably garbage-collect them. If canvas.getContext('webgl') (via the gl-context helper) returns null — typically because the environment has no WebGL support, contexts are exhausted, or hardware acceleration is disabled — there is no context to hand to the scene renderer and the error is thrown.","triggerScenarios":"Thrown at src/plots/gl3d/scene.js:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify WebGL is available in the environment (browsers: chrome://gpu; Node: ensure headless-gl / a GPU-capable GL stack is installed).","Free unused WebGL contexts; browsers cap the number of live contexts (~16), so destroy old plots before creating new ones.","When rasterizing with tools like puppeteer, launch with GPU/GL flags enabled (--enable-webgl, --use-gl=swiftshader).","Update graphics drivers or run on a machine with hardware acceleration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314","analyzedAt":"2026-09-02T22:03:39.906Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}