From 909ceee830dd59f2b47c820b22ab9791ed6f8adf Mon Sep 17 00:00:00 2001 From: Gregory Terzian <2792687+gterzian@users.noreply.github.com> Date: Tue, 26 Aug 2025 23:22:11 +0800 Subject: [PATCH] constellation: send EmbedderMsg::ShutdownComplete as last (#38923) To help ensure our internal threads have shut-down before we deinit Servo, the last thing the constellation should do, is sending the `EmbedderMsg::ShutdownComplete`. Testing: Manual testing by starting Servo and then closing the window. Fixes: Part of https://github.com/servo/servo/issues/30849 --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com> Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com> Co-authored-by: Martin Robinson --- components/constellation/constellation.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index cec20412a29..0b5358805dd 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -768,6 +768,12 @@ where join_handle .join() .expect("Failed to join on the fetch thread in the constellation"); + + // Note: the last thing the constellation does, is asking the embedder to + // shut down. This helps ensure we've shut down all our internal threads before + // de-initializing Servo (see the `thread_count` warning on MacOS). + debug!("Asking embedding layer to complete shutdown."); + self.embedder_proxy.send(EmbedderMsg::ShutdownComplete); } /// Generate a new pipeline id namespace. @@ -2719,9 +2725,6 @@ where } } - debug!("Asking embedding layer to complete shutdown."); - self.embedder_proxy.send(EmbedderMsg::ShutdownComplete); - debug!("Shutting-down IPC router thread in constellation."); ROUTER.shutdown();