Closed Bug 1680420 Opened 5 years ago Closed 5 years ago

Too much time spent instantiating fonts on WRWorker threads (causes scrolling latency on Facebook)

Categories

(Core :: Graphics: WebRender, defect)

All
macOS
defect

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: mstange, Assigned: lsalzman)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files)

Attached image Instruments screenshot

Profile from scrolling on Facebook: https://share.firefox.dev/37u6r7h

On Facebook, when performing a sequence of fast-scroll, pause, fast-scroll, pause, the scrolling has a high latency (>100ms). Profiling reveals that this latency is because WR frame building is blocking on font rasterization.

The profile above is unfortunately missing symbols for system libraries.

I'm attaching a screenshot from an Instruments profile to make up for it. The breakdown in Instruments is as follows:

  • 57% TBaseFont::GetSymbolicTraits
  • 21% CTFontCreateWithGraphicsFont called from core_text::font::new_from_CGFont_with_variations
  • 9% CTFontCreateWithGraphicsFont called from process_glyph directly
  • 7% CTFontCopyVariationAxes
  • 3% CTFontDrawGlyphs
  • 2% CTFontGetBoundingRectsForGlyphs
  • 1% CTFontGetAdvancesForGlyphs

It seems that we could get rid of 95% here if we held on to certain font objects for longer.

Could this be the same probem as with Matrix/Elements when trying to use an Emoji in a message? When clicking the smiley to open the emoji popup it takes more than a second to display the emojis on Apple. Note that the file is around 240MB in size.

Looks like the issue with Elements doesn't always happen. I will keep an eye and file a new bug if it's not related to that specific behavior.

I see similar slowness when switching between github tabs: https://share.firefox.dev/3qtYLdI

Blocks: gfx-triage
Severity: -- → S4
Flags: needinfo?(lsalzman)

GetSymbolicTraits is called by is_bitmap_font() for every glyph. We should do it once per font.

Assignee: nobody → lsalzman
Status: NEW → ASSIGNED
Flags: needinfo?(lsalzman)
Pushed by lsalzman@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4d24f069ddd9 cache CTFontSymbolicTraits in WR CT fonts. r=jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
No longer blocks: gfx-triage
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: