{"record":{"id":"2c9b4898bcdfc346","repo":"slint-ui/slint","slug":"wasm-interpreter-could-not-retrieve-existing-html","errorCode":null,"errorMessage":"wasm-interpreter: Could not retrieve existing HTML Canvas element '{}'","messagePattern":"wasm-interpreter: Could not retrieve existing HTML Canvas element '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/wasm-interpreter/src/lib.rs","lineNumber":354,"sourceCode":"pub 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))\n                        // Don't activate the window by default, as that will cause the page to scroll,\n                        // ignoring any existing anchors.\n                        .with_active(false);\n                    attrs\n                } else {","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/api/wasm-interpreter/src/lib.rs#L336-L372","documentation":"Error \"wasm-interpreter: Could not retrieve existing HTML Canvas element '{}'\" thrown in slint-ui/slint.","triggerScenarios":"Thrown at api/wasm-interpreter/src/lib.rs:354 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create a <canvas> element in the HTML page and pass its id to the Slint wasm initialization.","Check the canvas id for typos."],"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-14T05:17:10.506Z"}