Commit 3638eaae authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add trace events to investigate pathological fonts loading

This CL is adding trace events to look closer on some slow cases
happening in the browser process. Traces will be collected via
slow-reports and an investigation will be continued based on results of
these events.

R=fdoray@chromium.org, ccameron@chromium.org

Bug: 894459
Change-Id: I2e3c37e9a42ceef9ca9aea5ec94a125db247aa77
Reviewed-on: https://chromium-review.googlesource.com/c/1277825
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599205}
parent 03b4fcd9
...@@ -1786,7 +1786,6 @@ void RenderTextHarfBuzz::ShapeRuns( ...@@ -1786,7 +1786,6 @@ void RenderTextHarfBuzz::ShapeRuns(
TRACE_EVENT1("ui", "RenderTextHarfBuzz::ShapeRuns", "run_count", runs.size()); TRACE_EVENT1("ui", "RenderTextHarfBuzz::ShapeRuns", "run_count", runs.size());
const Font& primary_font = font_list().GetPrimaryFont(); const Font& primary_font = font_list().GetPrimaryFont();
Font best_font(primary_font);
for (const Font& font : font_list().GetFonts()) { for (const Font& font : font_list().GetFonts()) {
internal::TextRunHarfBuzz::FontParams test_font_params = font_params; internal::TextRunHarfBuzz::FontParams test_font_params = font_params;
...@@ -1816,33 +1815,40 @@ void RenderTextHarfBuzz::ShapeRuns( ...@@ -1816,33 +1815,40 @@ void RenderTextHarfBuzz::ShapeRuns(
} }
#endif #endif
std::vector<Font> fallback_font_list = GetFallbackFonts(primary_font); std::vector<Font> fallback_font_list;
{
TRACE_EVENT0("ui", "RenderTextHarfBuzz::GetFallbackFonts");
fallback_font_list = GetFallbackFonts(primary_font);
#if defined(OS_WIN) #if defined(OS_WIN)
// Append fonts in the fallback list of the preferred fallback font. // Append fonts in the fallback list of the preferred fallback font.
// TODO(tapted): Investigate whether there's a case that benefits from this on // TODO(tapted): Investigate whether there's a case that benefits from this
// Mac. // on Mac.
if (!preferred_fallback_family.empty()) { if (!preferred_fallback_family.empty()) {
std::vector<Font> fallback_fonts = GetFallbackFonts(fallback_font); std::vector<Font> fallback_fonts = GetFallbackFonts(fallback_font);
fallback_font_list.insert(fallback_font_list.end(), fallback_fonts.begin(), fallback_font_list.insert(fallback_font_list.end(),
fallback_fonts.end()); fallback_fonts.begin(), fallback_fonts.end());
} }
// Add Segoe UI and its associated linked fonts to the fallback font list to // Add Segoe UI and its associated linked fonts to the fallback font list to
// ensure that the fallback list covers the basic cases. // ensure that the fallback list covers the basic cases.
// http://crbug.com/467459. On some Windows configurations the default font // http://crbug.com/467459. On some Windows configurations the default font
// could be a raster font like System, which would not give us a reasonable // could be a raster font like System, which would not give us a reasonable
// fallback font list. // fallback font list.
if (!base::LowerCaseEqualsASCII(primary_font.GetFontName(), "segoe ui") && if (!base::LowerCaseEqualsASCII(primary_font.GetFontName(), "segoe ui") &&
!base::LowerCaseEqualsASCII(preferred_fallback_family, "segoe ui")) { !base::LowerCaseEqualsASCII(preferred_fallback_family, "segoe ui")) {
std::vector<Font> default_fallback_families = std::vector<Font> default_fallback_families =
GetFallbackFonts(Font("Segoe UI", 13)); GetFallbackFonts(Font("Segoe UI", 13));
fallback_font_list.insert(fallback_font_list.end(), fallback_font_list.insert(fallback_font_list.end(),
default_fallback_families.begin(), default_fallback_families.end()); default_fallback_families.begin(),
} default_fallback_families.end());
}
#endif #endif
}
// Use a set to track the fallback fonts and avoid duplicate entries. // Use a set to track the fallback fonts and avoid duplicate entries.
TRACE_EVENT1("ui", "RenderTextHarfBuzz::ShapeRunsWithFallbackFonts",
"fonts_count", fallback_font_list.size());
std::set<Font, CaseInsensitiveCompare> fallback_fonts; std::set<Font, CaseInsensitiveCompare> fallback_fonts;
// Try shaping with the fallback fonts. // Try shaping with the fallback fonts.
...@@ -1865,8 +1871,12 @@ void RenderTextHarfBuzz::ShapeRuns( ...@@ -1865,8 +1871,12 @@ void RenderTextHarfBuzz::ShapeRuns(
if (test_font_params.SetFontAndRenderParams(font, fallback_render_params)) { if (test_font_params.SetFontAndRenderParams(font, fallback_render_params)) {
ShapeRunsWithFont(text, test_font_params, &runs); ShapeRunsWithFont(text, test_font_params, &runs);
} }
if (runs.empty()) if (runs.empty()) {
TRACE_EVENT_INSTANT1("ui", "RenderTextHarfBuzz::FallbackFont",
TRACE_EVENT_SCOPE_THREAD, "font_name",
TRACE_STR_COPY(font_name.c_str()));
return; return;
}
} }
for (internal::TextRunHarfBuzz*& run : runs) { for (internal::TextRunHarfBuzz*& run : runs) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment