plotly/plotly.js · error · Error
error creating static canvas/context for image server
Error message
error creating static canvas/context for image server
What it means
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.
Source
Thrown at src/plots/gl3d/scene.js:121
autoScale: true,
autoBounds: false,
cameraObject: scene.camera,
pixelRatio: scene.pixelRatio
};
// for static plots, we reuse the WebGL context
// as WebKit doesn't collect them reliably
if(scene.staticMode) {
if(!STATIC_CONTEXT) {
STATIC_CANVAS = document.createElement('canvas');
STATIC_CONTEXT = getContext({
canvas: STATIC_CANVAS,
preserveDrawingBuffer: true,
premultipliedAlpha: true,
antialias: true
});
if(!STATIC_CONTEXT) {
throw new Error('error creating static canvas/context for image server');
}
}
opts.gl = STATIC_CONTEXT;
opts.canvas = STATIC_CANVAS;
}
return opts;
};
var firstInit = true;
proto.tryCreatePlot = function() {
var scene = this;
var opts = scene.prepareOptions();
var success = true;View on GitHub (pinned to 1d090e0b5f)
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.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/plots/gl3d/scene.js:121 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02).
Data as JSON: /api/errors/5137fec00cebff4d.
Report an issue: GitHub.