Closed Bug 41119 Opened 24 years ago Closed 23 years ago

nsFrameManager destructor is slow, maybe avoid frame destruction notification?

Categories

(Core :: Layout, defect, P3)

x86
Windows NT
defect

Tracking

()

RESOLVED FIXED
mozilla0.9.7

People

(Reporter: buster, Assigned: bryner)

References

Details

(Keywords: perf)

Attachments

(1 file, 3 obsolete files)

FrameManager owns the frame tree.
When FrameManager is destroyed, it destroys the frame tree.
As each frame is destroyed, it notifies the FrameManager about it's destruction.  
Is this really necessary?  The only reason I can see for doing this is to free 
up any properties stored on behalf of frame in a hash table owned by the 
FrameManager.   Maybe there's a more efficient way of doing this, since few 
frames store properties, and few properties actually need destructors called 
(some are just basic types like ints, some are pointers to other frames like 
Waterson's secondary frame pointers.)

This will effect page transition time.

Thoughts?
A frame still needs to notify the frame manager when its destroyed; e.g., by a
resize reflow or some DOM operation.

Maybe the optimization is to add a "fast path" destroy method that accepts a
"notify frame manager" argument? E.g.,

  class nsFrame {
  public:
    Destroy(nsIPresContext* aPresContext, PRBool aNotify = PR_TRUE);
  };

Only the frame manager would ever call Destroy(presContext, PR_FALSE);

Alternatively, you could try unhooking the pres content from the pres shell
before destroying the frame tree: nsFrame::Destroy() tries to get the shell, and
will only notify the frame manager if the pres context *has* a shell. Not sure
what other effects this would have...
This bug has been marked "future" because we have determined that it is not 
critical for netscape6.0. 
If you feel this is an error, or if it blocks your work in some way -- please 
attach your concern to the bug for reconsideration.

We may reopen this bug during the performance improvement phase of the project, 
if the frame destructor turns out to be a bottleneck for page transition.

assigning to waterson so it's on his bug list.
Assignee: buster → waterson
Keywords: perf
Target Milestone: --- → Future
Status: NEW → ASSIGNED
Target Milestone: Future → mozilla0.9.6
Blocks: 71668
Target Milestone: mozilla0.9.6 → mozilla0.9.7
I can take this.
Assignee: waterson → bryner
Status: ASSIGNED → NEW
Don't we already free up the properties by calling DestroyPropertyList() from
nsFrameManager::Destroy() ?
Attached patch patch (obsolete) — Splinter Review
I still need to do perf testing with this, but I can't do that very well at
home.
Attached patch patch v2.0 (obsolete) — Splinter Review
This also avoids flushing reflows for the destroyed frames.
Attachment #57898 - Attachment is obsolete: true
Attached patch patch v2.1 (obsolete) — Splinter Review
Let's try this again, without including part of the outliner content model
patch.
Attachment #59205 - Attachment is obsolete: true
Might you need to make nsPresShell::Destroy call CancelAllReflowCommands to
avoid leaking reflow commands?
Attached patch patch v2.2Splinter Review
make sure to call CancelAllReflowCommands()
Attachment #59209 - Attachment is obsolete: true
dbaron, can you review the new patch?
Status: NEW → ASSIGNED
Comment on attachment 59406 [details] [diff] [review]
patch v2.2

r=dbaron, except you don't need the member initializer and you can remove all
the other member initializers since nsPresShell uses a
ZEROING_OPERATOR_NEW.
Attachment #59406 - Flags: review+
AFAICT, this change seems to be mandating that frame properties _cannot_ rely on
being finalized when the pres shell is destroyed. This would imply that 1) any
dynamic allocation for a property must happen from the pres shell's arena, and
2) properties _must not_ hold owning references to objects outside the pres shell.

I think that this added constraint is reasonable, but you'll need to look at the
clients of nsIFrameManager::SetFrameProperty to verify that they all play by the
rules. For example, nsBlockBandData::StoreMaxElementSize will leak an nsSize
object, no?

Or am I confused?
nsFrameManager::Destroy calls DestroyPropertyList.  Isn't that sufficient?
Okay, missed that path. sr=waterson
checked in
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: