layout: Shut down style thread-pool when exiting a content process / shutting down the Constellation (#38924)

To ensure a clean-shutdown of Servo, we need to shutdown our internal
threading before deinit. This shuts down the style thread pool either
using the constellation(in single-process mode), or when a content
process exits.

Testing: Manual testing by opening a window, opening and closing
multiple tabs, and closing the window, with a sleep added before deinit
and a sample taken to ensure the loose threads previously noticed are
gone.
Fixes: part of https://github.com/servo/servo/issues/30849

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
Gregory Terzian 2025-08-26 21:10:03 +08:00 committed by GitHub
parent 7339e2b421
commit 08b9eb818c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 0 deletions

View file

@ -55,6 +55,7 @@ servo_config = { path = "../config" }
servo_rand = { path = "../rand" }
servo_url = { path = "../url" }
stylo_traits = { workspace = true }
stylo = { workspace = true }
tracing = { workspace = true, optional = true }
webgpu = { path = "../webgpu" }
webgpu_traits = { workspace = true }

View file

@ -165,6 +165,7 @@ use servo_config::prefs::{self, PrefValue};
use servo_config::{opts, pref};
use servo_rand::{Rng, ServoRng, SliceRandom, random};
use servo_url::{Host, ImmutableOrigin, ServoUrl};
use style::global_style_data::StyleThreadPool;
#[cfg(feature = "webgpu")]
use webgpu::swapchain::WGPUImageMap;
#[cfg(feature = "webgpu")]
@ -755,6 +756,10 @@ where
}
self.handle_shutdown();
if !opts::get().multiprocess {
StyleThreadPool::shutdown();
}
// Shut down the fetch thread started above.
exit_fetch_thread();
join_handle