slint-ui/slint · error
winit backend: Specified DOM element '{}' is not a HTML Canv
Error message
winit backend: Specified DOM element '{}' is not a HTML Canvas What it means
Error "winit backend: Specified DOM element '{}' is not a HTML Canvas" thrown in slint-ui/slint.
Source
Thrown at api/wasm-interpreter/src/lib.rs:361
if let Some(canvas_id) = next_id.borrow_mut().take() {
use i_slint_backend_winit::winit::platform::web::WindowAttributesExtWebSys;
use wasm_bindgen::JsCast;
let html_canvas = web_sys::window()
.expect("wasm-interpreter: Could not retrieve DOM window")
.document()
.expect("wasm-interpreter: Could not retrieve DOM document")
.get_element_by_id(&canvas_id)
.unwrap_or_else(|| {
panic!(
"wasm-interpreter: Could not retrieve existing HTML Canvas element '{}'",
canvas_id
)
})
.dyn_into::<web_sys::HtmlCanvasElement>()
.unwrap_or_else(|_| {
panic!(
"winit backend: Specified DOM element '{}' is not a HTML Canvas",
canvas_id
)
});
attrs = attrs
.with_canvas(Some(html_canvas))
// Don't activate the window by default, as that will cause the page to scroll,
// ignoring any existing anchors.
.with_active(false);
attrs
} else {
attrs
}
})
})
.build()
.unwrap();
i_slint_core::platform::set_platform(Box::new(backend))View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Pass the id of a <canvas> element, not a generic <div> or other DOM element.
- Replace the referenced element with a real HTMLCanvasElement.
When it happens
Trigger: Thrown at api/wasm-interpreter/src/lib.rs:361 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/7baa8951d1a761d2.
Report an issue: GitHub.