From c5994c65ef18a5345bd4a0a32ec4c3f4457cfa9e Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 6 Jan 2015 12:19:32 -0800 Subject: [PATCH] Be less stringent with invalid compositor messages It is possible for messages for defunct pipelines to arrive in the compositor. If the compositor believes that the pipelines are in the process of shutting down, simply ignore the messages. We still panic in the case that the pipeline is totally unknown. Fixes #3733. --- components/compositing/compositor.rs | 35 ++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 9c5d9c9c790..fc31b9e80a2 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -523,17 +523,25 @@ impl IOCompositor { } fn update_frame_tree(&mut self, frame_tree_diff: &FrameTreeDiff) { - let parent_layer = self.find_pipeline_root_layer(frame_tree_diff.parent_pipeline.id); + let pipeline_id = frame_tree_diff.parent_pipeline.id; + let parent_layer = match self.find_pipeline_root_layer(pipeline_id) { + Some(root_layer) => root_layer, + None => { + debug!("Ignoring FrameTreeUpdate message for pipeline ({}) shutting down.", + pipeline_id); + return; + } + }; parent_layer.add_child( self.create_root_layer_for_pipeline_and_rect(&frame_tree_diff.pipeline, frame_tree_diff.rect)); } - fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Rc> { - match self.find_layer_with_pipeline_and_layer_id(pipeline_id, LayerId::null()) { - Some(ref layer) => layer.clone(), - None => panic!("Tried to create or update layer for unknown pipeline"), + fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Option>> { + if !self.pipeline_details.contains_key(&pipeline_id) { + panic!("Tried to create or update layer for unknown pipeline") } + self.find_layer_with_pipeline_and_layer_id(pipeline_id, LayerId::null()) } fn update_layer_if_exists(&mut self, properties: LayerProperties) -> bool { @@ -547,9 +555,18 @@ impl IOCompositor { } fn create_or_update_base_layer(&mut self, layer_properties: LayerProperties) { + let pipeline_id = layer_properties.pipeline_id; + let root_layer = match self.find_pipeline_root_layer(pipeline_id) { + Some(root_layer) => root_layer, + None => { + debug!("Ignoring CreateOrUpdateBaseLayer message for pipeline ({}) shutting down.", + pipeline_id); + return; + } + }; + let need_new_base_layer = !self.update_layer_if_exists(layer_properties); if need_new_base_layer { - let root_layer = self.find_pipeline_root_layer(layer_properties.pipeline_id); root_layer.update_layer_except_bounds(layer_properties); let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone(); @@ -581,7 +598,11 @@ impl IOCompositor { } fn create_descendant_layer(&self, layer_properties: LayerProperties) { - let root_layer = self.find_pipeline_root_layer(layer_properties.pipeline_id); + let root_layer = match self.find_pipeline_root_layer(layer_properties.pipeline_id) { + Some(root_layer) => root_layer, + None => return, // This pipeline is in the process of shutting down. + }; + let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone(); let new_layer = CompositorData::new_layer(root_layer_pipeline, layer_properties,