perspective-dev/perspective · error · Error
WebGL is not supported
Error message
WebGL is not supported
What it means
The WebGL context manager tries webgl2 first, then webgl1; when the browser/environment (headless browser, disabled hardware acceleration, exhausted context limit) returns null from both getContext calls, no rendering surface exists and the constructor aborts. This is an environment-capability failure, not bad input.
Solutions
- Enable hardware acceleration or run in a browser with WebGL support
- Check for too many live WebGL contexts (browsers cap ~8–16); release unused canvases
- In headless/CI environments, launch with GPU-enabled flags (e.g. --use-gl=swiftshader) or render server-side
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at packages/viewer-charts/src/ts/webgl/gl-context.ts:82 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of perspective-dev/perspective@11c8238c0c (2026-09-09).
Data as JSON: /api/errors/2a1fe832c55d2995.
Report an issue: GitHub.
Appendix: source
Thrown at packages/viewer-charts/src/ts/webgl/gl-context.ts:82
this._precompile = options.precompile ?? false;
const gl2 = canvas.getContext("webgl2", {
antialias: true,
alpha: true,
premultipliedAlpha: false,
});
if (gl2) {
this.gl = gl2 as WebGL2RenderingContext;
this.isWebGL2 = true;
} else {
const gl1 = canvas.getContext("webgl", {
antialias: true,
alpha: true,
premultipliedAlpha: false,
});
if (!gl1) {
throw new Error("WebGL is not supported");
}
this.gl = gl1 as WebGLRenderingContext;
this.isWebGL2 = false;
}
this.shaders = new ShaderRegistry(this.gl);
if (this._precompile) {
this.shaders.precompile(SHADER_MANIFEST);
}
this._maxVertexAttribs = this.gl.getParameter(
this.gl.MAX_VERTEX_ATTRIBS,
) as number;
if (!this.isWebGL2) {
this._angle = this.gl.getExtension("ANGLE_instanced_arrays");
}
View on GitHub (pinned to 11c8238c0c)