mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #20106 - jdm:font-thread-shutdown-debug, r=emilio
Add font cache debugging to isolate cause of IPC failures in CI. This should help us better understand the actual underlying cause of frequent CI failures like #13509. In particular, we will be able to state with confidence whether an IPC message is being dropped while the font cache thread is still alive, or whether the dropped sender was in a message that was in the queue after the font cache thread was shutdown. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20106) <!-- Reviewable:end -->
This commit is contained in:
commit
267f9db314
1 changed files with 24 additions and 10 deletions
|
@ -112,6 +112,7 @@ pub enum Command {
|
||||||
AddWebFont(LowercaseString, EffectiveSources, IpcSender<()>),
|
AddWebFont(LowercaseString, EffectiveSources, IpcSender<()>),
|
||||||
AddDownloadedWebFont(LowercaseString, ServoUrl, Vec<u8>, IpcSender<()>),
|
AddDownloadedWebFont(LowercaseString, ServoUrl, Vec<u8>, IpcSender<()>),
|
||||||
Exit(IpcSender<()>),
|
Exit(IpcSender<()>),
|
||||||
|
Ping,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reply messages sent from the font cache thread to the FontContext caller.
|
/// Reply messages sent from the font cache thread to the FontContext caller.
|
||||||
|
@ -204,6 +205,7 @@ impl FontCache {
|
||||||
templates.add_template(Atom::from(url.to_string()), Some(bytes));
|
templates.add_template(Atom::from(url.to_string()), Some(bytes));
|
||||||
drop(result.send(()));
|
drop(result.send(()));
|
||||||
}
|
}
|
||||||
|
Command::Ping => (),
|
||||||
Command::Exit(result) => {
|
Command::Exit(result) => {
|
||||||
let _ = result.send(());
|
let _ = result.send(());
|
||||||
break;
|
break;
|
||||||
|
@ -472,10 +474,13 @@ impl FontSource for FontCacheThread {
|
||||||
self.chan.send(Command::GetFontInstance(key, size, response_chan))
|
self.chan.send(Command::GetFontInstance(key, size, response_chan))
|
||||||
.expect("failed to send message to font cache thread");
|
.expect("failed to send message to font cache thread");
|
||||||
|
|
||||||
let instance_key = response_port.recv()
|
let instance_key = response_port.recv();
|
||||||
.expect("failed to receive response to font request");
|
if instance_key.is_err() {
|
||||||
|
let font_thread_has_closed = self.chan.send(Command::Ping).is_err();
|
||||||
instance_key
|
assert!(font_thread_has_closed, "Failed to receive a response from live font cache");
|
||||||
|
panic!("Font cache thread has already exited.");
|
||||||
|
}
|
||||||
|
instance_key.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_font_template(&mut self, family: SingleFontFamily, desc: FontTemplateDescriptor)
|
fn find_font_template(&mut self, family: SingleFontFamily, desc: FontTemplateDescriptor)
|
||||||
|
@ -485,10 +490,15 @@ impl FontSource for FontCacheThread {
|
||||||
self.chan.send(Command::GetFontTemplate(family, desc, response_chan))
|
self.chan.send(Command::GetFontTemplate(family, desc, response_chan))
|
||||||
.expect("failed to send message to font cache thread");
|
.expect("failed to send message to font cache thread");
|
||||||
|
|
||||||
let reply = response_port.recv()
|
let reply = response_port.recv();
|
||||||
.expect("failed to receive response to font request");
|
|
||||||
|
|
||||||
match reply {
|
if reply.is_err() {
|
||||||
|
let font_thread_has_closed = self.chan.send(Command::Ping).is_err();
|
||||||
|
assert!(font_thread_has_closed, "Failed to receive a response from live font cache");
|
||||||
|
panic!("Font cache thread has already exited.");
|
||||||
|
}
|
||||||
|
|
||||||
|
match reply.unwrap() {
|
||||||
Reply::GetFontTemplateReply(data) => {
|
Reply::GetFontTemplateReply(data) => {
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
@ -502,10 +512,14 @@ impl FontSource for FontCacheThread {
|
||||||
self.chan.send(Command::GetLastResortFontTemplate(desc, response_chan))
|
self.chan.send(Command::GetLastResortFontTemplate(desc, response_chan))
|
||||||
.expect("failed to send message to font cache thread");
|
.expect("failed to send message to font cache thread");
|
||||||
|
|
||||||
let reply = response_port.recv()
|
let reply = response_port.recv();
|
||||||
.expect("failed to receive response to font request");
|
if reply.is_err() {
|
||||||
|
let font_thread_has_closed = self.chan.send(Command::Ping).is_err();
|
||||||
|
assert!(font_thread_has_closed, "Failed to receive a response from live font cache");
|
||||||
|
panic!("Font cache thread has already exited.");
|
||||||
|
}
|
||||||
|
|
||||||
match reply {
|
match reply.unwrap() {
|
||||||
Reply::GetFontTemplateReply(data) => {
|
Reply::GetFontTemplateReply(data) => {
|
||||||
data.unwrap()
|
data.unwrap()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue