zed-industries/zed · error

WebGPU initialization failed: {webgpu_error:#}. Failed to pr

Error message

WebGPU initialization failed: {webgpu_error:#}. Failed to prepare a replacement canvas for WebGL2: {error:#}

What it means

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.

Source

Thrown at crates/gpui_web/src/platform.rs:221

    /// Returns a browser Fetch HTTP client with the given reported user agent.
    pub fn fetch_http_client_with_user_agent(
        &self,
        user_agent: &str,
    ) -> anyhow::Result<FetchHttpClient> {
        FetchHttpClient::with_user_agent(self.dispatcher.clone(), user_agent)
    }
}

async fn initialize_graphics(
    browser_window: &web_sys::Window,
    preference: WebBackendPreference,
) -> anyhow::Result<(
    web_sys::HtmlCanvasElement,
    WgpuContext,
    wgpu::Surface<'static>,
)> {
    match preference {
        WebBackendPreference::Auto => {
            let webgpu_canvas = WebWindow::prepare_canvas(browser_window)?;
            let webgpu_result = if wgpu::util::is_browser_webgpu_supported().await {
                WgpuContext::new_web(&webgpu_canvas, WebBackendPreference::WebGpu).await
            } else {
                Err(anyhow::anyhow!(
                    "browser WebGPU probe did not return a usable adapter"
                ))
            };
            match webgpu_result {
                Ok(PreparedWebGraphics { context, surface }) => {
                    return Ok((webgpu_canvas, context, surface));
                }
                Err(webgpu_error) => {
                    let canvas: &web_sys::Element = webgpu_canvas.as_ref();
                    canvas.remove();
                    log::warn!(
                        "WebGPU initialization failed; falling back to WebGL2: {webgpu_error:#}"

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Investigate the WebGL2 canvas-prep error (DOM/canvas creation) — it is the proximate failure
  2. Keep both errors chained in user-facing reports so the WebGPU root cause stays visible
  3. Guard against hostile/embedded DOM environments where canvas injection fails (CSP, missing body)
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/gpui_web/src/platform.rs:221 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/73915f2bf47cd699. Report an issue: GitHub.