zed-industries/zed · error
Failed to set canvas {property} style: {error:?}
Error message
Failed to set canvas {property} style: {error:?} What it means
Guard in WebWindow::prepare_canvas: CSSStyleDeclaration.setProperty threw while applying the fullscreen sizing styles (width/height/display/outline/touch-action) to the canvas — {property} names the style that failed, {error:?} the JS exception.
Source
Thrown at crates/gpui_web/src/window.rs:132
.create_element("canvas")
.map_err(|error| anyhow::anyhow!("Failed to create canvas element: {error:?}"))?
.dyn_into()
.map_err(|error| anyhow::anyhow!("Created element is not a canvas: {error:?}"))?;
canvas.set_tab_index(-1);
let style = canvas.style();
for (property, value) in [
("width", "100%"),
("height", "100%"),
("display", "block"),
("outline", "none"),
("touch-action", "none"),
("-webkit-touch-callout", "none"),
("user-select", "none"),
("-webkit-user-select", "none"),
] {
style.set_property(property, value).map_err(|error| {
anyhow::anyhow!("Failed to set canvas {property} style: {error:?}")
})?;
}
let body = document
.body()
.ok_or_else(|| anyhow::anyhow!("No `body` found on document"))?;
body.append_child(&canvas)
.map_err(|error| anyhow::anyhow!("Failed to append canvas to body: {error:?}"))?;
Ok(canvas)
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
_handle: AnyWindowHandle,
_params: WindowParams,
context: &WgpuContext,
canvas: web_sys::HtmlCanvasElement,
surface: wgpu::Surface<'static>,View on GitHub (pinned to 9d272b0363)
Solutions
- Log which property failed — usually a CSP style-src restriction or an unusual CSSOM
- Ensure the embedding page's CSP allows inline style manipulation
- Fall back to setting style attributes directly (setAttribute) if setProperty is blocked
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/gpui_web/src/window.rs:99 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/2a77b1eb8efc186e.
Report an issue: GitHub.