zed-industries/zed · error

Created element is not a canvas: {error:?}

Error message

Created element is not a canvas: {error:?}

What it means

Guard in WebWindow::prepare_canvas: the element returned by createElement('canvas') failed dyn_into::<HtmlCanvasElement> — the created node is somehow not a canvas element, indicating DOM API tampering or an unusual embedding environment.

Source

Thrown at crates/gpui_web/src/window.rs:89

    /// The cycle is a keyboard-visibility hint, not a real activity change;
    /// letting the focus/blur listeners report it would re-enter GPUI
    /// synchronously from inside an input dispatch, and a `RefCell`
    /// double-borrow panic on wasm never unwinds, wedging the app.
    pub(crate) suppress_focus_status_events: Cell<bool>,
    /// The visual viewport height when the current pointer gesture began.
    /// A mid-gesture change means the software keyboard opened or closed and
    /// reflowed the layout, so the release position no longer refers to what
    /// the user aimed at.
    pub(crate) gesture_start_visual_viewport_height: Cell<f64>,
    /// A touch that may still resolve into a tap: its pointer id and starting
    /// position, cleared once it travels beyond touch slop. Virtual keyboard
    /// and IME focus may only change when a touch release completes a tap;
    /// pans must leave them untouched, or scrolling over editable content
    /// flickers the keyboard and drags the caret around.
    pub(crate) touch_tap_candidate: Cell<Option<(i32, Point<Pixels>)>>,
    mql_handle: RefCell<Option<MqlHandle>>,
    pending_physical_size: Cell<Option<(u32, u32)>>,
    raf_id: Cell<Option<i32>>,
    raf_function: RefCell<Option<js_sys::Function>>,
}

pub struct WebWindow {
    inner: Rc<WebWindowInner>,
    display: Rc<dyn PlatformDisplay>,
    lifecycle: Rc<Cell<WebWindowLifecycle>>,
    active_window: Rc<RefCell<Option<AnyWindowHandle>>>,
    _raf_closure: Closure<dyn FnMut()>,
    _resize_observer: Option<web_sys::ResizeObserver>,
    _resize_observer_closure: Closure<dyn FnMut(js_sys::Array)>,
    _safe_area_observer: Option<web_sys::ResizeObserver>,
    _safe_area_observer_closure: Closure<dyn FnMut(js_sys::Array)>,
    _event_listeners: WebEventListeners,
}

impl WebWindow {
    pub(crate) fn prepare_canvas(

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Log the element's tagName and constructor to identify what the environment actually returned
  2. Guard against scripts/libraries that monkey-patch document.createElement
  3. Treat as an unsupported environment and abort canvas preparation with the cast error
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/gpui_web/src/window.rs:87 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/af8c2a7f40bf0020. Report an issue: GitHub.