net: clean shutdown of fetch thread (#38421)

The fetch thread is currently not shut down, meaning it is one of the
threads counted in the "threads are still running after shutdown (bad)"
counter shown when Servo has shut-down.

This PR introduces a mechanism to start, and shut-down, one fetch thread
per process that requires one.

Testing: WPT tests and unit tests(for font context). Also manually
tested loading and closing "about:blank": this change indeed brings down
the count of threads still running after shutdown by one.

Fixes: https://github.com/servo/servo/issues/34887

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
Gregory Terzian 2025-08-07 17:01:30 +08:00 committed by GitHub
parent ad805e3110
commit b23cf9c6cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 71 additions and 11 deletions

View file

@ -35,8 +35,8 @@ use layout_api::{LayoutFactory, ScriptThreadFactory};
use log::{debug, error, warn};
use media::WindowGLContext;
use net::image_cache::ImageCacheImpl;
use net_traits::ResourceThreads;
use net_traits::image_cache::ImageCache;
use net_traits::{CoreResourceThread, ResourceThreads};
use profile::system_reporter;
use profile_traits::mem::{ProfilerMsg, Reporter};
use profile_traits::{mem as profile_mem, time};
@ -575,6 +575,10 @@ impl UnprivilegedPipelineContent {
&self.script_to_constellation_chan
}
pub fn core_resource_thread(&self) -> &CoreResourceThread {
&self.resource_threads.core_thread
}
pub fn opts(&self) -> Opts {
self.opts.clone()
}