Closed Bug 1139709 Opened 9 years ago Closed 9 years ago

nsMathMLContainerFrame should cache its intrinsic width

Categories

(Core :: MathML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: roc, Assigned: roc)

Details

Attachments

(3 files)

Attached 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.
No longer depends on: 1141252
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: