Testcase generating (and loading?) N dummy WOFF2 font is 50% slower to generate, and takes infinite time in cleanup.
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox147 | --- | fixed |
People
(Reporter: mayankleoboy1, Assigned: jfkthame)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
Open testcase
Click on start
Let the page generate and load the dummy fonts
Reload the page to do cleanup.
Firefox: https://share.firefox.dev/40ymNIm (12s to generate, infinite time in cleanup)
Chrome: https://share.firefox.dev/4omjEpx (8s to generate, does not do cleanup)
Very artificial. But maybe something easy to improve?
Comment 1•9 months ago
|
||
The severity field is not set for this bug.
:tlouw, could you have a look please?
For more information, please visit BugBot documentation.
Updated•9 months ago
|
| Reporter | ||
Comment 2•5 months ago
•
|
||
Testcase triggers long style/flushing thingy on theme cange: https://share.firefox.dev/3LYUkqD (90s+ in mozilla::dom::FontFaceSetDocumentImpl::InsertRuleFontFace)
Is that expected that theme change (which incluides change to the border color etc.) trigger such long restyle, when there is no element and the only thing added to the page is fonts?
This is the same scenario but with N=50000 : https://share.firefox.dev/4oceElI
| Assignee | ||
Comment 3•5 months ago
|
||
When we refresh the font set, FontFaceSetDocumentImpl::UpdateRules moves the existing mRuleFaces to a temporary oldRules array, and then builds the new mRuleFaces one by one, moving individual records across from oldRules as they're found. The problem arises if the array is large because we will generally be handling the rules in the same order as previously, which means we'll be pulling entries out of oldRules from the beginning of the array. That's expensive with a large array because all the following entries get shifted down.
A simple improvement, therefore, is to reverse the oldRules array, so that we'll be pulling entries from the end instead of the beginning. This avoids lots of array-element shifting as we're rebuilding the set.
(In theory, I guess an author could still hit the quadratically-bad case, but they'd have to not only have a very large number of rules, but then explicitly reverse their order, which seems a pretty unlikely scenario.)
| Assignee | ||
Comment 4•5 months ago
|
||
Updated•5 months ago
|
Comment 6•5 months ago
|
||
| bugherder | ||
| Reporter | ||
Comment 7•5 months ago
•
|
||
profile for generation: https://share.firefox.dev/4igxZ3Y (12s)
profile for theme change triggered restlye: https://share.firefox.dev/3KnNniq (2s) --> So this has definitely improved atleast 45x.
profile of cleanup: https://share.firefox.dev/3MlypKl (lots of time)
Updated•5 months ago
|
Description
•