mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Setting a devtools timeline marker may fail, due to pipeline lookup failure.
This commit is contained in:
parent
f584003191
commit
a6d83a38e5
5 changed files with 28 additions and 22 deletions
|
@ -143,7 +143,7 @@ impl TimelineActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pull_timeline_data(&self, receiver: IpcReceiver<TimelineMarker>, mut emitter: Emitter) {
|
fn pull_timeline_data(&self, receiver: IpcReceiver<Option<TimelineMarker>>, mut emitter: Emitter) {
|
||||||
let is_recording = self.is_recording.clone();
|
let is_recording = self.is_recording.clone();
|
||||||
|
|
||||||
if !*is_recording.lock().unwrap() {
|
if !*is_recording.lock().unwrap() {
|
||||||
|
@ -157,7 +157,7 @@ impl TimelineActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut markers = vec![];
|
let mut markers = vec![];
|
||||||
while let Ok(marker) = receiver.try_recv() {
|
while let Ok(Some(marker)) = receiver.try_recv() {
|
||||||
markers.push(emitter.marker(marker));
|
markers.push(emitter.marker(marker));
|
||||||
}
|
}
|
||||||
emitter.send(markers);
|
emitter.send(markers);
|
||||||
|
@ -182,7 +182,7 @@ impl Actor for TimelineActor {
|
||||||
"start" => {
|
"start" => {
|
||||||
**self.is_recording.lock().as_mut().unwrap() = true;
|
**self.is_recording.lock().as_mut().unwrap() = true;
|
||||||
|
|
||||||
let (tx, rx) = ipc::channel::<TimelineMarker>().unwrap();
|
let (tx, rx) = ipc::channel::<Option<TimelineMarker>>().unwrap();
|
||||||
self.script_sender.send(SetTimelineMarkers(self.pipeline,
|
self.script_sender.send(SetTimelineMarkers(self.pipeline,
|
||||||
self.marker_types.clone(),
|
self.marker_types.clone(),
|
||||||
tx)).unwrap();
|
tx)).unwrap();
|
||||||
|
|
|
@ -190,6 +190,7 @@ pub struct AutoMargins {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Messages to process in a particular script thread, as instructed by a devtools client.
|
/// Messages to process in a particular script thread, as instructed by a devtools client.
|
||||||
|
/// TODO: better error handling, e.g. if pipeline id lookup fails?
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub enum DevtoolScriptControlMsg {
|
pub enum DevtoolScriptControlMsg {
|
||||||
/// Evaluate a JS snippet in the context of the global for the given pipeline.
|
/// Evaluate a JS snippet in the context of the global for the given pipeline.
|
||||||
|
@ -209,7 +210,7 @@ pub enum DevtoolScriptControlMsg {
|
||||||
/// Request live console messages for a given pipeline (true if desired, false otherwise).
|
/// Request live console messages for a given pipeline (true if desired, false otherwise).
|
||||||
WantsLiveNotifications(PipelineId, bool),
|
WantsLiveNotifications(PipelineId, bool),
|
||||||
/// Request live notifications for a given set of timeline events for a given pipeline.
|
/// Request live notifications for a given set of timeline events for a given pipeline.
|
||||||
SetTimelineMarkers(PipelineId, Vec<TimelineMarkerType>, IpcSender<TimelineMarker>),
|
SetTimelineMarkers(PipelineId, Vec<TimelineMarkerType>, IpcSender<Option<TimelineMarker>>),
|
||||||
/// Withdraw request for live timeline notifications for a given pipeline.
|
/// Withdraw request for live timeline notifications for a given pipeline.
|
||||||
DropTimelineMarkers(PipelineId, Vec<TimelineMarkerType>),
|
DropTimelineMarkers(PipelineId, Vec<TimelineMarkerType>),
|
||||||
/// Request a callback directed at the given actor name from the next animation frame
|
/// Request a callback directed at the given actor name from the next animation frame
|
||||||
|
|
|
@ -250,16 +250,21 @@ pub fn handle_wants_live_notifications(global: &GlobalScope, send_notifications:
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_set_timeline_markers(context: &BrowsingContext,
|
pub fn handle_set_timeline_markers(context: &BrowsingContext,
|
||||||
|
pipeline: PipelineId,
|
||||||
marker_types: Vec<TimelineMarkerType>,
|
marker_types: Vec<TimelineMarkerType>,
|
||||||
reply: IpcSender<TimelineMarker>) {
|
reply: IpcSender<Option<TimelineMarker>>) {
|
||||||
let window = context.active_window();
|
match context.find(pipeline) {
|
||||||
window.set_devtools_timeline_markers(marker_types, reply);
|
None => reply.send(None).unwrap(),
|
||||||
|
Some(context) => context.active_window().set_devtools_timeline_markers(marker_types, reply),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_drop_timeline_markers(context: &BrowsingContext,
|
pub fn handle_drop_timeline_markers(context: &BrowsingContext,
|
||||||
|
pipeline: PipelineId,
|
||||||
marker_types: Vec<TimelineMarkerType>) {
|
marker_types: Vec<TimelineMarkerType>) {
|
||||||
let window = context.active_window();
|
if let Some(context) = context.find(pipeline) {
|
||||||
window.drop_devtools_timeline_markers(marker_types);
|
context.active_window().drop_devtools_timeline_markers(marker_types);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_request_animation_frame(context: &BrowsingContext,
|
pub fn handle_request_animation_frame(context: &BrowsingContext,
|
||||||
|
|
|
@ -172,7 +172,7 @@ pub struct Window {
|
||||||
/// no devtools server
|
/// no devtools server
|
||||||
devtools_markers: DOMRefCell<HashSet<TimelineMarkerType>>,
|
devtools_markers: DOMRefCell<HashSet<TimelineMarkerType>>,
|
||||||
#[ignore_heap_size_of = "channels are hard"]
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
devtools_marker_sender: DOMRefCell<Option<IpcSender<TimelineMarker>>>,
|
devtools_marker_sender: DOMRefCell<Option<IpcSender<Option<TimelineMarker>>>>,
|
||||||
|
|
||||||
/// Pending resize event, if any.
|
/// Pending resize event, if any.
|
||||||
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
|
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
|
||||||
|
@ -1435,12 +1435,12 @@ impl Window {
|
||||||
pub fn emit_timeline_marker(&self, marker: TimelineMarker) {
|
pub fn emit_timeline_marker(&self, marker: TimelineMarker) {
|
||||||
let sender = self.devtools_marker_sender.borrow();
|
let sender = self.devtools_marker_sender.borrow();
|
||||||
let sender = sender.as_ref().expect("There is no marker sender");
|
let sender = sender.as_ref().expect("There is no marker sender");
|
||||||
sender.send(marker).unwrap();
|
sender.send(Some(marker)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_devtools_timeline_markers(&self,
|
pub fn set_devtools_timeline_markers(&self,
|
||||||
markers: Vec<TimelineMarkerType>,
|
markers: Vec<TimelineMarkerType>,
|
||||||
reply: IpcSender<TimelineMarker>) {
|
reply: IpcSender<Option<TimelineMarker>>) {
|
||||||
*self.devtools_marker_sender.borrow_mut() = Some(reply);
|
*self.devtools_marker_sender.borrow_mut() = Some(reply);
|
||||||
self.devtools_markers.borrow_mut().extend(markers.into_iter());
|
self.devtools_markers.borrow_mut().extend(markers.into_iter());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1004,8 +1004,8 @@ impl ScriptThread {
|
||||||
devtools::handle_get_children(&context, id, node_id, reply),
|
devtools::handle_get_children(&context, id, node_id, reply),
|
||||||
DevtoolScriptControlMsg::GetLayout(id, node_id, reply) =>
|
DevtoolScriptControlMsg::GetLayout(id, node_id, reply) =>
|
||||||
devtools::handle_get_layout(&context, id, node_id, reply),
|
devtools::handle_get_layout(&context, id, node_id, reply),
|
||||||
DevtoolScriptControlMsg::GetCachedMessages(pipeline_id, message_types, reply) =>
|
DevtoolScriptControlMsg::GetCachedMessages(id, message_types, reply) =>
|
||||||
devtools::handle_get_cached_messages(pipeline_id, message_types, reply),
|
devtools::handle_get_cached_messages(id, message_types, reply),
|
||||||
DevtoolScriptControlMsg::ModifyAttribute(id, node_id, modifications) =>
|
DevtoolScriptControlMsg::ModifyAttribute(id, node_id, modifications) =>
|
||||||
devtools::handle_modify_attribute(&context, id, node_id, modifications),
|
devtools::handle_modify_attribute(&context, id, node_id, modifications),
|
||||||
DevtoolScriptControlMsg::WantsLiveNotifications(id, to_send) => {
|
DevtoolScriptControlMsg::WantsLiveNotifications(id, to_send) => {
|
||||||
|
@ -1015,14 +1015,14 @@ impl ScriptThread {
|
||||||
};
|
};
|
||||||
devtools::handle_wants_live_notifications(window.upcast(), to_send)
|
devtools::handle_wants_live_notifications(window.upcast(), to_send)
|
||||||
},
|
},
|
||||||
DevtoolScriptControlMsg::SetTimelineMarkers(_pipeline_id, marker_types, reply) =>
|
DevtoolScriptControlMsg::SetTimelineMarkers(id, marker_types, reply) =>
|
||||||
devtools::handle_set_timeline_markers(&context, marker_types, reply),
|
devtools::handle_set_timeline_markers(&context, id, marker_types, reply),
|
||||||
DevtoolScriptControlMsg::DropTimelineMarkers(_pipeline_id, marker_types) =>
|
DevtoolScriptControlMsg::DropTimelineMarkers(id, marker_types) =>
|
||||||
devtools::handle_drop_timeline_markers(&context, marker_types),
|
devtools::handle_drop_timeline_markers(&context, id, marker_types),
|
||||||
DevtoolScriptControlMsg::RequestAnimationFrame(pipeline_id, name) =>
|
DevtoolScriptControlMsg::RequestAnimationFrame(id, name) =>
|
||||||
devtools::handle_request_animation_frame(&context, pipeline_id, name),
|
devtools::handle_request_animation_frame(&context, id, name),
|
||||||
DevtoolScriptControlMsg::Reload(pipeline_id) =>
|
DevtoolScriptControlMsg::Reload(id) =>
|
||||||
devtools::handle_reload(&context, pipeline_id),
|
devtools::handle_reload(&context, id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue