added pipelines to all task sources

changed task sources to accept pipeline ids
This commit is contained in:
ddh 2017-10-24 02:45:55 +01:00
parent 2ffbe53989
commit 52b63def44
20 changed files with 194 additions and 230 deletions

2
Cargo.lock generated
View file

@ -1819,7 +1819,6 @@ dependencies = [
"gfx 0.0.1",
"gfx_traits 0.0.1",
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.0.1",
@ -2420,7 +2419,6 @@ version = "0.0.1"
dependencies = [
"energy-monitor 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"energymon 0.3.0 (git+https://github.com/energymon/energymon-rust.git)",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -17,7 +17,6 @@ log = "0.3.5"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
msg = {path = "../msg"}
lazy_static = "0.2"
profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}

View file

@ -1,14 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(custom_attribute)]
extern crate gfx;
extern crate gfx_traits;
extern crate ipc_channel;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate malloc_size_of;
#[macro_use]
@ -25,12 +22,11 @@ use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use profile_traits::time::{ProfilerChan, ProfilerCategory, send_profile_data};
use profile_traits::time::TimerMetadata;
use script_traits::{ConstellationControlMsg, LayoutMsg, PWMType};
use script_traits::{ConstellationControlMsg, LayoutMsg, ProgressiveWebMetricType};
use servo_config::opts;
use std::cell::{Cell, RefCell};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::time::{Instant, Duration};
use time::precise_time_ns;
pub trait ProfilerMetadataFactory {
@ -41,25 +37,23 @@ pub trait ProgressiveWebMetric {
fn get_navigation_start(&self) -> Option<f64>;
fn set_navigation_start(&mut self, time: f64);
fn get_time_profiler_chan(&self) -> &ProfilerChan;
fn send_queued_constellation_msg(&self, name: PWMType, time: f64);
fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: f64);
}
lazy_static!{
static ref TEN_SECONDS: Duration = Duration::new(10, 0);
pub static ref MAX_TASK_TIME: u64 = 50000000;
}
/// maximum task time is 50ms (in ns)
pub const MAX_TASK_NS: u64 = 50000000;
/// 10 second window (in ns)
const INTERACTIVE_WINDOW_SECONDS_IN_NS: u64 = 10000000000;
// there should be some requirements on self
// can i have self<U> ?
pub fn set_metric<U: ProgressiveWebMetric>(
fn set_metric<U: ProgressiveWebMetric>(
pwm: &U,
metadata: Option<TimerMetadata>,
metric_type: PWMType,
metric_type: ProgressiveWebMetricType,
category: ProfilerCategory,
attr: &Cell<Option<f64>>,
metric_time: Option<f64>,
) {
metric_time: Option<f64>)
{
let navigation_start = match pwm.get_navigation_start() {
Some(time) => time,
None => {
@ -67,7 +61,6 @@ pub fn set_metric<U: ProgressiveWebMetric>(
return;
}
};
let now = match metric_time {
Some(time) => time,
None => precise_time_ns() as f64,
@ -97,11 +90,19 @@ pub fn set_metric<U: ProgressiveWebMetric>(
}
// https://github.com/GoogleChrome/lighthouse/issues/27
// we can look at three different metrics here:
// navigation start -> visually ready (dom content loaded)
// navigation start -> thread ready (main thread available)
// visually ready -> thread ready
#[derive(MallocSizeOf)]
pub struct InteractiveMetrics {
navigation_start: Cell<Option<f64>>,
/// when we navigated to the page
navigation_start: Option<f64>,
/// indicates if the page is visually ready
dom_content_loaded: Cell<Option<f64>>,
/// main thread is available -- there's been a 10s window with no tasks longer than 50ms
main_thread_available: Cell<Option<f64>>,
// max(main_thread_available, dom_content_loaded)
time_to_interactive: Cell<Option<f64>>,
#[ignore_malloc_size_of = "can't measure channels"]
time_profiler_chan: ProfilerChan,
@ -110,73 +111,44 @@ pub struct InteractiveMetrics {
#[derive(Clone, Copy, Debug, MallocSizeOf)]
pub struct InteractiveWindow {
start: u64,
#[ignore_malloc_size_of = "don't need to measure rn"] //FIXME
instant: Instant,
all_interactive: bool,
}
//TODO i don't think all interactive is needed anymore
impl InteractiveWindow {
pub fn new() -> InteractiveWindow {
InteractiveWindow {
start: precise_time_ns(),
instant: Instant::now(),
all_interactive: false,
}
}
// We need to either start or restart the 10s window
// start: we've added a new document
// restart: there was a task > 50s
// restart: there was a task > 50ms
// not all documents are interactive
pub fn start_window(&mut self) {
self.start = precise_time_ns();
self.instant = Instant::now();
self.unset_all_interactive();
}
/// check if 10s has elapsed since start
pub fn needs_check(&self) -> bool {
self.instant.elapsed() > *TEN_SECONDS
}
pub fn check_interactive(&self) -> bool {
self.all_interactive
}
pub fn set_all_interactive(&mut self) {
self.all_interactive = true;
}
pub fn unset_all_interactive(&mut self) {
self.all_interactive = false;
precise_time_ns() - self.start >= INTERACTIVE_WINDOW_SECONDS_IN_NS
}
pub fn get_start(&self) -> u64 {
self.start
}
pub fn elapsed_since_start(&self) -> u64 {
self.instant.elapsed().as_secs()
}
// ^^^^^^^^^^^^^ expected u64, found struct `MAX_TASK_TIME`
pub fn max_task_time() -> u64 {
50000000
}
}
#[derive(Debug)]
pub enum InteractiveFlag {
DCL,
TTI,
DOMContentLoaded,
TimeToInteractive(f64),
}
impl InteractiveMetrics {
pub fn new(time_profiler_chan: ProfilerChan) -> InteractiveMetrics {
InteractiveMetrics {
navigation_start: Cell::new(None),
navigation_start: None,
dom_content_loaded: Cell::new(None),
main_thread_available: Cell::new(None),
time_to_interactive: Cell::new(None),
@ -190,9 +162,9 @@ impl InteractiveMetrics {
}
}
pub fn set_main_thread_available(&self, time: Option<f64>) {
if self.main_thread_available.get().is_none() && time.is_some() {
self.main_thread_available.set(time);
pub fn set_main_thread_available(&self, time: f64) {
if self.main_thread_available.get().is_none() {
self.main_thread_available.set(Some(time));
}
}
@ -209,7 +181,6 @@ impl InteractiveMetrics {
pub fn maybe_set_tti<T>(
&self,
profiler_metadata_factory: &T,
time: Option<f64>,
metric: InteractiveFlag,
) where
T: ProfilerMetadataFactory,
@ -218,32 +189,28 @@ impl InteractiveMetrics {
return;
}
match metric {
InteractiveFlag::DCL => self.set_dom_content_loaded(),
InteractiveFlag::TTI => self.set_main_thread_available(time),
InteractiveFlag::DOMContentLoaded => self.set_dom_content_loaded(),
InteractiveFlag::TimeToInteractive(time) => self.set_main_thread_available(time),
}
let dcl = self.dom_content_loaded.get();
let mta = self.main_thread_available.get();
if dcl.is_some() && mta.is_some() {
let metric_time = match dcl.unwrap().partial_cmp(&mta.unwrap()) {
Some(order) => {
match order {
Ordering::Less => mta,
_ => dcl,
}
}
None => panic!("no ordering possible. something bad happened"),
};
set_metric(
self,
profiler_metadata_factory.new_metadata(),
PWMType::TimeToInteractive,
ProfilerCategory::TimeToInteractive,
&self.time_to_interactive,
metric_time,
);
}
let (dcl, mta) = match (dcl, mta) {
(Some(dcl), Some(mta)) => (dcl, mta),
_ => return,
};
let metric_time = match dcl.partial_cmp(&mta) {
Some(Ordering::Less) => mta,
Some(_) => dcl,
None => panic!("no ordering possible. something bad happened"),
};
set_metric(
self,
profiler_metadata_factory.new_metadata(),
ProgressiveWebMetricType::TimeToInteractive,
ProfilerCategory::TimeToInteractive,
&self.time_to_interactive,
Some(metric_time));
}
pub fn get_tti(&self) -> Option<f64> {
@ -251,19 +218,16 @@ impl InteractiveMetrics {
}
}
// TODO don't impl on ref
impl ProgressiveWebMetric for InteractiveMetrics {
fn get_navigation_start(&self) -> Option<f64> {
self.navigation_start.get()
self.navigation_start
}
fn set_navigation_start(&mut self, time: f64) {
self.navigation_start.set(Some(time));
self.navigation_start = Some(time);
}
fn send_queued_constellation_msg(&self, name: PWMType, time: f64) {
// TODO
}
fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: f64) { }
fn get_time_profiler_chan(&self) -> &ProfilerChan {
&self.time_profiler_chan
@ -272,7 +236,7 @@ impl ProgressiveWebMetric for InteractiveMetrics {
pub struct PaintTimeMetrics {
pending_metrics: RefCell<HashMap<Epoch, (Option<TimerMetadata>, bool)>>,
navigation_start: Cell<Option<f64>>,
navigation_start: Option<f64>,
first_paint: Cell<Option<f64>>,
first_contentful_paint: Cell<Option<f64>>,
pipeline_id: PipelineId,
@ -286,11 +250,11 @@ impl PaintTimeMetrics {
pipeline_id: PipelineId,
time_profiler_chan: ProfilerChan,
constellation_chan: IpcSender<LayoutMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
) -> PaintTimeMetrics {
script_chan: IpcSender<ConstellationControlMsg>)
-> PaintTimeMetrics {
PaintTimeMetrics {
pending_metrics: RefCell::new(HashMap::new()),
navigation_start: Cell::new(None),
navigation_start: None,
first_paint: Cell::new(None),
first_contentful_paint: Cell::new(None),
pipeline_id,
@ -304,16 +268,14 @@ impl PaintTimeMetrics {
where
T: ProfilerMetadataFactory,
{
{
if self.first_paint.get().is_some() {
return;
}
if self.first_paint.get().is_some() {
return;
}
set_metric(
self,
profiler_metadata_factory.new_metadata(),
PWMType::FirstPaint,
ProgressiveWebMetricType::FirstPaint,
ProfilerCategory::TimeToFirstPaint,
&self.first_paint,
None,
@ -324,10 +286,8 @@ impl PaintTimeMetrics {
&self,
profiler_metadata_factory: &T,
epoch: Epoch,
display_list: &DisplayList,
) where
T: ProfilerMetadataFactory,
{
display_list: &DisplayList)
where T: ProfilerMetadataFactory {
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() {
// If we already set all paint metrics, we just bail out.
return;
@ -363,9 +323,8 @@ impl PaintTimeMetrics {
}
pub fn maybe_set_metric(&self, epoch: Epoch, paint_time: f64) {
if (self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some()) ||
self.get_navigation_start().is_none()
{
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() ||
self.navigation_start.is_none() {
// If we already set all paint metrics or we have not set navigation start yet,
// we just bail out.
return;
@ -376,7 +335,7 @@ impl PaintTimeMetrics {
set_metric(
self,
profiler_metadata.clone(),
PWMType::FirstPaint,
ProgressiveWebMetricType::FirstPaint,
ProfilerCategory::TimeToFirstPaint,
&self.first_paint,
Some(paint_time),
@ -386,7 +345,7 @@ impl PaintTimeMetrics {
set_metric(
self,
profiler_metadata,
PWMType::FirstContentfulPaint,
ProgressiveWebMetricType::FirstContentfulPaint,
ProfilerCategory::TimeToFirstContentfulPaint,
&self.first_contentful_paint,
Some(paint_time),
@ -404,17 +363,16 @@ impl PaintTimeMetrics {
}
}
// TODO don't impl on ref
impl ProgressiveWebMetric for PaintTimeMetrics {
fn get_navigation_start(&self) -> Option<f64> {
self.navigation_start.get()
self.navigation_start
}
fn set_navigation_start(&mut self, time: f64) {
self.navigation_start.set(Some(time));
self.navigation_start = Some(time);
}
fn send_queued_constellation_msg(&self, name: PWMType, time: f64) {
fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: f64) {
let msg = ConstellationControlMsg::PaintMetric(self.pipeline_id, name, time);
if let Err(e) = self.script_chan.send(msg) {
warn!("Sending metric to script thread failed ({}).", e);

View file

@ -359,7 +359,7 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)]
pub fn forward_error_to_worker_object(&self, error_info: ErrorInfo) {
let worker = self.worker.borrow().as_ref().unwrap().clone();
let pipeline_id = worker.clone().root().global().pipeline_id();
let pipeline_id = self.upcast::<GlobalScope>().pipeline_id();
let task = Box::new(task!(forward_error_to_worker_object: move || {
let worker = worker.root();
let global = worker.global();
@ -406,7 +406,7 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
unsafe fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
let data = StructuredCloneData::write(cx, message)?;
let worker = self.worker.borrow().as_ref().unwrap().clone();
let pipeline_id = worker.clone().root().global().pipeline_id();
let pipeline_id = self.upcast::<GlobalScope>().pipeline_id();
let task = Box::new(task!(post_worker_message: move || {
Worker::handle_message(worker, data);
}));

View file

@ -99,7 +99,7 @@ use hyper_serde::Serde;
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{JSContext, JSRuntime};
use js::jsapi::JS_GetRuntime;
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, ProgressiveWebMetric};
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory};
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId};
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
@ -1839,7 +1839,7 @@ impl Document {
update_with_current_time_ms(&self.dom_content_loaded_event_end);
// html parsing has finished - set dom content loaded
self.interactive_time.borrow().maybe_set_tti(self, None, InteractiveFlag::DCL);
self.interactive_time.borrow().maybe_set_tti(self, InteractiveFlag::DOMContentLoaded);
// Step 4.2.
// TODO: client message queue.
@ -1927,7 +1927,7 @@ impl Document {
self.interactive_time.borrow()
}
pub fn is_interactive(&self) -> bool {
pub fn has_recorded_tti_metric(&self) -> bool {
self.get_interactive_metrics().get_tti().is_some()
}
@ -1958,13 +1958,12 @@ impl Document {
/// check tti for this document
/// if it's been 10s since this doc encountered a task over 50ms, then we consider the
/// main thread available and try to set tti
pub fn check_tti(&self) {
if self.is_interactive() { return; }
pub fn record_tti_if_necessary(&self) {
if self.has_recorded_tti_metric() { return; }
if self.tti_window.borrow().needs_check() {
self.get_interactive_metrics().maybe_set_tti(self,
Some(self.tti_window.borrow().get_start() as f64),
InteractiveFlag::TTI);
InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start() as f64));
}
}
@ -2177,8 +2176,7 @@ impl Document {
(DocumentReadyState::Complete, true)
};
let mut interactive_time = InteractiveMetrics::new(window.time_profiler_chan().clone());
interactive_time.set_navigation_start(window.get_navigation_start());
let interactive_time = InteractiveMetrics::new(window.time_profiler_chan().clone());
Document {
node: Node::new_document_node(),

View file

@ -9,7 +9,7 @@ use dom::bindings::str::DOMString;
use dom::globalscope::GlobalScope;
use dom::performanceentry::PerformanceEntry;
use dom_struct::dom_struct;
use script_traits::PWMType;
use script_traits::ProgressiveWebMetricType;
#[dom_struct]
pub struct PerformancePaintTiming {
@ -17,10 +17,10 @@ pub struct PerformancePaintTiming {
}
impl PerformancePaintTiming {
fn new_inherited(metric_type: PWMType, start_time: f64) -> PerformancePaintTiming {
fn new_inherited(metric_type: ProgressiveWebMetricType, start_time: f64) -> PerformancePaintTiming {
let name = match metric_type {
PWMType::FirstPaint => DOMString::from("first-paint"),
PWMType::FirstContentfulPaint => DOMString::from("first-contentful-paint"),
ProgressiveWebMetricType::FirstPaint => DOMString::from("first-paint"),
ProgressiveWebMetricType::FirstContentfulPaint => DOMString::from("first-contentful-paint"),
_ => DOMString::from(""),
};
PerformancePaintTiming {
@ -33,7 +33,7 @@ impl PerformancePaintTiming {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope,
metric_type: PWMType,
metric_type: ProgressiveWebMetricType,
start_time: f64) -> DomRoot<PerformancePaintTiming> {
let entry = PerformancePaintTiming::new_inherited(metric_type, start_time);
reflect_dom_object(Box::new(entry), global, PerformancePaintTimingBinding::Wrap)

View file

@ -494,6 +494,7 @@ impl VRDisplay {
let address = Trusted::new(&*self);
let near_init = self.depth_near.get();
let far_init = self.depth_far.get();
let pipeline_id = self.global().pipeline_id();
// The render loop at native headset frame rate is implemented using a dedicated thread.
// Every loop iteration syncs pose data with the HMD, submits the pixels to the display and waits for Vsync.
@ -505,7 +506,6 @@ impl VRDisplay {
let (raf_sender, raf_receiver) = mpsc::channel();
let mut near = near_init;
let mut far = far_init;
// let pipeline_id = self.global().pipeline_id().clone(); TODO
// Initialize compositor
api_sender.send_vr(WebVRCommand::Create(display_id)).unwrap();
@ -516,7 +516,7 @@ impl VRDisplay {
let task = Box::new(task!(handle_vrdisplay_raf: move || {
this.root().handle_raf(&sender);
}));
js_sender.send(CommonScriptMsg::Task(WebVREvent, task, None)).unwrap();
js_sender.send(CommonScriptMsg::Task(WebVREvent, task, Some(pipeline_id))).unwrap();
// Run Sync Poses in parallell on Render thread
let msg = WebVRCommand::SyncPoses(display_id, near, far, sync_sender.clone());

View file

@ -29,6 +29,7 @@ use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext, JSRuntime};
use js::jsval::UndefinedValue;
use js::panic::maybe_resume_unwind;
use msg::constellation_msg::PipelineId;
use net_traits::{IpcSend, load_whole_resource};
use net_traits::request::{CredentialsMode, Destination, RequestInit as NetRequestInit, Type as RequestType};
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, get_reports, Runtime};
@ -165,6 +166,10 @@ impl WorkerGlobalScope {
cancelled: self.closing.clone(),
}
}
pub fn pipeline_id(&self) -> PipelineId {
self.globalscope.pipeline_id()
}
}
impl WorkerGlobalScopeMethods for WorkerGlobalScope {
@ -364,15 +369,15 @@ impl WorkerGlobalScope {
}
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
FileReadingTaskSource(self.script_chan())
FileReadingTaskSource(self.script_chan(), self.pipeline_id())
}
pub fn networking_task_source(&self) -> NetworkingTaskSource {
NetworkingTaskSource(self.script_chan())
NetworkingTaskSource(self.script_chan(), self.pipeline_id())
}
pub fn performance_timeline_task_source(&self) -> PerformanceTimelineTaskSource {
PerformanceTimelineTaskSource(self.script_chan())
PerformanceTimelineTaskSource(self.script_chan(), self.pipeline_id())
}
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {

View file

@ -1285,7 +1285,7 @@ impl XMLHttpRequest {
let (task_source, script_port) = if self.sync.get() {
let (tx, rx) = global.new_script_pair();
(NetworkingTaskSource(tx), Some(rx))
(NetworkingTaskSource(tx, global.pipeline_id()), Some(rx))
} else {
(global.networking_task_source(), None)
};

View file

@ -16,7 +16,6 @@
//! takes over the response body. Once parsing is complete, the document lifecycle for loading
//! a page runs its course and the script thread returns to processing events in the main event
//! loop.
#![feature(box_syntax)]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
@ -75,7 +74,7 @@ use js::jsapi::{JSTracer, SetWindowProxyClass};
use js::jsval::UndefinedValue;
use malloc_size_of::MallocSizeOfOps;
use mem::malloc_size_of_including_self;
use metrics::{InteractiveWindow, PaintTimeMetrics};
use metrics::{MAX_TASK_NS, PaintTimeMetrics};
use microtask::{MicrotaskQueue, Microtask};
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, PipelineNamespace, TopLevelBrowsingContextId};
use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg};
@ -92,7 +91,7 @@ use script_traits::{CompositorEvent, ConstellationControlMsg};
use script_traits::{DiscardBrowsingContext, DocumentActivity, EventResult};
use script_traits::{InitialScriptState, JsEvalResult, LayoutMsg, LoadData};
use script_traits::{MouseButton, MouseEventType, MozBrowserEvent, NewLayoutInfo};
use script_traits::{PWMType, Painter, ScriptMsg, ScriptThreadFactory};
use script_traits::{ProgressiveWebMetricType, Painter, ScriptMsg, ScriptThreadFactory};
use script_traits::{ScriptToConstellationChan, TimerEvent, TimerSchedulerMsg};
use script_traits::{TimerSource, TouchEventType, TouchId, UntrustedNodeAddress};
use script_traits::{UpdatePipelineIdReason, WindowSizeData, WindowSizeType};
@ -415,17 +414,17 @@ pub struct ScriptThread {
/// events in the event queue.
chan: MainThreadScriptChan,
dom_manipulation_task_source: DOMManipulationTaskSource,
dom_manipulation_task_sender: Sender<MainThreadScriptMsg>,
user_interaction_task_source: UserInteractionTaskSource,
user_interaction_task_sender: Sender<MainThreadScriptMsg>,
networking_task_source: NetworkingTaskSource,
networking_task_sender: Box<ScriptChan>,
history_traversal_task_source: HistoryTraversalTaskSource,
file_reading_task_source: FileReadingTaskSource,
file_reading_task_sender: Box<ScriptChan>,
performance_timeline_task_source: PerformanceTimelineTaskSource,
performance_timeline_task_sender: Box<ScriptChan>,
/// A channel to hand out to threads that need to respond to a message from the script thread.
control_chan: IpcSender<ConstellationControlMsg>,
@ -686,8 +685,8 @@ impl ScriptThread {
SCRIPT_THREAD_ROOT.with(|root| {
if let Some(script_thread) = root.get() {
let script_thread = unsafe { &*script_thread };
let p_id = Some(new_layout_info.new_pipeline_id);
script_thread.profile_event(ScriptThreadEventCategory::AttachLayout, p_id, || {
let pipeline_id = Some(new_layout_info.new_pipeline_id);
script_thread.profile_event(ScriptThreadEventCategory::AttachLayout, pipeline_id, || {
script_thread.handle_new_layout(new_layout_info, origin);
})
}
@ -836,12 +835,13 @@ impl ScriptThread {
port: port,
chan: MainThreadScriptChan(chan.clone()),
dom_manipulation_task_source: DOMManipulationTaskSource(chan.clone()),
user_interaction_task_source: UserInteractionTaskSource(chan.clone()),
networking_task_source: NetworkingTaskSource(boxed_script_sender.clone()),
dom_manipulation_task_sender: chan.clone(),
user_interaction_task_sender: chan.clone(),
networking_task_sender: boxed_script_sender.clone(),
file_reading_task_sender: boxed_script_sender.clone(),
performance_timeline_task_sender: boxed_script_sender.clone(),
history_traversal_task_source: HistoryTraversalTaskSource(chan),
file_reading_task_source: FileReadingTaskSource(boxed_script_sender.clone()),
performance_timeline_task_source: PerformanceTimelineTaskSource(boxed_script_sender),
control_chan: state.control_chan,
control_port: control_port,
@ -970,8 +970,8 @@ impl ScriptThread {
// child list yet, causing the find() to fail.
FromConstellation(ConstellationControlMsg::AttachLayout(
new_layout_info)) => {
//FIXME there should be a pipeline id
self.profile_event(ScriptThreadEventCategory::AttachLayout, None, || {
let pipeline_id = new_layout_info.new_pipeline_id;
self.profile_event(ScriptThreadEventCategory::AttachLayout, Some(pipeline_id), || {
// If this is an about:blank load, it must share the creator's origin.
// This must match the logic in the constellation when creating a new pipeline
let origin = if new_layout_info.load_data.url.as_str() != "about:blank" {
@ -1060,9 +1060,9 @@ impl ScriptThread {
debug!("Processing event {:?}.", msg);
let category = self.categorize_msg(&msg);
let p_id = self.message_to_pipeline(&msg);
let pipeline_id = self.message_to_pipeline(&msg);
let result = self.profile_event(category, p_id, move || {
let result = self.profile_event(category, pipeline_id, move || {
match msg {
FromConstellation(ConstellationControlMsg::ExitScriptThread) => {
self.handle_exit_script_thread_msg();
@ -1127,6 +1127,7 @@ impl ScriptThread {
_ => ScriptThreadEventCategory::ConstellationMsg
}
},
// TODO https://github.com/servo/servo/issues/18998
MixedMessage::FromDevtools(_) => ScriptThreadEventCategory::DevtoolsMsg,
MixedMessage::FromImageCache(_) => ScriptThreadEventCategory::ImageCacheMsg,
MixedMessage::FromScript(ref inner_msg) => {
@ -1169,15 +1170,15 @@ impl ScriptThread {
FocusIFrame(id, ..) => Some(id),
WebDriverScriptCommand(id, ..) => Some(id),
TickAllAnimations(id) => Some(id),
// FIXME https://github.com/servo/servo/issues/15079
TransitionEnd(..) => None,
WebFontLoaded(id) => Some(id),
DispatchIFrameLoadEvent { .. } => None,
DispatchIFrameLoadEvent { target: _, parent: id, child: _ } => Some(id),
DispatchStorageEvent(id, ..) => Some(id),
ReportCSSError(id, ..) => Some(id),
Reload(id, ..) => Some(id),
WebVREvents(id, ..) => Some(id),
PaintMetric(..) => None,
InteractiveMetric(..) => None,
}
},
MixedMessage::FromDevtools(_) => None,
@ -1185,7 +1186,7 @@ impl ScriptThread {
match *inner_msg {
MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, _, pipeline_id)) =>
pipeline_id,
MainThreadScriptMsg::Common(_) => None, //TODO double check
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(_)) => None,
MainThreadScriptMsg::ExitWindow(pipeline_id) => Some(pipeline_id),
MainThreadScriptMsg::Navigate(pipeline_id, ..) => Some(pipeline_id),
MainThreadScriptMsg::WorkletLoaded(pipeline_id) => Some(pipeline_id),
@ -1204,9 +1205,10 @@ impl ScriptThread {
}
}
fn profile_event<F, R>(&self, category: ScriptThreadEventCategory, p_id: Option<PipelineId>, f: F) -> R
fn profile_event<F, R>(&self, category: ScriptThreadEventCategory, pipeline_id: Option<PipelineId>, f: F) -> R
where F: FnOnce() -> R {
if opts::get().profile_script_events {
let start = precise_time_ns();
let value = if opts::get().profile_script_events {
let profiler_cat = match category {
ScriptThreadEventCategory::AttachLayout => ProfilerCategory::ScriptAttachLayout,
ScriptThreadEventCategory::ConstellationMsg => ProfilerCategory::ScriptConstellationMsg,
@ -1238,27 +1240,20 @@ impl ScriptThread {
ScriptThreadEventCategory::ExitFullscreen => ProfilerCategory::ScriptExitFullscreen,
ScriptThreadEventCategory::PerformanceTimelineTask => ProfilerCategory::ScriptPerformanceEvent,
};
let start = precise_time_ns();
let t = profile(profiler_cat, None, self.time_profiler_chan.clone(), f);
let end = precise_time_ns();
debug!("Task {:?} took {}", category, end - start); // TODO do we want to do anything with this?
for (doc_id, doc) in self.documents.borrow().iter() {
match p_id {
Some(p_id) => {
if p_id == doc_id && end - start > InteractiveWindow::max_task_time() {
doc.start_tti()
}
},
_ => ()
}
doc.check_tti();
}
t
profile(profiler_cat, None, self.time_profiler_chan.clone(), f)
} else {
f()
};
let end = precise_time_ns();
for (doc_id, doc) in self.documents.borrow().iter() {
if let Some(pipeline_id) = pipeline_id {
if pipeline_id == doc_id && end - start > MAX_TASK_NS {
doc.start_tti();
}
}
doc.record_tti_if_necessary();
}
value
}
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
@ -1326,7 +1321,6 @@ impl ScriptThread {
self.handle_webvr_events(pipeline_id, events),
ConstellationControlMsg::PaintMetric(pipeline_id, metric_type, metric_value) =>
self.handle_paint_metric(pipeline_id, metric_type, metric_value),
ConstellationControlMsg::InteractiveMetric(pipeline_id, metric_value) => (), //TODO
msg @ ConstellationControlMsg::AttachLayout(..) |
msg @ ConstellationControlMsg::Viewport(..) |
msg @ ConstellationControlMsg::SetScrollState(..) |
@ -1812,12 +1806,24 @@ impl ScriptThread {
let _ = self.chan.0.send(MainThreadScriptMsg::DispatchJobQueue { scope_url });
}
pub fn dom_manipulation_task_source(&self) -> &DOMManipulationTaskSource {
&self.dom_manipulation_task_source
pub fn dom_manipulation_task_source(&self, pipeline_id: PipelineId) -> DOMManipulationTaskSource {
DOMManipulationTaskSource(self.dom_manipulation_task_sender.clone(), pipeline_id)
}
pub fn performance_timeline_task_source(&self) -> &PerformanceTimelineTaskSource {
&self.performance_timeline_task_source
pub fn performance_timeline_task_source(&self, pipeline_id: PipelineId) -> PerformanceTimelineTaskSource {
PerformanceTimelineTaskSource(self.performance_timeline_task_sender.clone(), pipeline_id)
}
pub fn user_interaction_task_source(&self, pipeline_id: PipelineId) -> UserInteractionTaskSource {
UserInteractionTaskSource(self.user_interaction_task_sender.clone(), pipeline_id)
}
pub fn networking_task_source(&self, pipeline_id: PipelineId) -> NetworkingTaskSource {
NetworkingTaskSource(self.networking_task_sender.clone(), pipeline_id)
}
pub fn file_reading_task_source(&self, pipeline_id: PipelineId) -> FileReadingTaskSource {
FileReadingTaskSource(self.file_reading_task_sender.clone(), pipeline_id)
}
/// Handles a request for the window title.
@ -2105,8 +2111,6 @@ impl ScriptThread {
debug!("ScriptThread: loading {} on pipeline {:?}", incomplete.url, incomplete.pipeline_id);
let MainThreadScriptChan(ref sender) = self.chan;
let DOMManipulationTaskSource(ref dom_sender) = self.dom_manipulation_task_source;
let UserInteractionTaskSource(ref user_sender) = self.user_interaction_task_source;
let HistoryTraversalTaskSource(ref history_sender) = self.history_traversal_task_source;
let (ipc_timer_event_chan, ipc_timer_event_port) = ipc::channel().unwrap();
@ -2128,12 +2132,12 @@ impl ScriptThread {
let window = Window::new(
self.js_runtime.clone(),
MainThreadScriptChan(sender.clone()),
DOMManipulationTaskSource(dom_sender.clone()),
UserInteractionTaskSource(user_sender.clone()),
self.networking_task_source.clone(),
self.dom_manipulation_task_source(incomplete.pipeline_id),
self.user_interaction_task_source(incomplete.pipeline_id),
self.networking_task_source(incomplete.pipeline_id),
HistoryTraversalTaskSource(history_sender.clone()),
self.file_reading_task_source.clone(),
self.performance_timeline_task_source.clone(),
self.file_reading_task_source(incomplete.pipeline_id),
self.performance_timeline_task_source(incomplete.pipeline_id).clone(),
self.image_cache_channel.clone(),
self.image_cache.clone(),
self.resource_threads.clone(),
@ -2650,7 +2654,7 @@ impl ScriptThread {
fn handle_paint_metric(&self,
pipeline_id: PipelineId,
metric_type: PWMType,
metric_type: ProgressiveWebMetricType,
metric_value: f64) {
let window = self.documents.borrow().find_window(pipeline_id);
if let Some(window) = window {

View file

@ -153,19 +153,21 @@ impl JobQueue {
// https://w3c.github.io/ServiceWorker/#register-algorithm
fn run_register(&self, job: &Job, scope_url: ServoUrl, script_thread: &ScriptThread) {
debug!("running register job");
let global = &*job.client.global();
let pipeline_id = global.pipeline_id();
// Step 1-3
if !UrlHelper::is_origin_trustworthy(&job.script_url) {
// Step 1.1
reject_job_promise(job,
Error::Type("Invalid script ServoURL".to_owned()),
script_thread.dom_manipulation_task_source());
&script_thread.dom_manipulation_task_source(pipeline_id));
// Step 1.2 (see run_job)
return;
} else if job.script_url.origin() != job.referrer.origin() || job.scope_url.origin() != job.referrer.origin() {
// Step 2.1/3.1
reject_job_promise(job,
Error::Security,
script_thread.dom_manipulation_task_source());
&script_thread.dom_manipulation_task_source(pipeline_id));
// Step 2.2/3.2 (see run_job)
return;
}
@ -180,17 +182,15 @@ impl JobQueue {
if let Some(ref newest_worker) = reg.get_newest_worker() {
if (&*newest_worker).get_script_url() == job.script_url {
// Step 5.3.1
resolve_job_promise(job, &*reg, script_thread.dom_manipulation_task_source());
resolve_job_promise(job, &*reg, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 5.3.2 (see run_job)
return;
}
}
} else {
// Step 6.1
let global = &*job.client.global();
let pipeline = global.pipeline_id();
let new_reg = ServiceWorkerRegistration::new(&*global, &job.script_url, scope_url);
script_thread.handle_serviceworker_registration(&job.scope_url, &*new_reg, pipeline);
script_thread.handle_serviceworker_registration(&job.scope_url, &*new_reg, pipeline_id);
}
// Step 7
self.update(job, script_thread)
@ -218,13 +218,16 @@ impl JobQueue {
// https://w3c.github.io/ServiceWorker/#update-algorithm
fn update(&self, job: &Job, script_thread: &ScriptThread) {
debug!("running update job");
let global = &*job.client.global();
let pipeline_id = global.pipeline_id();
// Step 1
let reg = match script_thread.handle_get_registration(&job.scope_url) {
Some(reg) => reg,
None => {
let err_type = Error::Type("No registration to update".to_owned());
// Step 2.1
reject_job_promise(job, err_type, script_thread.dom_manipulation_task_source());
reject_job_promise(job, err_type, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 2.2 (see run_job)
return;
}
@ -233,7 +236,7 @@ impl JobQueue {
if reg.get_uninstalling() {
let err_type = Error::Type("Update called on an uninstalling registration".to_owned());
// Step 2.1
reject_job_promise(job, err_type, script_thread.dom_manipulation_task_source());
reject_job_promise(job, err_type, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 2.2 (see run_job)
return;
}
@ -244,7 +247,7 @@ impl JobQueue {
if newest_worker_url.as_ref() == Some(&job.script_url) && job.job_type == JobType::Update {
let err_type = Error::Type("Invalid script ServoURL".to_owned());
// Step 4.1
reject_job_promise(job, err_type, script_thread.dom_manipulation_task_source());
reject_job_promise(job, err_type, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 4.2 (see run_job)
return;
}
@ -252,7 +255,7 @@ impl JobQueue {
if let Some(newest_worker) = newest_worker {
job.client.set_controller(&*newest_worker);
// Step 8.1
resolve_job_promise(job, &*reg, script_thread.dom_manipulation_task_source());
resolve_job_promise(job, &*reg, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 8.2 present in run_job
}
// TODO Step 9 (create new service worker)

View file

@ -7,6 +7,7 @@ use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask};
use dom::eventtarget::EventTarget;
use dom::window::Window;
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use script_thread::MainThreadScriptMsg;
use servo_atoms::Atom;
@ -17,7 +18,7 @@ use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(Clone, JSTraceable)]
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>, pub PipelineId);
impl fmt::Debug for DOMManipulationTaskSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -37,7 +38,7 @@ impl TaskSource for DOMManipulationTaskSource {
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
ScriptThreadEventCategory::ScriptEvent,
Box::new(canceller.wrap_task(task)),
None //TODO
Some(self.1)
));
self.0.send(msg).map_err(|_| ())
}

View file

@ -4,17 +4,18 @@
use dom::domexception::DOMErrorName;
use dom::filereader::{FileReader, TrustedFileReader, GenerationId, ReadMetaData};
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory, ScriptChan};
use std::sync::Arc;
use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(JSTraceable)]
pub struct FileReadingTaskSource(pub Box<ScriptChan + Send + 'static>);
pub struct FileReadingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
impl Clone for FileReadingTaskSource {
fn clone(&self) -> FileReadingTaskSource {
FileReadingTaskSource(self.0.clone())
FileReadingTaskSource(self.0.clone(), self.1.clone())
}
}
@ -30,7 +31,7 @@ impl TaskSource for FileReadingTaskSource {
self.0.send(CommonScriptMsg::Task(
ScriptThreadEventCategory::FileRead,
Box::new(canceller.wrap_task(task)),
None //TODO
Some(self.1),
))
}
}

View file

@ -2,16 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(JSTraceable)]
pub struct NetworkingTaskSource(pub Box<ScriptChan + Send + 'static>);
pub struct NetworkingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
impl Clone for NetworkingTaskSource {
fn clone(&self) -> NetworkingTaskSource {
NetworkingTaskSource(self.0.clone())
NetworkingTaskSource(self.0.clone(), self.1.clone())
}
}
@ -27,7 +28,7 @@ impl TaskSource for NetworkingTaskSource {
self.0.send(CommonScriptMsg::Task(
ScriptThreadEventCategory::NetworkEvent,
Box::new(canceller.wrap_task(task)),
None
Some(self.1),
))
}
}
@ -42,7 +43,7 @@ impl NetworkingTaskSource {
self.0.send(CommonScriptMsg::Task(
ScriptThreadEventCategory::NetworkEvent,
Box::new(task),
None //TODO
Some(self.1),
))
}
}

View file

@ -8,6 +8,7 @@
use dom::bindings::refcounted::Trusted;
use dom::globalscope::GlobalScope;
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
use std::fmt;
use std::result::Result;
@ -15,11 +16,11 @@ use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(JSTraceable)]
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>);
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
impl Clone for PerformanceTimelineTaskSource {
fn clone(&self) -> PerformanceTimelineTaskSource {
PerformanceTimelineTaskSource(self.0.clone())
PerformanceTimelineTaskSource(self.0.clone(), self.1.clone())
}
}
@ -41,7 +42,7 @@ impl TaskSource for PerformanceTimelineTaskSource {
let msg = CommonScriptMsg::Task(
ScriptThreadEventCategory::PerformanceTimelineTask,
Box::new(canceller.wrap_task(task)),
None
Some(self.1)
);
self.0.send(msg).map_err(|_| ())
}

View file

@ -7,6 +7,7 @@ use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventTask};
use dom::eventtarget::EventTarget;
use dom::window::Window;
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use script_thread::MainThreadScriptMsg;
use servo_atoms::Atom;
@ -17,7 +18,7 @@ use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(Clone, JSTraceable)]
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>, pub PipelineId);
impl fmt::Debug for UserInteractionTaskSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -37,7 +38,7 @@ impl TaskSource for UserInteractionTaskSource {
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
ScriptThreadEventCategory::InputEvent,
Box::new(canceller.wrap_task(task)),
None
Some(self.1)
));
self.0.send(msg).map_err(|_| ())
}

View file

@ -233,7 +233,7 @@ pub enum DocumentActivity {
/// Type of recorded progressive web metric
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum PWMType {
pub enum ProgressiveWebMetricType {
/// Time to first Paint
FirstPaint,
/// Time to first contentful paint
@ -324,9 +324,7 @@ pub enum ConstellationControlMsg {
/// Notifies the script thread of WebVR events.
WebVREvents(PipelineId, Vec<WebVREvent>),
/// Notifies the script thread about a new recorded paint metric.
PaintMetric(PipelineId, PWMType, f64),
/// Notifies the script thread of interactive time
InteractiveMetric(PipelineId, f64),
PaintMetric(PipelineId, ProgressiveWebMetricType, f64),
}
impl fmt::Debug for ConstellationControlMsg {
@ -361,7 +359,6 @@ impl fmt::Debug for ConstellationControlMsg {
Reload(..) => "Reload",
WebVREvents(..) => "WebVREvents",
PaintMetric(..) => "PaintMetric",
InteractiveMetric(..) => "InteractiveMetric"
};
write!(formatter, "ConstellationMsg::{}", variant)
}

View file

@ -34,12 +34,12 @@ fn test_set_dcl() {
let profiler_metadata_factory = DummyProfilerMetadataFactory {};
let interactive = test_interactive();
interactive.maybe_set_tti(&profiler_metadata_factory, None, InteractiveFlag::DCL);
interactive.maybe_set_tti(&profiler_metadata_factory, InteractiveFlag::DOMContentLoaded);
let dcl = interactive.get_dom_content_loaded();
assert!(dcl.is_some());
//try to overwrite
interactive.maybe_set_tti(&profiler_metadata_factory, None, InteractiveFlag::DCL);
interactive.maybe_set_tti(&profiler_metadata_factory, InteractiveFlag::DOMContentLoaded);
assert_eq!(interactive.get_dom_content_loaded(), dcl);
assert_eq!(interactive.get_tti(), None);
}
@ -52,8 +52,7 @@ fn test_set_mta() {
let t = time::precise_time_ns();
interactive.maybe_set_tti(
&profiler_metadata_factory,
Some(t as f64),
InteractiveFlag::TTI,
InteractiveFlag::TimeToInteractive(t as f64),
);
let mta = interactive.get_main_thread_available();
assert!(mta.is_some());
@ -62,8 +61,7 @@ fn test_set_mta() {
//try to overwrite
interactive.maybe_set_tti(
&profiler_metadata_factory,
Some(time::precise_time_ns() as f64),
InteractiveFlag::TTI,
InteractiveFlag::TimeToInteractive(time::precise_time_ns() as f64),
);
assert_eq!(interactive.get_main_thread_available(), mta);
assert_eq!(interactive.get_tti(), None);
@ -77,13 +75,12 @@ fn test_set_tti_dcl() {
let t = time::precise_time_ns();
interactive.maybe_set_tti(
&profiler_metadata_factory,
Some(t as f64),
InteractiveFlag::TTI,
InteractiveFlag::TimeToInteractive(t as f64),
);
let mta = interactive.get_main_thread_available();
assert!(mta.is_some());
interactive.maybe_set_tti(&profiler_metadata_factory, None, InteractiveFlag::DCL);
interactive.maybe_set_tti(&profiler_metadata_factory, InteractiveFlag::DOMContentLoaded);
let dcl = interactive.get_dom_content_loaded();
assert!(dcl.is_some());
@ -96,15 +93,14 @@ fn test_set_tti_mta() {
let profiler_metadata_factory = DummyProfilerMetadataFactory {};
let interactive = test_interactive();
interactive.maybe_set_tti(&profiler_metadata_factory, None, InteractiveFlag::DCL);
interactive.maybe_set_tti(&profiler_metadata_factory, InteractiveFlag::DOMContentLoaded);
let dcl = interactive.get_dom_content_loaded();
assert!(dcl.is_some());
let t = time::precise_time_ns();
interactive.maybe_set_tti(
&profiler_metadata_factory,
Some(t as f64),
InteractiveFlag::TTI,
InteractiveFlag::TimeToInteractive(t as f64),
);
let mta = interactive.get_main_thread_available();
assert!(mta.is_some());

View file

@ -15,4 +15,5 @@ extern crate time;
#[cfg(test)]
mod interactive_time;
#[cfg(test)]
mod paint_time;

View file

@ -100,7 +100,7 @@ fn test_first_paint_setter() {
clip_scroll_nodes: Vec::new(),
};
let epoch = Epoch(0);
let mut paint_time_metrics = test_common(&empty_display_list, epoch);
let paint_time_metrics = test_common(&empty_display_list, epoch);
let now = time::precise_time_ns() as f64;
paint_time_metrics.maybe_set_metric(epoch, now);
assert!(
@ -134,7 +134,7 @@ fn test_first_contentful_paint_setter() {
clip_scroll_nodes: Vec::new(),
};
let epoch = Epoch(0);
let mut paint_time_metrics = test_common(&display_list, epoch);
let paint_time_metrics = test_common(&display_list, epoch);
let now = time::precise_time_ns() as f64;
paint_time_metrics.maybe_set_metric(epoch, now);
assert!(