zed-industries/zed · error

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

Error message

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

What it means

Fires when HtmlElement::set_attribute("style", ...) rejects for the safe-area probe element (created successfully just before). set_attribute returns a Promise in the DOM and web_sys surfaces rejection as a JsValue; a malformed style string or a detached/invalid element are typical triggers. The probe measures env(safe-area-inset-<edge>) so losing it means inset defaults to 0.

Source

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

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. Check the generated style string for the failing edge; an unexpected edge value could produce an invalid CSS env() expression
  2. Catch the failure at the caller (new) and proceed with default (0px) safe-area insets while logging the JsValue error
  3. If it persists, set style properties via the CSSStyleDeclaration (element.style()) instead of set_attribute to isolate the invalid attribute
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/gpui_web/src/viewport.rs:124 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/506cee1e7358b9bd. Report an issue: GitHub.