From 0d694b1fed62797d991eb34fd826027b3fdd7000 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 21 May 2016 01:52:20 +0200 Subject: [PATCH] Hoist channel creation out of loop in handle_is_ready_to_save_image --- components/constellation/constellation.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 239dbbc3fc3..27f48bec8eb 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1735,6 +1735,9 @@ impl Constellation return ReadyToSave::PendingFrames; } + let (state_sender, state_receiver) = ipc::channel().expect("Failed to create IPC channel!"); + let (epoch_sender, epoch_receiver) = ipc::channel().expect("Failed to create IPC channel!"); + // Step through the current frame tree, checking that the script // thread is idle, and that the current epoch of the layout thread // matches what the compositor has painted. If all these conditions @@ -1757,12 +1760,11 @@ impl Constellation // before we check whether the document is ready; otherwise, // there's a race condition where a webfont has finished loading, // but hasn't yet notified the document. - let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!"); - let msg = LayoutControlMsg::GetWebFontLoadState(sender); + let msg = LayoutControlMsg::GetWebFontLoadState(state_sender.clone()); if let Err(e) = pipeline.layout_chan.0.send(msg) { warn!("Get web font failed ({})", e); } - if receiver.recv().unwrap_or(true) { + if state_receiver.recv().unwrap_or(true) { return ReadyToSave::WebFontNotLoaded; } @@ -1794,12 +1796,11 @@ impl Constellation // epoch matches what the compositor has drawn. If they match // (and script is idle) then this pipeline won't change again // and can be considered stable. - let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!"); let LayoutControlChan(ref layout_chan) = pipeline.layout_chan; - if let Err(e) = layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)) { + if let Err(e) = layout_chan.send(LayoutControlMsg::GetCurrentEpoch(epoch_sender.clone())) { warn!("Failed to send GetCurrentEpoch ({}).", e); } - match receiver.recv() { + match epoch_receiver.recv() { Err(e) => warn!("Failed to receive current epoch ({}).", e), Ok(layout_thread_epoch) => if layout_thread_epoch != *compositor_epoch { return ReadyToSave::EpochMismatch;