You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Web fonts should only be loaded when content actually needs them #8342
This in particular makes cnn.com's page load times abysmal, since we have no prioritization or pooling for our network threads, and it ends up launching 356 simultaneous web font requests right after the stylesheets are parsed.
I think a reasonable solution would be to modify FontCache::handle_add_web_font to only store the font source information without starting any request. Then find_font_web_family will need to be updated to initiate a request if there is information about a font but it has not been requested before.
@jdm I just finished the parts where the font is downloaded when we call the find_font_in_web_family but I struggle a bit on how I could notify the layout to rebuild itself?
Activity
jdm commentedon May 17, 2016
This in particular makes cnn.com's page load times abysmal, since we have no prioritization or pooling for our network threads, and it ends up launching 356 simultaneous web font requests right after the stylesheets are parsed.
pcwalton commentedon May 17, 2016
Fascinating. Thanks for diving into this, @jdm!
charlesvdv commentedon Jun 24, 2017
Hi!
Since I finished my exams, I'm looking to contribute again to servo. Can I try to tackle this issue? 😄
jdm commentedon Jun 24, 2017
https://dxr.mozilla.org/servo/rev/a29261dec196ab5c887655e479e503ca6cbb9229/components/layout_thread/lib.rs#390-418 is the code that kicks off the font loads right now. It uses https://dxr.mozilla.org/servo/rev/a29261dec196ab5c887655e479e503ca6cbb9229/components/style/stylesheets/stylesheet.rs#337 to iterate over all of the effective rules in the stylesheet (which I'm pretty sure only means "rules that are not overridden by other rules").
I think a reasonable solution would be to modify FontCache::handle_add_web_font to only store the font source information without starting any request. Then
find_font_web_familywill need to be updated to initiate a request if there is information about a font but it has not been requested before.charlesvdv commentedon Jun 24, 2017
Thanks @jdm I will look into that !
charlesvdv commentedon Jun 27, 2017
@jdm I just finished the parts where the font is downloaded when we call the
find_font_in_web_familybut I struggle a bit on how I could notify the layout to rebuild itself?jdm commentedon Jun 27, 2017
@charlesvdv https://dxr.mozilla.org/servo/rev/4e8cf678bf12c1fa3400454905ae33dabff45bb5/components/layout_thread/lib.rs#634-640 is the code that handles that right now. The layout thread sends
font_cache_senderthe the font cache, and the font cache sends a message using that sender which the layout thread observes.Auto merge of #17545 - charlesvdv:lazy-font-loading, r=<try>