Add perfetto tracing events to fonts (#33436)

* trace fonts

Co-authored-by: Delan Azabani <dazabani@igalia.com>
Signed-off-by: atbrakhi <atbrakhi@igalia.com>

* review fix

Co-authored-by: Delan Azabani <dazabani@igalia.com>
Signed-off-by: atbrakhi <atbrakhi@igalia.com>

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
atbrakhi 2024-09-16 11:04:58 +02:00 committed by GitHub
parent b12cebd1ac
commit 236cae9ce5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 1 deletions

1
Cargo.lock generated
View file

@ -1914,6 +1914,7 @@ dependencies = [
"smallvec",
"style",
"surfman",
"tracing",
"truetype",
"unicode-bidi",
"unicode-properties",

View file

@ -41,6 +41,7 @@ servo_url = { path = "../url" }
smallvec = { workspace = true, features = ["union"] }
surfman = { workspace = true }
style = { workspace = true }
tracing = { workspace = true }
unicode-bidi = { workspace = true, features = ["with_serde"] }
unicode-properties = { workspace = true }
unicode-script = { workspace = true }

View file

@ -23,6 +23,7 @@ use style::values::computed::font::{
};
use style::values::computed::{FontStretch, FontWeight};
use style::values::specified::FontStretch as SpecifiedFontStretch;
use tracing::{span, Level};
use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey};
use webrender_traits::WebRenderFontApi;
@ -102,12 +103,19 @@ struct FontCache {
}
impl FontCache {
#[tracing::instrument(skip(self), fields(servo_profiling = true))]
fn run(&mut self) {
loop {
let msg = self.port.recv().unwrap();
match msg {
Command::GetFontTemplates(descriptor_to_match, font_family, result) => {
let span = span!(
Level::TRACE,
"Command::GetFontTemplates",
servo_profiling = true
);
let _span = span.enter();
let templates =
self.find_font_templates(descriptor_to_match.as_ref(), &font_family);
debug!("Found templates for descriptor {descriptor_to_match:?}: ");
@ -141,6 +149,12 @@ impl FontCache {
.font_data
.entry(identifier)
.or_insert_with(|| font_template.data());
let span = span!(
Level::TRACE,
"GetFontTemplates send",
servo_profiling = true
);
let _span = span.enter();
let _ = bytes_sender.send(data);
}
},
@ -186,6 +200,7 @@ impl FontCache {
});
}
#[tracing::instrument(skip(self), fields(servo_profiling = true))]
fn find_font_templates(
&mut self,
descriptor_to_match: Option<&FontDescriptor>,

View file

@ -89,6 +89,7 @@ use surfman::platform::generic::multi::context::NativeContext as LinuxNativeCont
use surfman::{GLApi, GLVersion};
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
use surfman::{NativeConnection, NativeContext};
use tracing::{span, Level};
use webgpu::swapchain::WGPUImageMap;
use webrender::{RenderApiSender, ShaderPrecacheFlags, UploadMethod, ONE_TIME_USAGE_HINT};
use webrender_api::{
@ -1105,6 +1106,7 @@ impl WebRenderFontApi for WebRenderFontApiCompositorProxy {
receiver.recv().unwrap()
}
#[tracing::instrument(skip(self), fields(servo_profiling = true))]
fn add_font(&self, data: Arc<Vec<u8>>, index: u32) -> FontKey {
let (sender, receiver) = unbounded();
let (bytes_sender, bytes_receiver) =
@ -1113,7 +1115,11 @@ impl WebRenderFontApi for WebRenderFontApiCompositorProxy {
.send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
FontToCompositorMsg::AddFont(sender, index, bytes_receiver),
)));
let _ = bytes_sender.send(&data);
{
let span = span!(Level::TRACE, "add_font send", servo_profiling = true);
let _span = span.enter();
let _ = bytes_sender.send(&data);
}
receiver.recv().unwrap()
}