zed-industries/zed · error

Failed to create safe-area probe: {error:?}

Error message

Failed to create safe-area probe: {error:?}

What it means

A DOM sentinel error in the safe_area_probe helper: document.create_element("div") returned an Err (wrapped with the offending JsValue) while creating one of the four edge probes used to observe safe-area insets. createElement essentially never fails for 'div' in a healthy document, so this indicates a broken document context (e.g. an XML/SVG document or a destroyed window) rather than a problem with the probe configuration itself.

Source

Thrown at crates/gpui_web/src/viewport.rs:113

        Ok(changed)
    }
}

impl Drop for WebViewport {
    fn drop(&mut self) {
        for probe in &self.safe_area_probes {
            probe.remove();
        }
    }
}

fn safe_area_probe(
    document: &web_sys::Document,
    edge: &str,
) -> anyhow::Result<web_sys::HtmlElement> {
    let probe = document
        .create_element("div")
        .map_err(|error| anyhow::anyhow!("Failed to create safe-area probe: {error:?}"))?
        .dyn_into::<web_sys::HtmlElement>()
        .map_err(|error| anyhow::anyhow!("Invalid safe-area probe element: {error:?}"))?;
    probe
        .set_attribute(
            "style",
            &format!(
                "position:fixed;left:0;top:0;width:0;padding:0;border:0;visibility:hidden;\
                 pointer-events:none;height:env(safe-area-inset-{edge},0px)"
            ),
        )
        .map_err(|error| anyhow::anyhow!("Failed to style safe-area probe: {error:?}"))?;
    Ok(probe)
}

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Ensure viewport construction runs on a fully loaded HTML document (wait for DOMContentLoaded)
  2. Inspect the {error:?} JsValue (usually NotSupportedError) to confirm the document supports HTML element creation
  3. Defer or disable safe-area probing in hosting contexts that provide non-HTML documents
Defensive patterns

Strategy: fallback

When it happens

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

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12). Data as JSON: /api/errors/55d593a2f2527aef. Report an issue: GitHub.