{"record":{"id":"9b3bed8f12ead1eb","repo":"slint-ui/slint","slug":"wasm-interpreter-could-not-retrieve-dom-window","errorCode":null,"errorMessage":"wasm-interpreter: Could not retrieve DOM window","messagePattern":"wasm-interpreter: Could not retrieve DOM window","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/wasm-interpreter/src/lib.rs","lineNumber":349,"sourceCode":"thread_local!(\n    static NEXT_CANVAS_ID: Rc<RefCell<Option<String>>> = Default::default();\n);\n\n#[wasm_bindgen(start)]\npub fn init() -> Result<(), JsValue> {\n    #[cfg(feature = \"console_error_panic_hook\")]\n    console_error_panic_hook::set_once();\n    let backend = i_slint_backend_winit::Backend::builder()\n        .with_spawn_event_loop(true)\n        .with_window_attributes_hook(|mut attrs| {\n            NEXT_CANVAS_ID.with(|next_id| {\n                if let Some(canvas_id) = next_id.borrow_mut().take() {\n                    use i_slint_backend_winit::winit::platform::web::WindowAttributesExtWebSys;\n\n                    use wasm_bindgen::JsCast;\n\n                    let html_canvas = web_sys::window()\n                        .expect(\"wasm-interpreter: Could not retrieve DOM window\")\n                        .document()\n                        .expect(\"wasm-interpreter: Could not retrieve DOM document\")\n                        .get_element_by_id(&canvas_id)\n                        .unwrap_or_else(|| {\n                            panic!(\n                                \"wasm-interpreter: Could not retrieve existing HTML Canvas element '{}'\",\n                                canvas_id\n                            )\n                        })\n                        .dyn_into::<web_sys::HtmlCanvasElement>()\n                        .unwrap_or_else(|_| {\n                            panic!(\n                                \"winit backend: Specified DOM element '{}' is not a HTML Canvas\",\n                                canvas_id\n                            )\n                        });\n                    attrs = attrs\n                        .with_canvas(Some(html_canvas))","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/api/wasm-interpreter/src/lib.rs#L331-L367","documentation":"Error \"wasm-interpreter: Could not retrieve DOM window\" thrown in slint-ui/slint.","triggerScenarios":"Thrown at api/wasm-interpreter/src/lib.rs:349 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the wasm module in a real browser environment with a DOM window.","Do not execute the wasm interpreter in a non-DOM JS runtime."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}