aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread
diff options
context:
space:
mode:
authorPhilipp Albrecht <palbrecht@mailbox.org>2019-03-25 22:39:41 +0100
committerpylbrecht <palbrecht@mailbox.org>2019-04-13 07:42:07 +0200
commit858011c5132d647c0718a2801279222652004a3b (patch)
treedabb9c3c2f218e1f37728896493f9fd204f5f461 /components/layout_thread
parenta74f5222db7f7f39e426cd0b8836f5b806730ef7 (diff)
downloadservo-858011c5132d647c0718a2801279222652004a3b.tar.gz
servo-858011c5132d647c0718a2801279222652004a3b.zip
Measure layout queries blocked by ongoing layout
Diffstat (limited to 'components/layout_thread')
-rw-r--r--components/layout_thread/lib.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index db48aa483aa..4ab5c653ea8 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -96,7 +96,7 @@ use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use std::process;
-use std::sync::atomic::{AtomicUsize, Ordering};
+use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, MutexGuard};
use std::thread;
use std::time::Duration;
@@ -244,6 +244,9 @@ pub struct LayoutThread {
/// The sizes of all iframes encountered during the last layout operation.
last_iframe_sizes: RefCell<HashMap<BrowsingContextId, TypedSize2D<f32, CSSPixel>>>,
+
+ /// Flag that indicates if LayoutThread is busy handling a request.
+ busy: Arc<AtomicBool>,
}
impl LayoutThreadFactory for LayoutThread {
@@ -268,6 +271,7 @@ impl LayoutThreadFactory for LayoutThread {
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
paint_time_metrics: PaintTimeMetrics,
+ busy: Arc<AtomicBool>,
) {
thread::Builder::new()
.name(format!("LayoutThread {:?}", id))
@@ -305,6 +309,7 @@ impl LayoutThreadFactory for LayoutThread {
webrender_api_sender,
webrender_document,
paint_time_metrics,
+ busy,
);
let reporter_name = format!("layout-reporter-{}", id);
@@ -466,6 +471,7 @@ impl LayoutThread {
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
paint_time_metrics: PaintTimeMetrics,
+ busy: Arc<AtomicBool>,
) -> LayoutThread {
// The device pixel ratio is incorrect (it does not have the hidpi value),
// but it will be set correctly when the initial reflow takes place.
@@ -544,6 +550,7 @@ impl LayoutThread {
paint_time_metrics: paint_time_metrics,
layout_query_waiting_time: Histogram::new(),
last_iframe_sizes: Default::default(),
+ busy: busy,
}
}
@@ -648,7 +655,8 @@ impl LayoutThread {
recv(self.font_cache_receiver) -> msg => { msg.unwrap(); Request::FromFontCache }
};
- match request {
+ self.busy.store(true, Ordering::Relaxed);
+ let result = match request {
Request::FromPipeline(LayoutControlMsg::SetScrollStates(new_scroll_states)) => self
.handle_request_helper(
Msg::SetScrollStates(new_scroll_states),
@@ -679,7 +687,9 @@ impl LayoutThread {
.unwrap();
true
},
- }
+ };
+ self.busy.store(false, Ordering::Relaxed);
+ result
}
/// Receives and dispatches messages from other threads.
@@ -861,6 +871,7 @@ impl LayoutThread {
self.webrender_api.clone_sender(),
self.webrender_document,
info.paint_time_metrics,
+ self.busy.clone(),
);
}