{"record":{"id":"078a13d5c6fbaa5b","repo":"slint-ui/slint","slug":"cannot-proceed-without-webgl-aborting","errorCode":null,"errorMessage":"Cannot proceed without WebGL - aborting","messagePattern":"Cannot proceed without WebGL - aborting","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/renderers/femtovg/opengl.rs","lineNumber":147,"sourceCode":"        let gl_renderer = match femtovg::renderer::OpenGl::new_from_html_canvas(&html_canvas) {\n            Ok(gl_renderer) => gl_renderer,\n            Err(_) => {\n                use wasm_bindgen::JsCast;\n\n                // I don't believe that there's a way of disabling the 2D canvas.\n                let context_2d = html_canvas\n                    .get_context(\"2d\")\n                    .unwrap()\n                    .unwrap()\n                    .dyn_into::<web_sys::CanvasRenderingContext2d>()\n                    .unwrap();\n                context_2d.set_font(\"20px serif\");\n                // We don't know if we're rendering on dark or white background, so choose a \"color\" in the middle for the text.\n                context_2d.set_fill_style_str(\"red\");\n                context_2d\n                    .fill_text(\"Slint requires WebGL to be enabled in your browser\", 0., 30.)\n                    .unwrap();\n                panic!(\"Cannot proceed without WebGL - aborting\")\n            }\n        };\n\n        let femtovg_canvas = femtovg::Canvas::new_with_text_context(\n            gl_renderer,\n            crate::font_cache::FONT_CACHE.with(|cache| cache.borrow().text_context.clone()),\n        )\n        .unwrap();\n\n        *self.opengl_context.borrow_mut() = opengl_context;\n        #[cfg(target_family = \"wasm\")]\n        {\n            *self.html_canvas.borrow_mut() = Some(html_canvas);\n        }\n\n        let canvas = Rc::new(RefCell::new(femtovg_canvas));\n        renderer.reset_canvas(canvas);\n        Ok(())","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/renderers/femtovg/opengl.rs#L129-L165","documentation":"The FemtoVG renderer's WebGL backend panics when the browser cannot provide a WebGL context, which means Slint cannot render at all in the WASM target. Before panicking it draws the message 'Slint requires WebGL to be enabled in your browser' onto a 2D canvas so end users see the reason.","triggerScenarios":"Running a Slint WASM app in a browser/context where canvas.getContext('webgl') returns null: WebGL disabled or blocked (e.g. hardware acceleration off, headless browser, unsupported GPU/driver), or the canvas already has a different context type.","commonSituations":"Firefox/Chrome with webgl.disabled=true; corporate VMs or RDP sessions without GPU; headless CI browsers without SwiftShader; embedding Slint's canvas in a page that already requested a '2d' context on the same canvas.","solutions":["Enable hardware acceleration / WebGL in the browser (chrome://gpu, about:config webgl.disabled=false)","Use a WebGL-capable environment (non-headless browser or headless with --use-gl=swiftshader)","Ensure the canvas is not already bound to a '2d' context before Slint initializes"],"exampleFix":"// before (headless CI)\nchromium --headless app.html\n// after\nchromium --headless --use-gl=swiftshader --enable-unsafe-swiftshader app.html","handlingStrategy":"fallback","validationCode":"const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');\nif (!gl) { showWebglRequiredBanner(); return; }","typeGuard":"function hasWebGL(): boolean {\n  try { const c = document.createElement('canvas');\n    return !!(c.getContext('webgl') || c.getContext('experimental-webgl'));\n  } catch { return false; }\n}","tryCatchPattern":"// Slint panics (WASM trap); pre-check before initializing\nif (!hasWebGL()) { renderStaticFallback(); } else { await initSlint(); }","preventionTips":["Feature-detect WebGL before booting the app and show a graceful banner","Enable hardware acceleration / SwiftShader in headless CI browsers","Never acquire a '2d' context on the same canvas Slint will use"],"tags":["wasm","webgl","browser","femtovg","panic"],"backgroundTag":"feature-not-enabled","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}