mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #11313 - nox:channel-loop, r=mbrubeck
Hoist channel creation out of loop in handle_is_ready_to_save_image <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11313) <!-- Reviewable:end -->
This commit is contained in:
commit
eeea481a12
1 changed files with 7 additions and 6 deletions
|
@ -1735,6 +1735,9 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
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<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
// 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<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
// 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue