servo: Merge #11607 - Remove the layout and paint shutdown channels (from Ms2ger:shutdown-channels); r=asajeffrey
authorMs2ger <Ms2ger@gmail.com>
Sat, 04 Jun 2016 14:24:56 -0500
changeset 339011 d9dfc1f50f3ac6930c51cd63d1f0cba06c6fcd1b
parent 339010 7c15ae711040ee9f246187da23f45b7e4738396a
child 339012 34a33f786aab45eeda4aaf63773a072c2700cd9b
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasajeffrey
servo: Merge #11607 - Remove the layout and paint shutdown channels (from Ms2ger:shutdown-channels); r=asajeffrey Source-Repo: https://github.com/servo/servo Source-Revision: 80a58cadc5f864bfb44671e2e7228d7c6cdf4ab4
servo/components/constellation/pipeline.rs
servo/components/gfx/paint_thread.rs
servo/components/layout/layout_thread.rs
servo/components/layout_traits/lib.rs
servo/components/script/layout_interface.rs
servo/components/script/script_thread.rs
servo/components/script_traits/lib.rs
--- a/servo/components/constellation/pipeline.rs
+++ b/servo/components/constellation/pipeline.rs
@@ -50,18 +50,16 @@ pub struct Pipeline {
     pub id: PipelineId,
     pub parent_info: Option<(PipelineId, SubpageId, FrameType)>,
     pub script_chan: IpcSender<ConstellationControlMsg>,
     /// A channel to layout, for performing reflows and shutdown.
     pub layout_chan: IpcSender<LayoutControlMsg>,
     /// A channel to the compositor.
     pub compositor_proxy: Box<CompositorProxy + 'static + Send>,
     pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
-    pub layout_shutdown_port: IpcReceiver<()>,
-    pub paint_shutdown_port: IpcReceiver<()>,
     /// URL corresponding to the most recently-loaded page.
     pub url: Url,
     /// The title of the most recently-loaded page.
     pub title: Option<String>,
     pub size: Option<TypedSize2D<PagePx, f32>>,
     /// Whether this pipeline is currently running animations. Pipelines that are running
     /// animations cause composites to be continually scheduled.
     pub running_animations: bool,
@@ -125,20 +123,16 @@ impl Pipeline {
                                     -> Result<(Pipeline, Option<ChildProcess>), IOError>
         where LTF: LayoutThreadFactory<Message=Message>,
               STF: ScriptThreadFactory<Message=Message>
     {
         // Note: we allow channel creation to panic, since recovering from this
         // probably requires a general low-memory strategy.
         let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel();
         let (chrome_to_paint_chan, chrome_to_paint_port) = channel();
-        let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel()
-            .expect("Pipeline paint shutdown chan");
-        let (layout_shutdown_chan, layout_shutdown_port) = ipc::channel()
-            .expect("Pipeline layout shutdown chan");
         let (pipeline_chan, pipeline_port) = ipc::channel()
             .expect("Pipeline main chan");;
 
         let (layout_content_process_shutdown_chan, layout_content_process_shutdown_port) =
             ipc::channel().expect("Pipeline layout content shutdown chan");
 
         let (script_chan, content_ports) = match state.script_chan {
             Some(script_chan) => {
@@ -148,17 +142,16 @@ impl Pipeline {
                     containing_pipeline_id: containing_pipeline_id,
                     new_pipeline_id: state.id,
                     subpage_id: subpage_id,
                     load_data: state.load_data.clone(),
                     paint_chan: layout_to_paint_chan.clone().to_opaque(),
                     panic_chan: state.panic_chan.clone(),
                     pipeline_port: pipeline_port,
                     layout_to_constellation_chan: state.layout_to_constellation_chan.clone(),
-                    layout_shutdown_chan: layout_shutdown_chan.clone(),
                     content_process_shutdown_chan: layout_content_process_shutdown_chan.clone(),
                 };
 
                 if let Err(e) = script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info)) {
                     warn!("Sending to script during pipeline creation failed ({})", e);
                 }
                 (script_chan, None)
             }
@@ -172,18 +165,17 @@ impl Pipeline {
                             state.load_data.url.clone(),
                             chrome_to_paint_chan.clone(),
                             layout_to_paint_port,
                             chrome_to_paint_port,
                             state.compositor_proxy.clone_compositor_proxy(),
                             state.panic_chan.clone(),
                             state.font_cache_thread.clone(),
                             state.time_profiler_chan.clone(),
-                            state.mem_profiler_chan.clone(),
-                            paint_shutdown_chan);
+                            state.mem_profiler_chan.clone());
 
         let mut child_process = None;
         if let Some((script_port, pipeline_port)) = content_ports {
             // Route messages coming from content to devtools as appropriate.
             let script_to_devtools_chan = state.devtools_chan.as_ref().map(|devtools_chan| {
                 let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel()
                     .expect("Pipeline script to devtools chan");
                 let devtools_chan = (*devtools_chan).clone();
@@ -227,17 +219,16 @@ impl Pipeline {
                 script_chan: script_chan.clone(),
                 load_data: state.load_data.clone(),
                 panic_chan: state.panic_chan,
                 script_port: script_port,
                 opts: (*opts::get()).clone(),
                 prefs: prefs::get_cloned(),
                 layout_to_paint_chan: layout_to_paint_chan,
                 pipeline_port: pipeline_port,
-                layout_shutdown_chan: layout_shutdown_chan,
                 pipeline_namespace_id: state.pipeline_namespace_id,
                 layout_content_process_shutdown_chan: layout_content_process_shutdown_chan,
                 layout_content_process_shutdown_port: layout_content_process_shutdown_port,
                 script_content_process_shutdown_chan: script_content_process_shutdown_chan,
                 script_content_process_shutdown_port: script_content_process_shutdown_port,
                 webrender_api_sender: state.webrender_api_sender,
             };
 
@@ -252,44 +243,38 @@ impl Pipeline {
         }
 
         let pipeline = Pipeline::new(state.id,
                                      state.parent_info,
                                      script_chan,
                                      pipeline_chan,
                                      state.compositor_proxy,
                                      chrome_to_paint_chan,
-                                     layout_shutdown_port,
-                                     paint_shutdown_port,
                                      state.load_data.url,
                                      state.window_size);
 
         Ok((pipeline, child_process))
     }
 
     fn new(id: PipelineId,
            parent_info: Option<(PipelineId, SubpageId, FrameType)>,
            script_chan: IpcSender<ConstellationControlMsg>,
            layout_chan: IpcSender<LayoutControlMsg>,
            compositor_proxy: Box<CompositorProxy + 'static + Send>,
            chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
-           layout_shutdown_port: IpcReceiver<()>,
-           paint_shutdown_port: IpcReceiver<()>,
            url: Url,
            size: Option<TypedSize2D<PagePx, f32>>)
            -> Pipeline {
         Pipeline {
             id: id,
             parent_info: parent_info,
             script_chan: script_chan,
             layout_chan: layout_chan,
             compositor_proxy: compositor_proxy,
             chrome_to_paint_chan: chrome_to_paint_chan,
-            layout_shutdown_port: layout_shutdown_port,
-            paint_shutdown_port: paint_shutdown_port,
             url: url,
             title: None,
             children: vec!(),
             size: size,
             running_animations: false,
             is_private: false,
         }
     }
@@ -402,17 +387,16 @@ pub struct UnprivilegedPipelineContent {
     load_data: LoadData,
     panic_chan: IpcSender<PanicMsg>,
     script_port: IpcReceiver<ConstellationControlMsg>,
     layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
     opts: Opts,
     prefs: HashMap<String, Pref>,
     pipeline_port: IpcReceiver<LayoutControlMsg>,
     pipeline_namespace_id: PipelineNamespaceId,
-    layout_shutdown_chan: IpcSender<()>,
     layout_content_process_shutdown_chan: IpcSender<()>,
     layout_content_process_shutdown_port: IpcReceiver<()>,
     script_content_process_shutdown_chan: IpcSender<()>,
     script_content_process_shutdown_port: IpcReceiver<()>,
     webrender_api_sender: Option<webrender_traits::RenderApiSender>,
 }
 
 impl UnprivilegedPipelineContent {
@@ -447,17 +431,16 @@ impl UnprivilegedPipelineContent {
                     self.layout_to_constellation_chan,
                     self.panic_chan,
                     self.script_chan,
                     self.layout_to_paint_chan,
                     self.image_cache_thread,
                     self.font_cache_thread,
                     self.time_profiler_chan,
                     self.mem_profiler_chan,
-                    self.layout_shutdown_chan,
                     self.layout_content_process_shutdown_chan,
                     self.webrender_api_sender);
 
         if wait_for_completion {
             let _ = self.script_content_process_shutdown_port.recv();
             let _ = self.layout_content_process_shutdown_port.recv();
         }
     }
--- a/servo/components/gfx/paint_thread.rs
+++ b/servo/components/gfx/paint_thread.rs
@@ -391,56 +391,48 @@ impl<C> PaintThread<C> where C: PaintLis
                   url: Url,
                   chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
                   layout_to_paint_port: Receiver<LayoutToPaintMsg>,
                   chrome_to_paint_port: Receiver<ChromeToPaintMsg>,
                   mut compositor: C,
                   panic_chan: IpcSender<PanicMsg>,
                   font_cache_thread: FontCacheThread,
                   time_profiler_chan: time::ProfilerChan,
-                  mem_profiler_chan: mem::ProfilerChan,
-                  shutdown_chan: IpcSender<()>) {
+                  mem_profiler_chan: mem::ProfilerChan) {
         thread::spawn_named_with_send_on_panic(format!("PaintThread {:?}", id),
                                                thread_state::PAINT,
                                                move || {
-            {
-                // Ensures that the paint thread and graphics context are destroyed before the
-                // shutdown message.
-                let native_display = compositor.native_display();
-                let worker_threads = WorkerThreadProxy::spawn(native_display,
-                                                              font_cache_thread,
-                                                              time_profiler_chan.clone());
+            let native_display = compositor.native_display();
+            let worker_threads = WorkerThreadProxy::spawn(native_display,
+                                                          font_cache_thread,
+                                                          time_profiler_chan.clone());
 
-                let mut paint_thread = PaintThread {
-                    id: id,
-                    _url: url,
-                    layout_to_paint_port: layout_to_paint_port,
-                    chrome_to_paint_port: chrome_to_paint_port,
-                    compositor: compositor,
-                    time_profiler_chan: time_profiler_chan,
-                    root_display_list: None,
-                    layer_map: HashMap::new(),
-                    paint_permission: false,
-                    current_epoch: None,
-                    worker_threads: worker_threads,
-                };
+            let mut paint_thread = PaintThread {
+                id: id,
+                _url: url,
+                layout_to_paint_port: layout_to_paint_port,
+                chrome_to_paint_port: chrome_to_paint_port,
+                compositor: compositor,
+                time_profiler_chan: time_profiler_chan,
+                root_display_list: None,
+                layer_map: HashMap::new(),
+                paint_permission: false,
+                current_epoch: None,
+                worker_threads: worker_threads,
+            };
 
-                let reporter_name = format!("paint-reporter-{}", id);
-                mem_profiler_chan.run_with_memory_reporting(|| {
-                    paint_thread.start();
-                }, reporter_name, chrome_to_paint_chan, ChromeToPaintMsg::CollectReports);
+            let reporter_name = format!("paint-reporter-{}", id);
+            mem_profiler_chan.run_with_memory_reporting(|| {
+                paint_thread.start();
+            }, reporter_name, chrome_to_paint_chan, ChromeToPaintMsg::CollectReports);
 
-                // Tell all the worker threads to shut down.
-                for worker_thread in &mut paint_thread.worker_threads {
-                    worker_thread.exit()
-                }
+            // Tell all the worker threads to shut down.
+            for worker_thread in &mut paint_thread.worker_threads {
+                worker_thread.exit()
             }
-
-            debug!("paint_thread: shutdown_chan send");
-            let _ = shutdown_chan.send(());
         }, Some(id), panic_chan);
     }
 
     #[allow(unsafe_code)]
     fn start(&mut self) {
         debug!("PaintThread: beginning painting loop");
 
         loop {
--- a/servo/components/layout/layout_thread.rs
+++ b/servo/components/layout/layout_thread.rs
@@ -254,17 +254,16 @@ impl LayoutThreadFactory for LayoutThrea
               constellation_chan: IpcSender<ConstellationMsg>,
               panic_chan: IpcSender<PanicMsg>,
               script_chan: IpcSender<ConstellationControlMsg>,
               paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
               image_cache_thread: ImageCacheThread,
               font_cache_thread: FontCacheThread,
               time_profiler_chan: time::ProfilerChan,
               mem_profiler_chan: mem::ProfilerChan,
-              shutdown_chan: IpcSender<()>,
               content_process_shutdown_chan: IpcSender<()>,
               webrender_api_sender: Option<webrender_traits::RenderApiSender>) {
         thread::spawn_named_with_send_on_panic(format!("LayoutThread {:?}", id),
                                                thread_state::LAYOUT,
                                                move || {
             { // Ensures layout thread is destroyed before we send shutdown message
                 let sender = chan.0;
                 let layout = LayoutThread::new(id,
@@ -281,17 +280,16 @@ impl LayoutThreadFactory for LayoutThrea
                                              mem_profiler_chan.clone(),
                                              webrender_api_sender);
 
                 let reporter_name = format!("layout-reporter-{}", id);
                 mem_profiler_chan.run_with_memory_reporting(|| {
                     layout.start();
                 }, reporter_name, sender, Msg::CollectReports);
             }
-            let _ = shutdown_chan.send(());
             let _ = content_process_shutdown_chan.send(());
         }, Some(id), panic_chan);
     }
 }
 
 /// The `LayoutThread` `rw_data` lock must remain locked until the first reflow,
 /// as RPC calls don't make sense until then. Use this in combination with
 /// `LayoutThread::lock_rw_data` and `LayoutThread::return_rw_data`.
@@ -743,17 +741,16 @@ impl LayoutThread {
                              info.constellation_chan,
                              info.panic_chan,
                              info.script_chan.clone(),
                              info.paint_chan.to::<LayoutToPaintMsg>(),
                              self.image_cache_thread.clone(),
                              self.font_cache_thread.clone(),
                              self.time_profiler_chan.clone(),
                              self.mem_profiler_chan.clone(),
-                             info.layout_shutdown_chan,
                              info.content_process_shutdown_chan,
                              self.webrender_api.as_ref().map(|wr| wr.clone_sender()));
     }
 
     /// Enters a quiescent state in which no new messages will be processed until an `ExitNow` is
     /// received. A pong is immediately sent on the given response channel.
     fn prepare_to_exit(&mut self, response_chan: Sender<()>) {
         response_chan.send(()).unwrap();
--- a/servo/components/layout_traits/lib.rs
+++ b/servo/components/layout_traits/lib.rs
@@ -43,12 +43,11 @@ pub trait LayoutThreadFactory {
               constellation_chan: IpcSender<ConstellationMsg>,
               panic_chan: IpcSender<PanicMsg>,
               script_chan: IpcSender<ConstellationControlMsg>,
               layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
               image_cache_thread: ImageCacheThread,
               font_cache_thread: FontCacheThread,
               time_profiler_chan: time::ProfilerChan,
               mem_profiler_chan: mem::ProfilerChan,
-              shutdown_chan: IpcSender<()>,
               content_process_shutdown_chan: IpcSender<()>,
               webrender_api_sender: Option<webrender_traits::RenderApiSender>);
 }
--- a/servo/components/script/layout_interface.rs
+++ b/servo/components/script/layout_interface.rs
@@ -227,11 +227,10 @@ pub struct NewLayoutThreadInfo {
     pub is_parent: bool,
     pub layout_pair: (Sender<Msg>, Receiver<Msg>),
     pub pipeline_port: IpcReceiver<LayoutControlMsg>,
     pub constellation_chan: IpcSender<ConstellationMsg>,
     pub panic_chan: IpcSender<PanicMsg>,
     pub script_chan: IpcSender<ConstellationControlMsg>,
     pub image_cache_thread: ImageCacheThread,
     pub paint_chan: OptionalOpaqueIpcSender,
-    pub layout_shutdown_chan: IpcSender<()>,
     pub content_process_shutdown_chan: IpcSender<()>,
 }
--- a/servo/components/script/script_thread.rs
+++ b/servo/components/script/script_thread.rs
@@ -1124,17 +1124,16 @@ impl ScriptThread {
             containing_pipeline_id,
             new_pipeline_id,
             subpage_id,
             load_data,
             paint_chan,
             panic_chan,
             pipeline_port,
             layout_to_constellation_chan,
-            layout_shutdown_chan,
             content_process_shutdown_chan,
         } = new_layout_info;
 
         let layout_pair = channel();
         let layout_chan = layout_pair.0.clone();
 
         let layout_creation_info = NewLayoutThreadInfo {
             id: new_pipeline_id,
@@ -1142,17 +1141,16 @@ impl ScriptThread {
             is_parent: false,
             layout_pair: layout_pair,
             pipeline_port: pipeline_port,
             constellation_chan: layout_to_constellation_chan,
             panic_chan: panic_chan,
             paint_chan: paint_chan,
             script_chan: self.control_chan.clone(),
             image_cache_thread: self.image_cache_thread.clone(),
-            layout_shutdown_chan: layout_shutdown_chan,
             content_process_shutdown_chan: content_process_shutdown_chan,
         };
 
         let context = self.root_browsing_context();
         let parent_context = context.find(containing_pipeline_id).expect("ScriptThread: received a layout
             whose parent has a PipelineId which does not correspond to a pipeline in the script
             thread's browsing context tree. This is a bug.");
         let parent_window = parent_context.active_window();
--- a/servo/components/script_traits/lib.rs
+++ b/servo/components/script_traits/lib.rs
@@ -99,18 +99,16 @@ pub struct NewLayoutInfo {
     /// `Sender<LayoutToPaintMsg>`.
     pub paint_chan: OptionalOpaqueIpcSender,
     /// A port on which layout can receive messages from the pipeline.
     pub pipeline_port: IpcReceiver<LayoutControlMsg>,
     /// A channel for sending panics on
     pub panic_chan: IpcSender<PanicMsg>,
     /// A sender for the layout thread to communicate to the constellation.
     pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
-    /// A shutdown channel so that layout can notify others when it's done.
-    pub layout_shutdown_chan: IpcSender<()>,
     /// A shutdown channel so that layout can tell the content process to shut down when it's done.
     pub content_process_shutdown_chan: IpcSender<()>,
 }
 
 /// Messages sent from the constellation or layout to the script thread.
 #[derive(Deserialize, Serialize)]
 pub enum ConstellationControlMsg {
     /// Gives a channel and ID to a layout thread, as well as the ID of that layout's parent