{"record":{"id":"371c8db762975e48","repo":"zed-industries/zed","slug":"missing-document","errorCode":null,"errorMessage":"Missing document","messagePattern":"Missing document","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/viewport.rs","lineNumber":51,"sourceCode":"    }\n\n    pub(crate) fn observe_safe_area(&self, observer: &web_sys::ResizeObserver) {\n        // Separate boxes detect redistribution between edges even when the\n        // total inset, and therefore a single combined probe's size, is unchanged.\n        for probe in &self.safe_area_probes {\n            observer.observe(probe);\n        }\n    }\n\n    pub(crate) fn update(\n        &mut self,\n        window: &web_sys::Window,\n        canvas: &web_sys::HtmlCanvasElement,\n    ) -> anyhow::Result<bool> {\n        let canvas_bounds = canvas.get_bounding_client_rect();\n        let document = window\n            .document()\n            .ok_or_else(|| anyhow::anyhow!(\"Missing document\"))?;\n        let root = document\n            .document_element()\n            .ok_or_else(|| anyhow::anyhow!(\"Missing root\"))?;\n        let layout_width = root.client_width() as f64;\n        let layout_height = root.client_height() as f64;\n        let (left, top, width, height) = match window.visual_viewport() {\n            Some(viewport) => (\n                viewport.offset_left(),\n                viewport.offset_top(),\n                viewport.width(),\n                viewport.height(),\n            ),\n            None => (0., 0., layout_width, layout_height),\n        };\n        // VisualViewport offsets and getBoundingClientRect share layout CSS\n        // coordinates. Multiplying by the pinch scale here would incorrectly\n        // expand the visible rectangle back to its unzoomed size.\n        let x = (left - canvas_bounds.left()).clamp(0., canvas_bounds.width());","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_web/src/viewport.rs#L33-L69","documentation":"A sentinel guard in WebViewport::update: window.document() returned None while recomputing canvas bounds and safe-area insets for the frame. Per web-sys this only happens for non-HTML or transitional documents, so during a normal session it indicates the window/document is being torn down or is in an invalid state mid-update. The update aborts and the old cached bounds are kept.","triggerScenarios":"Thrown at crates/gpui_web/src/viewport.rs:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as a transient teardown signal: skip this frame's viewport update and keep the previous bounds","Ensure update() is not invoked after the window is closed or during document unload","If persistent, inspect the hosting document type; webviews serving XHTML or non-HTML content can trigger this"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}