Move stylo thread pool mutex to servo layout thread crates (#34480)

* Eliminate stylo thread pool mutex

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Reinstate Mutex in the Servo codebase

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Revert back to main Stylo branch

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
Nico Burns 2024-12-05 17:10:27 +13:00 committed by GitHub
parent e4ec84fad1
commit 97f486ad26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 15 deletions

View file

@ -68,7 +68,7 @@ use style::context::{
use style::dom::{OpaqueNode, TElement, TNode};
use style::error_reporting::RustLogReporter;
use style::font_metrics::FontMetrics;
use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
use style::global_style_data::GLOBAL_STYLE_DATA;
use style::invalidation::element::restyle_hints::RestyleHint;
use style::media_queries::{Device, MediaList, MediaType};
use style::properties::style_structs::Font;
@ -94,6 +94,14 @@ use webrender_api::units::{DevicePixel, LayoutPixel};
use webrender_api::{units, ExternalScrollId, HitTestFlags};
use webrender_traits::CrossProcessCompositorApi;
// This mutex is necessary due to syncronisation issues between two different types of thread-local storage
// which manifest themselves when the layout thread tries to layout iframes in parallel with the main page
//
// See: https://github.com/servo/servo/pull/29792
// And: https://gist.github.com/mukilan/ed57eb61b83237a05fbf6360ec5e33b0
static STYLE_THREAD_POOL: Mutex<&style::global_style_data::STYLE_THREAD_POOL> =
Mutex::new(&style::global_style_data::STYLE_THREAD_POOL);
/// Information needed by layout.
pub struct LayoutThread {
/// The ID of the pipeline that we belong to.
@ -796,7 +804,7 @@ impl LayoutThread {
self.stylist.flush(&guards, Some(root_element), Some(&map));
let rayon_pool = STYLE_THREAD_POOL.lock().unwrap();
let rayon_pool = STYLE_THREAD_POOL.lock();
let rayon_pool = rayon_pool.pool();
let rayon_pool = rayon_pool.as_ref();