mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Layout-2020: Serialize access to stylo thread pool.
When rendering a page containing an iframe, layout 2020 creates parallel 'Layout' threads which share workers in the stylo thread pool. Because of the way the 'StyleSharingCache' is designed using TLS for storage of the LRU cache, this leads to a double borrow of the cache when both layout threads run concurrently. More details about the issue can be found here: https://gist.github.com/mukilan/ed57eb61b83237a05fbf6360ec5e33b0 This PR is a workaround until we find a more elegant/optimal design that also can work for gecko. The fix for now is simply to not allow multiple layouts in parallel. Signed-off-by: Mukilan Thiyagarajan <me@mukilan.in>
This commit is contained in:
parent
43ebf6c82c
commit
05239f879e
3 changed files with 17 additions and 19 deletions
|
@ -517,6 +517,7 @@ impl LayoutThread {
|
|||
animation_timeline_value: f64,
|
||||
animations: &DocumentAnimationSet,
|
||||
stylesheets_changed: bool,
|
||||
use_rayon: bool,
|
||||
) -> LayoutContext<'a> {
|
||||
let traversal_flags = match stylesheets_changed {
|
||||
true => TraversalFlags::ForCSSRuleChanges,
|
||||
|
@ -541,7 +542,7 @@ impl LayoutThread {
|
|||
font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
|
||||
webrender_image_cache: self.webrender_image_cache.clone(),
|
||||
pending_images: Mutex::new(vec![]),
|
||||
use_rayon: STYLE_THREAD_POOL.pool().is_some(),
|
||||
use_rayon,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -989,6 +990,10 @@ impl LayoutThread {
|
|||
|
||||
self.stylist.flush(&guards, Some(root_element), Some(&map));
|
||||
|
||||
let rayon_pool = STYLE_THREAD_POOL.lock().unwrap();
|
||||
let rayon_pool = rayon_pool.pool();
|
||||
let rayon_pool = rayon_pool.as_ref();
|
||||
|
||||
// Create a layout context for use throughout the following passes.
|
||||
let mut layout_context = self.build_layout_context(
|
||||
guards.clone(),
|
||||
|
@ -997,6 +1002,7 @@ impl LayoutThread {
|
|||
data.animation_timeline_value,
|
||||
&data.animations,
|
||||
data.stylesheets_changed,
|
||||
rayon_pool.is_some(),
|
||||
);
|
||||
|
||||
let dirty_root = unsafe {
|
||||
|
@ -1012,9 +1018,6 @@ impl LayoutThread {
|
|||
RecalcStyle::pre_traverse(dirty_root, shared)
|
||||
};
|
||||
|
||||
let rayon_pool = STYLE_THREAD_POOL.pool();
|
||||
let rayon_pool = rayon_pool.as_ref();
|
||||
|
||||
if token.should_traverse() {
|
||||
let dirty_root: ServoLayoutNode<DOMLayoutData> =
|
||||
driver::traverse_dom(&traversal, token, rayon_pool).as_node();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue