From 64259de1f7ee9571fcc3405318303652c45f37a6 Mon Sep 17 00:00:00 2001 From: Narfinger Date: Wed, 25 Jun 2025 17:13:54 +0200 Subject: [PATCH] script: Do not run garbage collection when shutting down a Pipeline (#37691) Removes a GC cleanup step on exit pipeline that took half a second at the end of the Speedmometer benchmark. As layout and script are now run serially this does not seem to be needed anymore. See also the very short discussion on Zulip: [#performance > GC in handle_exit_pipeline](https://servo.zulipchat.com/#narrow/channel/416779-performance/topic/GC.20in.20handle_exit_pipeline/with/525697861). Testing: Tested with Speedometer and the WPT tests should still work. Signed-off-by: Narfinger --- components/script/dom/window.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 89c15e73692..01135822984 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -2007,20 +2007,6 @@ impl Window { custom_elements.teardown(); } - // The above code may not catch all DOM objects (e.g. DOM - // objects removed from the tree that haven't been collected - // yet). There should not be any such DOM nodes with layout - // data, but if there are, then when they are dropped, they - // will attempt to send a message to layout. - // This causes memory safety issues, because the DOM node uses - // the layout channel from its window, and the window has - // already been GC'd. For nodes which do not have a live - // pointer, we can avoid this by GCing now: - self.Gc(); - // but there may still be nodes being kept alive by user - // script. - // TODO: ensure that this doesn't happen! - self.current_state.set(WindowState::Zombie); *self.js_runtime.borrow_mut() = None;