diff --git a/src/components/compositing/compositor.rs b/src/components/compositing/compositor.rs index c12d50e1a15..f92a2920531 100644 --- a/src/components/compositing/compositor.rs +++ b/src/components/compositing/compositor.rs @@ -530,14 +530,24 @@ impl IOCompositor { new_layer_buffer_set.mark_will_leak(); match self.scene.root { - Some(ref layer) => { - assert!(CompositorData::add_buffers(layer.clone(), - &self.graphics_context, - pipeline_id, - layer_id, - new_layer_buffer_set, - epoch).is_none()); - self.recomposite = true; + Some(ref root_layer) => { + match CompositorData::find_layer_with_pipeline_and_layer_id(root_layer.clone(), + pipeline_id, + layer_id) { + Some(ref layer) => { + assert!(CompositorData::add_buffers(layer.clone(), + &self.graphics_context, + new_layer_buffer_set, + epoch)); + self.recomposite = true; + } + None => { + // FIXME: This may potentially be triggered by a race condition where a + // buffers are being rendered but the layer is removed before rendering + // completes. + fail!("compositor given paint command for non-existent layer"); + } + } } None => { fail!("compositor given paint command with no root layer initialized"); diff --git a/src/components/compositing/compositor_data.rs b/src/components/compositing/compositor_data.rs index ed67fe1584c..86d4fa2aeb0 100644 --- a/src/components/compositing/compositor_data.rs +++ b/src/components/compositing/compositor_data.rs @@ -675,33 +675,9 @@ impl CompositorData { // layer buffer set is consumed, and None is returned. pub fn add_buffers(layer: Rc>, graphics_context: &NativeCompositingGraphicsContext, - pipeline_id: PipelineId, - layer_id: LayerId, - mut new_buffers: Box, + new_buffers: Box, epoch: Epoch) - -> Option> { - debug!("compositor_data: starting add_buffers()"); - if layer.extra_data.borrow().pipeline.id != pipeline_id || - layer.extra_data.borrow().id != layer_id { - // ID does not match ours, so recurse on descendents (including hidden children). - for child_layer in layer.children().iter() { - match CompositorData::add_buffers(child_layer.clone(), - graphics_context, - pipeline_id, - layer_id, - new_buffers, - epoch) { - None => return None, - Some(buffers) => new_buffers = buffers, - } - } - - // Not found. Give the caller the buffers back. - return Some(new_buffers) - } - - debug!("compositor_data: layers found for add_buffers()"); - + -> bool { if layer.extra_data.borrow().epoch != epoch { debug!("add_buffers: compositor epoch mismatch: {:?} != {:?}, id: {:?}", layer.extra_data.borrow().epoch, @@ -709,7 +685,7 @@ impl CompositorData { layer.extra_data.borrow().pipeline.id); let msg = UnusedBufferMsg(new_buffers.buffers); let _ = layer.extra_data.borrow().pipeline.render_chan.send_opt(msg); - return None + return false; } { @@ -724,7 +700,7 @@ impl CompositorData { } CompositorData::build_layer_tree(layer.clone(), graphics_context); - None + return true; } // Recursively sets occluded portions of quadtrees to Hidden, so that they do not ask for