Blank Plots When Exceeding the Browser WebGL Context Limit with Plotly.js scattergl Charts
0 reputation · 19 Mar 2026, 22:57 UTC
0 reputation · 19 Mar 2026, 22:57 UTC
A documented failure condition for Plotly.js WebGL-accelerated traces (scattergl, pointcloud, parcoords) is the browser's WebGL context limit. When a single page creates more WebGL contexts than the browser allows (commonly cited around 16 in Chrome, though this varies by browser and version), the oldest contexts are lost and the affected charts render blank or break. This makes dashboards with many scattergl charts a known risk.
The component in question is the decision of when to use WebGL traces at all. Plotly's guidance is that WebGL helps for large datasets, but the crossover point where scattergl outperforms the SVG scatter trace depends on marker count, browser, and hardware, and WebGL traces lack or alter some SVG features (certain marker symbols, dash styles, per-point styling), so switching can silently change output.
At what dataset size should I benchmark scatter versus scattergl for my environment, and which browser dev-tool signals confirm that rendering, not data processing, is the bottleneck? How can I detect approaching WebGL context saturation before charts go blank on a multi-chart page? Given that WebGL feature support differs across plotly.js releases, how should I verify which styling features my bundled version supports in WebGL mode?
35275 reputation · 20 Mar 2026, 00:30 UTC
For most modern browsers (Chrome 120+, Edge 120+, Firefox 120+), the WebGL context limit is around 16. When you exceed this, Plotly.js silently discards the oldest contexts, causing scattergl charts to render blank. The practical way to decide whether to use scattergl is to benchmark at the point where GPU rendering outweighs SVG rendering – typically between 10,000 and 50,000 markers on a typical workstation. If your page hosts more than 5–6 scattergl charts, start counting contexts or monitor the console for the “Maximum number of WebGL contexts reached” warning.
Performance tab shows a spike in “WebGL draw calls” when rendering is the bottleneck.Maximum number of WebGL contexts reached appears when the limit is hit.diamond-open or cross are unsupported in scattergl; a visual test chart can confirm supported styles.scattergl trace with 5k, 10k, 20k, 40k markers.performance.now() before and after adding the chart.DevTools → Performance, record a session while adding a new chart.WebGL draw calls bar with minimal CPU activity; this indicates GPU work, not data processing.Maximum number of WebGL contexts reached message.Plotly.newPlot in a function that increments a counter each time a scattergl trace is created, and log the count.scattergl charts and switch to scatter for the remaining ones.circle, square, diamond, diamond-open, cross, triangle-up, etc.) in a scattergl trace.How many scattergl charts are you planning to render on a single page? If you’re already approaching the 5–6 chart threshold, consider pre‑loading one chart with a lower marker count or using a hybrid approach (scatter for the first few charts, scattergl for the rest).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.