From d48d6a745409a8998998ed59c28493a1aa733ebb Mon Sep 17 00:00:00 2001 From: localcc Date: Wed, 17 Sep 2025 11:26:53 +0200 Subject: [PATCH] Fix empty nodes crash (#38259) The crash occured because we raced against the platform windowing backend to render a frame, and if we lost the race there would be no frame on a window that we return, which breaks most of gpui Release Notes: - N/A --- crates/gpui/src/app.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 8b0b404d1dffbf8a27de1f29437ce9cc2ba63f0f..e6c3e3b8deea9b82514b5ac932c4f204fa081e14 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)