{"record":{"id":"e26dec3026014f83","repo":"a-b-street/abstreet","slug":"browser-doesn-t-support-webgl-2-0","errorCode":null,"errorMessage":"Browser doesn't support WebGL 2.0","messagePattern":"Browser doesn't support WebGL 2\\.0","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"widgetry/src/backend_glow_wasm.rs","lineNumber":87,"sourceCode":"        .and_then(|gl| webgl2_program(gl))\n        .or_else(|err| {\n            warn!(\n                \"failed to build WebGL 2.0 context with error: \\\"{}\\\". Trying WebGL 1.0 instead...\",\n                err\n            );\n            webgl1_glow_context(&canvas).and_then(|gl| {\n                is_gl2 = false;\n                webgl1_program(gl)\n            })\n        })\n        .unwrap();\n\n    fn webgl2_glow_context(canvas: &web_sys::HtmlCanvasElement) -> Result<glow::Context> {\n        let maybe_context: Option<_> = canvas\n            .get_context(\"webgl2\")\n            .map_err(|err| anyhow!(\"error getting context for WebGL 2.0: {:?}\", err))?;\n        let js_webgl2_context =\n            maybe_context.ok_or(anyhow!(\"Browser doesn't support WebGL 2.0\"))?;\n        let webgl2_context = js_webgl2_context\n            .dyn_into::<web_sys::WebGl2RenderingContext>()\n            .map_err(|err| anyhow!(\"unable to cast to WebGl2RenderingContext. error: {:?}\", err))?;\n        Ok(glow::Context::from_webgl2_context(webgl2_context))\n    }\n\n    fn webgl1_glow_context(canvas: &web_sys::HtmlCanvasElement) -> Result<glow::Context> {\n        let maybe_context: Option<_> = canvas\n            .get_context(\"webgl\")\n            .map_err(|err| anyhow!(\"error getting context for WebGL 1.0: {:?}\", err))?;\n        let js_webgl1_context =\n            maybe_context.ok_or(anyhow!(\"Browser doesn't support WebGL 1.0\"))?;\n        let webgl1_context = js_webgl1_context\n            .dyn_into::<web_sys::WebGlRenderingContext>()\n            .map_err(|err| anyhow!(\"unable to cast to WebGlRenderingContext. error: {:?}\", err))?;\n        Ok(glow::Context::from_webgl1_context(webgl1_context))\n    }\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/widgetry/src/backend_glow_wasm.rs#L69-L105","documentation":"After get_context(\"webgl2\") succeeds but returns None (no JS exception), the code concludes the browser does not support WebGL 2 and raises this error via ok_or. It means the environment cannot provide a WebGL 2 context, which this renderer path requires for features like tex_storage_3d.","triggerScenarios":"setup() runs webgl2_glow_context on a browser whose canvas.get_context(\"webgl2\") returns null — browsers without WebGL 2 (older Safari, some mobile browsers) or with WebGL 2 disabled.","commonSituations":"Legacy browsers or iOS Safari before WebGL 2 support; WebGL hardware-acceleration disabled; remote-desktop/headless browsers with software GL lacking webgl2; ANGLE/driver blocks.","solutions":["Use a browser with WebGL 2 support (modern Chrome, Firefox, Edge, Safari 15+).","Enable hardware acceleration / WebGL in browser settings.","Fall back to the WebGL 1 path (webgl1_glow_context) if the app supports GL1-compatible rendering.","Note that upload_gl2 requires WebGL 2, so a GL1 fallback may also restrict texture array features."],"exampleFix":"// before\nlet js_webgl2_context =\n    maybe_context.ok_or(anyhow!(\"Browser doesn't support WebGL 2.0\"))?;\n// after: caller falls back to WebGL 1\nlet glow_ctx = match webgl2_glow_context(canvas) {\n    Ok(c) => c,\n    Err(_) => webgl1_glow_context(canvas)?,\n};","handlingStrategy":"fallback","validationCode":"// Check WebGL 2 support in JS before loading the wasm renderer\nif (!document.createElement('canvas').getContext('webgl2')) {\n  showUpgradeBrowserBanner();\n}","typeGuard":null,"tryCatchPattern":"// Fall back to WebGL 1 when WebGL 2 is unsupported\nmatch webgl2_glow_context(canvas) {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"doesn't support WebGL 2.0\") => webgl1_glow_context(canvas)?,\n    Err(e) => return Err(e),\n}","preventionTips":["Publish minimum browser requirements and detect support before setup","Maintain a WebGL 1 fallback path and test it regularly","Enable hardware acceleration checks in user diagnostics","Gate GL2-only features (tex_storage_3d, texture arrays) on context version"],"tags":["webgl","wasm","browser-compatibility","rendering"],"backgroundTag":"unsupported-platform","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}