Closed
Bug 1054161
Opened 10 years ago
Closed 10 years ago
Avoid building nsDisplayText when text is transparent
Categories
(Core :: Layout, defect)
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: roc, Assigned: roc)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [MemShrink:P2])
Attachments
(2 files)
966 bytes,
patch
|
n.nethercote
:
feedback+
|
Details | Diff | Splinter Review |
1.22 KB,
patch
|
dbaron
:
review+
|
Details | Diff | Splinter Review |
Apparently this will help pdf.js a good bit. There's a text overlay which can contain a lot of very small text blocks (1 character each), each positioned and CSS transformed, all color:transparent. In nsTextFrame::BuildDisplayList, if the color's alpha value is 0, the text is not selected, there are no shadows, and no text decorations, we can skip building the nsDisplayText. Then we will avoid building an nsDisplayTransform wrapping it, and the inactive layer for that.
Assignee | ||
Comment 1•10 years ago
|
||
Assignee | ||
Comment 2•10 years ago
|
||
Comment on attachment 8473502 [details] [diff] [review] patch Review of attachment 8473502 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/generic/nsTextFrame.cpp @@ +4567,5 @@ > return; > > DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame"); > > + if (NS_GET_A(GetVisitedDependentColor(eCSSProperty_color)) == 0 && Before this NS_GET_A call, insert "NS_GET_A(StyleColor()->mColor) == 0 &&" for more efficiency.
That's actually all you need, since visitedness never changes the alpha; we always use the alpha component from the unvisited style.
Comment 4•10 years ago
|
||
Comment on attachment 8473502 [details] [diff] [review] patch Review of attachment 8473502 [details] [diff] [review]: ----------------------------------------------------------------- I tried the patch (with the suggested edit) and it definitely improved the scrolling of the PDF at https://github.com/mozilla/pdf.js/issues/1045 -- made it smoother and less laggy.
Attachment #8473502 -
Flags: feedback+
Comment 5•10 years ago
|
||
I also tried measuring peak RSS while loading https://github.com/mozilla/pdf.js/issues/2541. Without the patch, it was ~700 MiB. With the patch it was ~530 MiB. Nice!
Comment 6•10 years ago
|
||
I did an about:memory diff to see exactly what accounted for the difference in memory usage. It showed up mostly as "heap-unclassified", with a bit of "heap-overhead" as well. So I did some DMD runs and the "heap-unclassified" is all from the FrameLayerBuilder -- see bug 1054321.
Updated•10 years ago
|
Whiteboard: [MemShrink]
Updated•10 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P2]
Comment 7•10 years ago
|
||
roc: is anything else needed to land this? You can see from the blocking bugs that there are lots of cases where this will help pdf.js performance greatly.
Updated•10 years ago
|
Flags: needinfo?(roc)
Assignee | ||
Comment 8•10 years ago
|
||
Attachment #8476482 -
Flags: review?(dbaron)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → roc
Status: NEW → ASSIGNED
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(roc)
Attachment #8476482 -
Flags: review?(dbaron) → review+
Comment 9•10 years ago
|
||
Comment on attachment 8476482 [details] [diff] [review] Don't build display items for text with alph Review of attachment 8476482 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/generic/nsTextFrame.cpp @@ +4580,5 @@ > > DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame"); > > + if (NS_GET_A(StyleColor()->mColor) == 0 && > + !IsSVGText() && !IsSelected() && !StyleText()->HasTextShadow()) { Would a short comment explaining the motivation be useful? E.g. "pdf.js generates lots of transparent text divs, so optimize that case."
Assignee | ||
Comment 10•10 years ago
|
||
Maybe, but I didn't... https://hg.mozilla.org/integration/mozilla-inbound/rev/bbfc46e60d79
https://hg.mozilla.org/mozilla-central/rev/bbfc46e60d79
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in
before you can comment on or make changes to this bug.
Description
•