Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix empty nodes crash (#38259)

localccd48d6a745409
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs
index 8b0b404d1df..e6c3e3b8dee 100644
--- a/crates/gpui/src/app.rs
+++ b/crates/gpui/src/app.rs
@@ -958,6 +958,14 @@ impl App {
cx.window_update_stack.pop();
window.root.replace(root_view.into());
window.defer(cx, |window: &mut Window, cx| window.appearance_changed(cx));
+
+ // allow a window to draw at least once before returning
+ // this didn't cause any issues on non windows platforms as it seems we always won the race to on_request_frame
+ // on windows we quite frequently lose the race and return a window that has never rendered, which leads to a crash
+ // where DispatchTree::root_node_id asserts on empty nodes
+ let clear = window.draw(cx);
+ clear.clear();
+
cx.window_handles.insert(id, window.handle);
cx.windows.get_mut(id).unwrap().replace(window);
Ok(handle)