Closed Bug 908987 Opened 11 years ago Closed 9 years ago

NotifyDidPaintForSubtree is slow when there are lots of open browsing contexts

Categories

(Core :: Layout, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: smaug, Assigned: dbaron)

Details

Attachments

(1 file)

The method seems to go through each descendant document and then each child
traverses up to root prescontext (at least if mFireAfterPaintEvents is false).

Do we really need to go through also all the background tabs in case the method
is called on root presshell?

(Saw NotifyDidPaintForSubtree in profiles when looking at Bug 854100 in a browser which
had lots of tabs open)
I think bug 1078005 fixed the actual firing of after-paint events, but there's still a lot of time spent in NotifyDidPaintForSubtree, mostly in nsFrameList::FrameAt called from nsIFrame::IsVisibleConsideringAncestors.
That call stack is actually (with the tail call optimization removed):

nsFrameList::FrameAt
nsDeckFrame::GetSelectedBox
nsIFrame::IsVisibleConsideringAncestors
PresShell::IsVisible
nsPresContext::NotifyDidPaintForSubtree
... I suspect that may be fixable by making PresShell::IsVisible use mIsActive more aggressively, which would be part of the way towards fixing bug 465216.
(Note that the nsFrameList::FrameAt calls make the algorithm O(N^2), since we're searching the deck frame's child list for each child in turn.)
(Note that in some sense this patch is rewriting bug 1096076 more aggressively.)
This means that we avoid an O(N^2) calling pattern of IsVisible when we
call IsVisible for all tabs of a tabbrowser, since in a tabbrowser
(which uses an nsDeckFrame), IsVisibleConsideringAncestors is O(N) in
number of earlier tabs.
Attachment #8547395 - Flags: review?(roc)
Assignee: nobody → dbaron
Status: NEW → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/7d3ef4f3fa8f
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: