{"record":{"id":"73915f2bf47cd699","repo":"zed-industries/zed","slug":"webgpu-initialization-failed-webgpu-error-fa","errorCode":null,"errorMessage":"WebGPU initialization failed: {webgpu_error:#}. Failed to prepare a replacement canvas for WebGL2: {error:#}","messagePattern":"WebGPU initialization failed: (.+?)\\. Failed to prepare a replacement canvas for WebGL2: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/platform.rs","lineNumber":221,"sourceCode":"\n    /// Returns a browser Fetch HTTP client with the given reported user agent.\n    pub fn fetch_http_client_with_user_agent(\n        &self,\n        user_agent: &str,\n    ) -> anyhow::Result<FetchHttpClient> {\n        FetchHttpClient::with_user_agent(self.dispatcher.clone(), user_agent)\n    }\n}\n\nasync fn initialize_graphics(\n    browser_window: &web_sys::Window,\n    preference: WebBackendPreference,\n) -> anyhow::Result<(\n    web_sys::HtmlCanvasElement,\n    WgpuContext,\n    wgpu::Surface<'static>,\n)> {\n    match preference {\n        WebBackendPreference::Auto => {\n            let webgpu_canvas = WebWindow::prepare_canvas(browser_window)?;\n            let webgpu_result = if wgpu::util::is_browser_webgpu_supported().await {\n                WgpuContext::new_web(&webgpu_canvas, WebBackendPreference::WebGpu).await\n            } else {\n                Err(anyhow::anyhow!(\n                    \"browser WebGPU probe did not return a usable adapter\"\n                ))\n            };\n            match webgpu_result {\n                Ok(PreparedWebGraphics { context, surface }) => {\n                    return Ok((webgpu_canvas, context, surface));\n                }\n                Err(webgpu_error) => {\n                    let canvas: &web_sys::Element = webgpu_canvas.as_ref();\n                    canvas.remove();\n                    log::warn!(\n                        \"WebGPU initialization failed; falling back to WebGL2: {webgpu_error:#}\"","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_web/src/platform.rs#L203-L239","documentation":"Combined failure in initialize_graphics (Auto preference): WebGPU initialization already failed with {webgpu_error}, and the recovery step — preparing a fresh canvas for the WebGL2 fallback — then also failed with {error}. The message chains both errors so the WebGPU cause is not lost in the fallback.","triggerScenarios":"Thrown at crates/gpui_web/src/platform.rs:221 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Investigate the WebGL2 canvas-prep error (DOM/canvas creation) — it is the proximate failure","Keep both errors chained in user-facing reports so the WebGPU root cause stays visible","Guard against hostile/embedded DOM environments where canvas injection fails (CSP, missing body)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}