Skip to content

Commit

Permalink
fix constellation being inundated with messages from script.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tim Kuehn committed Sep 20, 2013
1 parent 84d7317 commit 5f600f0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
24 changes: 13 additions & 11 deletions src/components/gfx/render_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ 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;
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};
Expand Down Expand Up @@ -86,6 +86,7 @@ struct RenderTask<C,T> {
id: PipelineId,
port: Port<Msg<T>>,
compositor: C,
constellation_chan: ConstellationChan,
font_ctx: @mut FontContext,
opts: Opts,

Expand All @@ -110,24 +111,21 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
pub fn create(id: PipelineId,
port: Port<Msg<T>>,
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()),
Expand Down Expand Up @@ -155,6 +153,8 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
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;
Expand Down Expand Up @@ -284,6 +284,8 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
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);
Expand Down
13 changes: 5 additions & 8 deletions src/components/main/constellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/main/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Pipeline {
RenderTask::create(id,
render_port,
compositor_chan.clone(),
constellation_chan.clone(),
opts.clone(),
profiler_chan.clone());

Expand Down Expand Up @@ -136,6 +137,7 @@ impl Pipeline {
RenderTask::create(id,
render_port,
compositor_chan.clone(),
constellation_chan.clone(),
opts.clone(),
profiler_chan.clone());

Expand Down
3 changes: 1 addition & 2 deletions src/components/script/script_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down

5 comments on commit 5f600f0

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from kmcallister
at tikue@5f600f0

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging tikue/servo/master = 5f600f0 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tikue/servo/master = 5f600f0 merged ok, testing candidate = e576a1c

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = e576a1c

Please sign in to comment.