{"record":{"id":"e9317c575a64f43d","repo":"gfx-rs/wgpu","slug":"canvas-is-not-found","errorCode":null,"errorMessage":"Canvas is not found","messagePattern":"Canvas is not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-hal/src/gles/web.rs","lineNumber":157,"sourceCode":"            .into_iter()\n            .collect()\n        } else {\n            Vec::new()\n        }\n    }\n\n    unsafe fn create_surface(\n        &self,\n        _display_handle: raw_window_handle::RawDisplayHandle,\n        window_handle: raw_window_handle::RawWindowHandle,\n    ) -> Result<Surface, crate::InstanceError> {\n        let canvas: web_sys::HtmlCanvasElement = match window_handle {\n            raw_window_handle::RawWindowHandle::Web(handle) => web_sys::window()\n                .and_then(|win| win.document())\n                .expect(\"Cannot get document\")\n                .query_selector(&format!(\"canvas[data-raw-handle=\\\"{}\\\"]\", handle.id))\n                .expect(\"Cannot query for canvas\")\n                .expect(\"Canvas is not found\")\n                .dyn_into()\n                .expect(\"Failed to downcast to canvas type\"),\n            raw_window_handle::RawWindowHandle::WebCanvas(handle) => {\n                let value: &JsValue = unsafe { handle.obj.cast().as_ref() };\n                value.clone().unchecked_into()\n            }\n            raw_window_handle::RawWindowHandle::WebOffscreenCanvas(handle) => {\n                let value: &JsValue = unsafe { handle.obj.cast().as_ref() };\n                let canvas: web_sys::OffscreenCanvas = value.clone().unchecked_into();\n\n                return self.create_surface_from_offscreen_canvas(canvas);\n            }\n            _ => {\n                return Err(crate::InstanceError::new(format!(\n                    \"window handle {window_handle:?} is not a web handle\"\n                )))\n            }\n        };","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-hal/src/gles/web.rs#L139-L175","documentation":"Panic in the GLES/web create_surface: the element found for the raw handle was not an HtmlCanvasElement, so it cannot host a WebGL context. The faulty input is the element type associated with the window handle.","triggerScenarios":"Thrown at wgpu-hal/src/gles/web.rs:157 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a window handle whose data-raw-handle resolves to an actual <canvas> element","Use the canvas directly instead of a raw handle pointing at other DOM nodes"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}