Closed Bug 726334 Opened 12 years ago Closed 12 years ago

nsFormFillController::mFocusedInput can keep nodes alive longer than needed

Categories

(Toolkit :: Form Manager, defect)

12 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: smaug, Assigned: smaug)

References

Details

(Whiteboard: [snappy:p3][MemShrink:P2])

Attachments

(1 file, 3 obsolete files)

If I read the code correctly nsFormFillController::mFocusedInput can
actually in some cases keep node alive longer than needed.
(In reply to Olli Pettay [:smaug] from comment #0)
> If I read the code correctly nsFormFillController::mFocusedInput can
> actually in some cases keep node alive longer than needed.

how often does this happen?
(In reply to Olli Pettay [:smaug] from comment #0)
> If I read the code correctly nsFormFillController::mFocusedInput can
> actually in some cases keep node alive longer than needed.

Could you be more specific?
Something like hiding focused input element and moving it to another document might
cause this to happen.
I don't know how often this happens, since this is still speculation.
Something is keeping input elements alive occasionally, though.
(In reply to Olli Pettay [:smaug] from comment #3)
> Something like hiding focused input element and moving it to another
> document might
> cause this to happen.
> I don't know how often this happens, since this is still speculation.
> Something is keeping input elements alive occasionally, though.

We need a needs-telemetry whiteboard entry. In meantime I'm P4ing this until telemetry(or something) can show us extent of this problem.
Whiteboard: [snappy] → [snappy:p4]
I keep accidentally using a non-existent snappy:p4 priority
Whiteboard: [snappy:p4] → [snappy:p3]
Assignee: nobody → bugs
Attached patch patch (obsolete) — Splinter Review
I hadn't realized formfillcontroller is a service, which makes the
situation even worse.

Chrome code really shouldn't keep strong references to content nodes.
It is just way too easy to leak some of them accidentally.
I'll ask review if the tryserver results look good.

https://tbpl.mozilla.org/?tree=Try&rev=915c6d323e19
Bah, looks like the patch crashes nicely :(
Attached patch better patch (obsolete) — Splinter Review
Attachment #599005 - Attachment is obsolete: true
Attached patch patch (obsolete) — Splinter Review
https://tbpl.mozilla.org/?tree=Try&rev=ee6e64a48620
This should actually pass the input.list tests.
Need to be careful with mListNode handling so that we always have pointer to it
when needed.

The patch makes FFC to never own any dom nodes. All the nodes it has pointer to
are controlled via mutationobservers.
Attachment #599013 - Attachment is obsolete: true
Attachment #599284 - Flags: review?
Attachment #599284 - Flags: review? → review?(gavin.sharp)
Comment on attachment 599284 [details] [diff] [review]
patch

nit: I noticed a couple of "if("s (missing space)

If you're going to start adding the formfillcontroller as an nsIMutationObserver for more than just list elements (i.e. also for the inputs themselves), you'll need to add a checks to avoid calling RevalidateDataList() for changes to the <input>. r- because of that.

>diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp

> nsFormFillController::~nsFormFillController()

>+  if (mListNode) {

>+  if (mFocusedInputNode) {

These changes shouldn't be necessary since RemoveWindowListeners (called later in this function) calls StopControllingInput(). In theory that also takes care of clearing mPwmgrInputs, though only if the relevant windows still have documents, which might not be as reliable, I guess?

>diff --git a/toolkit/components/satchel/nsFormFillController.h b/toolkit/components/satchel/nsFormFillController.h

>+  nsDataHashtable<nsPtrHashKey<const nsINode>, PRInt32> mPwmgrInputs;

Might as well make this nsDataHashtable<nsPtrHashKey<const nsINode>, bool>, no?
Attachment #599284 - Flags: review?(gavin.sharp) → review-
(In reply to Gavin Sharp (use gavin@gavinsharp.com for email) from comment #11)
> Comment on attachment 599284 [details] [diff] [review]
> patch
> 
> nit: I noticed a couple of "if("s (missing space)

Hmm, where did those come from. strange.

> 
> If you're going to start adding the formfillcontroller as an
> nsIMutationObserver for more than just list elements (i.e. also for the
> inputs themselves), you'll need to add a checks to avoid calling
> RevalidateDataList() for changes to the <input>. r- because of that.
Why?

> These changes shouldn't be necessary since RemoveWindowListeners (called
> later in this function) calls StopControllingInput(). In theory that also
> takes care of clearing mPwmgrInputs, though only if the relevant windows
> still have documents, which might not be as reliable, I guess?
Yeah.

> Might as well make this nsDataHashtable<nsPtrHashKey<const nsINode>, bool>,
> no?
Sure, I just didn't change the existing value type.
Whiteboard: [snappy:p3] → [snappy:p3][MemShrink]
(In reply to Olli Pettay [:smaug] from comment #12)
 
> > These changes shouldn't be necessary since RemoveWindowListeners (called
> > later in this function) calls StopControllingInput(). In theory that also
> > takes care of clearing mPwmgrInputs, though only if the relevant windows
> > still have documents, which might not be as reliable, I guess?
Actually, that is not enough. I don't see what guarantees that mDocShells has any items.
Whiteboard: [snappy:p3][MemShrink] → [snappy:p3]
Whiteboard: [snappy:p3] → [snappy:p3][MemShrink]
Whiteboard: [snappy:p3][MemShrink] → [snappy:p3][MemShrink:P2]
(In reply to Olli Pettay [:smaug] from comment #13)
> Actually, that is not enough. I don't see what guarantees that mDocShells
> has any items.

You're right - it's theoretically possible for mPwmgrInputs to be populated without AttachToBrowser having been called. I don't think that happens in practice because form fill controller is always hooked up to every docshell in Firefox (even if form filling is disabled). I guess that's a good thing since we'd otherwise leak all these inputs indefinitely...
Attached patch patchSplinter Review
Contains is inclusive
http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-contains
Attachment #599284 - Attachment is obsolete: true
Attachment #599413 - Flags: review?(gavin.sharp)
Comment on attachment 599413 [details] [diff] [review]
patch

thanks for fixing this
Attachment #599413 - Flags: review?(gavin.sharp) → review+
https://hg.mozilla.org/mozilla-central/rev/2d065305b7d2

Thanks for quick review!
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
Depends on: 730470
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: