From 5f600f0ec03d84d511744c4a8043d1f9dc81fb80 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Fri, 20 Sep 2013 03:45:16 -0400 Subject: [PATCH] fix constellation being inundated with messages from script. script task sent RendererReadyMsg after every reflow. now, the renderer sends RendererReady at the appropriate time, and _only_ if it doesn't have paint permission. --- src/components/gfx/render_task.rs | 24 +++++++++++++----------- src/components/main/constellation.rs | 13 +++++-------- src/components/main/pipeline.rs | 2 ++ src/components/script/script_task.rs | 3 +-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs index 170c8ad6158..63374dd71d6 100644 --- a/src/components/gfx/render_task.rs +++ b/src/components/gfx/render_task.rs @@ -9,7 +9,7 @@ use azure::azure_hl::{B8G8R8A8, DrawTarget}; use display_list::DisplayList; use servo_msg::compositor_msg::{RenderListener, IdleRenderState, RenderingRenderState, LayerBuffer}; use servo_msg::compositor_msg::{LayerBufferSet, Epoch}; -use servo_msg::constellation_msg::PipelineId; +use servo_msg::constellation_msg::{ConstellationChan, PipelineId, RendererReadyMsg}; use font_context::FontContext; use geom::matrix2d::Matrix2D; use geom::size::Size2D; @@ -17,8 +17,8 @@ use geom::rect::Rect; use opts::Opts; use render_context::RenderContext; -use std::cell::Cell; use std::comm::{Chan, Port, SharedChan}; +use std::task::spawn_with; use extra::arc::Arc; use servo_util::time::{ProfilerChan, profile}; @@ -86,6 +86,7 @@ struct RenderTask { id: PipelineId, port: Port>, compositor: C, + constellation_chan: ConstellationChan, font_ctx: @mut FontContext, opts: Opts, @@ -110,24 +111,21 @@ impl RenderTask { pub fn create(id: PipelineId, port: Port>, compositor: C, + constellation_chan: ConstellationChan, opts: Opts, profiler_chan: ProfilerChan) { - let compositor = Cell::new(compositor); - let opts = Cell::new(opts); - let port = Cell::new(port); - let profiler_chan = Cell::new(profiler_chan); - do spawn { - let compositor = compositor.take(); + do spawn_with((port, compositor, constellation_chan, opts, profiler_chan)) + |(port, compositor, constellation_chan, opts, profiler_chan)| { + let share_gl_context = compositor.get_gl_context(); - let opts = opts.take(); - let profiler_chan = profiler_chan.take(); // FIXME: rust/#5967 let mut render_task = RenderTask { id: id, - port: port.take(), + port: port, compositor: compositor, + constellation_chan: constellation_chan, font_ctx: @mut FontContext::new(opts.render_backend.clone(), false, profiler_chan.clone()), @@ -155,6 +153,8 @@ impl RenderTask { if self.paint_permission { self.epoch.next(); self.compositor.set_layer_page_size(self.id, render_layer.size, self.epoch); + } else { + self.constellation_chan.send(RendererReadyMsg(self.id)); } self.render_layer = Some(render_layer); self.last_paint_msg = None; @@ -284,6 +284,8 @@ impl RenderTask { debug!("render_task: returning surface"); if self.paint_permission { self.compositor.paint(self.id, layer_buffer_set.clone(), self.epoch); + } else { + self.constellation_chan.send(RendererReadyMsg(self.id)); } debug!("caching paint msg"); self.last_paint_msg = Some(layer_buffer_set); diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index 23230ca1991..07b9601d641 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -201,20 +201,18 @@ impl NavigationContext { pub fn back(&mut self) -> @mut FrameTree { self.next.push(self.current.take_unwrap()); self.current = Some(self.previous.pop()); - debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref()); self.current.unwrap() } pub fn forward(&mut self) -> @mut FrameTree { self.previous.push(self.current.take_unwrap()); self.current = Some(self.next.pop()); - debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref()); self.current.unwrap() } /// Loads a new set of page frames, returning all evicted frame trees pub fn load(&mut self, frame_tree: @mut FrameTree) -> ~[@mut FrameTree] { - debug!("navigating to %?", frame_tree); + debug!("navigating to %?", frame_tree.pipeline.id); let evicted = replace(&mut self.next, ~[]); if self.current.is_some() { self.previous.push(self.current.take_unwrap()); @@ -554,7 +552,7 @@ impl Constellation { if url.path.ends_with(".js") { pipeline.execute(url); } else { - debug!("Constellation: sending load msg to %?", pipeline); + debug!("Constellation: sending load msg to pipeline %?", pipeline.id); pipeline.load(url); } let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id)); @@ -718,12 +716,11 @@ impl Constellation { // If to_add is not the root frame, then replace revoked_frame with it. // This conveniently keeps scissor rect size intact. - debug!("Constellation: replacing %? with %? in %?", revoke_id, to_add, next_frame_tree); + debug!("Constellation: replacing %? with %? in %?", + revoke_id, to_add.pipeline.id, next_frame_tree.pipeline.id); if to_add.parent.is_some() { - let replaced = next_frame_tree.replace_child(revoke_id, to_add); - debug!("Replaced child: %?", replaced); + next_frame_tree.replace_child(revoke_id, to_add); } - debug!("Constellation: frame tree after replacing: %?", next_frame_tree); } None => { diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs index 37e8b1eb41e..b90edc7e320 100644 --- a/src/components/main/pipeline.rs +++ b/src/components/main/pipeline.rs @@ -54,6 +54,7 @@ impl Pipeline { RenderTask::create(id, render_port, compositor_chan.clone(), + constellation_chan.clone(), opts.clone(), profiler_chan.clone()); @@ -136,6 +137,7 @@ impl Pipeline { RenderTask::create(id, render_port, compositor_chan.clone(), + constellation_chan.clone(), opts.clone(), profiler_chan.clone()); diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 01960196c81..8c800727657 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -21,7 +21,7 @@ use layout_interface::{ReflowDocumentDamage, ReflowForDisplay, ReflowGoal}; use layout_interface::ReflowMsg; use layout_interface; use servo_msg::constellation_msg::{ConstellationChan, LoadUrlMsg, NavigationDirection}; -use servo_msg::constellation_msg::{PipelineId, SubpageId, RendererReadyMsg}; +use servo_msg::constellation_msg::{PipelineId, SubpageId}; use servo_msg::constellation_msg::{LoadIframeUrlMsg, IFrameSandboxed, IFrameUnsandboxed}; use servo_msg::constellation_msg; @@ -582,7 +582,6 @@ impl ScriptTask { if page_tree.page.last_reflow_id == reflow_id { page_tree.page.layout_join_port = None; } - self.constellation_chan.send(RendererReadyMsg(pipeline_id)); self.compositor.set_ready_state(FinishedLoading); }