Closed Bug 1652816 Opened 5 years ago Closed 5 years ago

Preload fonts only after DOMContentLoaded

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

RESOLVED WONTFIX

People

(Reporter: mayhemer, Assigned: mayhemer)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

There is a regression on a cnn website. Comparing full logs in logan's network diagnostic overview suggested that we are preloading fonts too soon and delay DOMContentLoaded. This is an experiemntal bug to delay font preload to happen after DOMContentLoaded. It decreases the refgression significantly but doesn't affect firstPaint.

What is the regression we're trying to fix here? Which metric?

How do fonts block DOMContentLoaded?

Also, is this the DOMContentFlushed one? If so there's something with that metric that I need to investigate: https://bugzilla.mozilla.org/show_bug.cgi?id=1648003#c7

The metric that regresses is DOMContentLoaded. With preload turned on I'm locally able to reproduce it with browsertime on the cnn website. Looking at logs shows that we are loading the fonts too soon and the main thread (possibly both processes) flood and network utilization slow down the load and parsing of the main document, including sync script load and run. This fix lowers the regression significantly on that page. I don't understand the exact cause of the regression, the tools are not sufficient to find out. But experimentally this helps and doesn't lower time to first paint.

Part of the issue is that font loads being slow don't necessarily lower first paint. But they may show a flash of unstyled text, which is pretty ugly.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)

Part of the issue is that font loads being slow don't necessarily lower first paint. But they may show a flash of unstyled text, which is pretty ugly.

I know. I came to conclusion that the source of the regressions are fonts by specifically disabling only font preload. Wiggling with priorities and class-of-service didn't change anything, so timing to start the load was likely the problem. I gave a test build with this patch to acreskey for retesting, let's see how this will affect also other sites.

BTW, with unpatched preload on, the fonts don't load before the first paint anyway.

DOMContentLoaded timing isn't particularly important. I wonder how font loading affects to visual metrics.

Severity: -- → S4
Priority: -- → P3

It's hard for me to say whether this is the right change. You may have a large document that takes a while to download, and before it has finished downloading, you'll render the content you do have already. It would be better to render that with the correct font if possible. If preloading the font earlier means DOMContentLoaded is later, but the amount of content within the viewport isn't affected, then it seems like it's the right thing to do to minimize any time spent rendering that initial content with the wrong font. Unless the font download delays the viewport's content from downloading sooner.

This is all balancing the weight of the fonts and the HTML download and the user's network bandwidth. Focusing on the visual results of the change seems like the right thing to do.

According results from acreskey with this patch and comments on this bug we are not going to land this.

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: