Attempt to fix webfont-related intermittent test failures.

I'm not completely sure the race condition outlined in this patch is
actually the race condition causing failures... but it seems reasonable.
This commit is contained in:
Eli Friedman 2015-10-29 21:11:06 -07:00
parent 1dfc0481ef
commit 4f866625cc

View file

@ -1203,6 +1203,21 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
for frame in self.current_frame_tree_iter(self.root_frame_id) {
let pipeline = self.pipeline(frame.current);
// Check to see if there are any webfonts still loading.
//
// If GetWebFontLoadState returns false, either there are no
// webfonts loading, or there's a WebFontLoaded message waiting in
// script_chan's message queue. Therefore, we need to check this
// 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().unwrap();
let msg = LayoutControlMsg::GetWebFontLoadState(sender);
pipeline.layout_chan.0.send(msg).unwrap();
if receiver.recv().unwrap() {
return false;
}
// Synchronously query the script task for this pipeline
// to see if it is idle.
let (sender, receiver) = channel();
@ -1213,13 +1228,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
return false;
}
let (sender, receiver) = ipc::channel().unwrap();
let msg = LayoutControlMsg::GetWebFontLoadState(sender);
pipeline.layout_chan.0.send(msg).unwrap();
if receiver.recv().unwrap() {
return false;
}
// Check the visible rectangle for this pipeline. If the constellation has received a
// size for the pipeline, then its painting should be up to date. If the constellation
// *hasn't* received a size, it could be that the layer was hidden by script before the