mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
constellation: Use one image cache thread pool in the single-process mode (#38783)
Previously, each ScriptThread was creating a new image cache with a separate thread pool. These changes add an image cache to the constellation and create new image caches by calling the `create_new_image_cache` method. It reuses the original image cache's thread pool and reduces the number of spawned threads in the single-process mode. Testing: Tested manually, using `ps -M` to see the number of spawned threads with multiple tabs open in servoshell before and after these changes. Fixes: #37770 Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
This commit is contained in:
parent
23ac24438a
commit
4aabc67e57
3 changed files with 30 additions and 7 deletions
|
@ -147,6 +147,8 @@ use keyboard_types::{Key, KeyState, Modifiers, NamedKey};
|
|||
use layout_api::{LayoutFactory, ScriptThreadFactory};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use media::WindowGLContext;
|
||||
use net::image_cache::ImageCacheImpl;
|
||||
use net_traits::image_cache::ImageCache;
|
||||
use net_traits::pub_domains::reg_host;
|
||||
use net_traits::request::Referrer;
|
||||
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
|
||||
|
@ -486,6 +488,9 @@ pub struct Constellation<STF, SWF> {
|
|||
|
||||
/// A list of URLs that can access privileged internal APIs.
|
||||
privileged_urls: Vec<ServoUrl>,
|
||||
|
||||
/// The image cache for the single-process mode
|
||||
image_cache: Box<dyn ImageCache>,
|
||||
}
|
||||
|
||||
/// State needed to construct a constellation.
|
||||
|
@ -684,7 +689,7 @@ where
|
|||
compositor_receiver,
|
||||
layout_factory,
|
||||
embedder_proxy: state.embedder_proxy,
|
||||
compositor_proxy: state.compositor_proxy,
|
||||
compositor_proxy: state.compositor_proxy.clone(),
|
||||
webviews: WebViewManager::default(),
|
||||
devtools_sender: state.devtools_sender,
|
||||
#[cfg(feature = "bluetooth")]
|
||||
|
@ -731,12 +736,16 @@ where
|
|||
active_keyboard_modifiers: Modifiers::empty(),
|
||||
hard_fail,
|
||||
active_media_session: None,
|
||||
rippy_data,
|
||||
rippy_data: rippy_data.clone(),
|
||||
user_content_manager: state.user_content_manager,
|
||||
process_manager: ProcessManager::new(state.mem_profiler_chan),
|
||||
async_runtime: state.async_runtime,
|
||||
script_join_handles: Default::default(),
|
||||
privileged_urls: state.privileged_urls,
|
||||
image_cache: Box::new(ImageCacheImpl::new(
|
||||
state.compositor_proxy.cross_process_compositor_api,
|
||||
rippy_data,
|
||||
)),
|
||||
};
|
||||
|
||||
constellation.run();
|
||||
|
@ -1014,6 +1023,10 @@ where
|
|||
rippy_data: self.rippy_data.clone(),
|
||||
user_content_manager: self.user_content_manager.clone(),
|
||||
privileged_urls: self.privileged_urls.clone(),
|
||||
image_cache: self.image_cache.create_new_image_cache(
|
||||
Some(pipeline_id),
|
||||
self.compositor_proxy.cross_process_compositor_api.clone(),
|
||||
),
|
||||
});
|
||||
|
||||
let pipeline = match result {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue