nsMathMLContainerFrame should cache its intrinsic width

RESOLVED FIXED in Firefox 39

Status

()

defect
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: roc, Assigned: roc)

Tracking

Trunk
mozilla39
x86_64
Linux
Points:
---

Firefox Tracking Flags

(firefox39 fixed)

Details

Attachments

(3 attachments)

Posted file inch.zip
Someone sent me a test page full of MathML which renders incredibly slowly in Firefox. I'm attaching a version of it which takes 68s to render for me on trunk.

We spend the majority of the time in nsMathMLContainerFrame::GetMinISize/GetPrefISize --- which actually compute the same thing. We should cache the intrinsic width, which will cut that time in half by sharing the results between GetMinISize/GetPrefISize, and probably by more since we can also reuse intrinsic widths across reflows.

There is a risk that dynamic changes to MathML could break if intrinsic widths are not currently invalidated correctly. However, nsMathMLContainerFrame is currently very conservative and invalidates intrinsic widths on any AttributeChanged. Also, wherever MathML fails to invalidate intrinsic widths is already a bug since inline MathML contributes to the cached intrinsic widths of non-MathML containers.
For me, this reduces the load time of the testcase in bug 1139709 from
68s to 34s.
Now this page spends > 50% of its load time in nsMathMLChar::GetMaxWidth. A global stretchy-char-max-width cache would probably make this a lot faster. However, it's slightly tricky to implement and probably isn't worth implementing right now.
Comment on attachment 8572968 [details] [diff] [review]
Cache nsMathMLContainerFrame's intrinsic width

r=mats

>layout/mathml/nsMathMLContainerFrame.cpp
> ...::UpdateIntrinsicWidth(nsRenderingContext *aRenderingContext)

Perhaps you could change GetMinISize, GetPrefISize to use the more
common code style "nsRenderingContext* " instead?

Would be nice, since it's the last instances in this file, AFAICT.
Attachment #8572968 - Flags: review?(mats) → review+
Comment on attachment 8572970 [details] [diff] [review]
Remove unused parameters from nsMathMLChar::GetMaxWidth

r=mats, same nsRenderingContext* comment here.
Attachment #8572970 - Flags: review?(mats) → review+
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #3)
> Now this page spends > 50% of its load time in nsMathMLChar::GetMaxWidth. A
> global stretchy-char-max-width cache would probably make this a lot faster.
> However, it's slightly tricky to implement and probably isn't worth
> implementing right now.

In general, nsMathMLChar is not very efficient at the moment. See also bug 1009582.
Depends on: 1141252
No longer depends on: 1141252
You need to log in before you can comment on or make changes to this bug.