Closed Bug 83635 Opened 24 years ago Closed 14 years ago

XBL binding not deleted on removal from document tree

Categories

(Core :: XBL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b7
Tracking Status
blocking2.0 --- -

People

(Reporter: tim.dewhirst, Assigned: mounir)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files, 2 obsolete files)

A problem has been noted with regards to removing an XBL binding from a document. If a simple binding is constructed, which simply dumps a message on construction and destruction, and added to the document and subsequently deleted, the destructor is not called. The destructor is only called at browser shutdown if the binding is not removed from the tree. A test case attachment follows.
Status: UNCONFIRMED → NEW
Ever confirmed: true
->moz1.0
Target Milestone: --- → mozilla1.0
Status: NEW → ASSIGNED
Target Milestone: mozilla1.0 → mozilla1.0.1
Blocks: 230086
Depends on: 265086
Blocks: 262234
Assignee: hyatt → general
Status: ASSIGNED → NEW
QA Contact: jrgmorrison → ian
OS: Windows 2000 → All
Hardware: PC → All
Target Milestone: mozilla1.0.1 → ---
So the basic problem is that we only detach bindings when a document is unloaded, and only for those bindings that are in the binding manager's table. When we remove a node from the document, we null out the binding in the document's binding manager and nuke the anonymous content, but do NOT call BindingDetached(). Frankly, I think we should just call BindingDetached either in that code, or in ~nsXBLBinding. Thoughts? Note that this bug causes various memory leaks if people removeChild a node with a binding attached to it; we have workarounds for some of these in our tabbrowser bindings last I checked...
Flags: blocking1.9?
Is there a risk that that would break a bunch of XUL because we'd behave differently for nodes that are moved out of the tree?
Maybe. If people remove nodes from the DOM and then call XBL methods on them, the methods will not work. Right now they sorta kinda work, maybe. One more note: our current behavior is that if you remove a node from the DOM we do nothing. If you reinsert it, we fire the constructor (a second time, with no destructor firing in between). Whether you reinsert it or not, if the destructor did any sort of cleanup we probably leak the node (more likely if you don't reinsert)....
Marking wanted for fixing any mlk involved; correctness isn't blocking 1.9.
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
Flags: wanted1.9+
Whiteboard: [wanted-1.9]
Blocks: 432035
Assignee: xbl → nobody
QA Contact: ian → xbl
(In reply to comment #5) > Maybe. If people remove nodes from the DOM and then call XBL methods on them, > the methods will not work. Right now they sorta kinda work, maybe. > No. It does not work. Although the binding wasn't destroyed, one cannot access the binding implementation after the node is removed (see my patch on bug 528006). IMO, this negates the compatibility argument for keeping this behavior until XBL2.
> No. It does not work. Indeed; that got changed in bug 398135.
OK. What sort of compatibility issue remains here then?
Probably none.
Re-evauating for blocking then. Drivers: This bug is causing various leaks related to toolbar customization, along with non-trivial workarounds, like the one in 528006.
blocking2.0: --- → ?
Blocks: 528006
Assignee: nobody → jonas
blocking2.0: ? → beta1
blocking2.0: beta1+ → beta2+
blocking2.0: beta2+ → beta3+
jst, you marked this beta3+ 10 days ago, no progress since then. Do we expect this to hit code freeze on Monday, Aug 2, 23:00 PT?
No. Moving to beta4.
blocking2.0: beta3+ → beta4+
This isn't a regression from anything remotely recent, and we still have no progress on it AFAICT. It's not clear to me why this should block. At a maximum it feels like we just need beta coverage, but I'm leaning to "not a blocker". Setting to betaN for now, but please justify why this is blocking.
blocking2.0: beta4+ → betaN+
After looking at more details in this bug and talking this over with Jonas I agree with Shawn, this is not a blocker.
Assignee: jonas → mounir.lamouri
blocking2.0: betaN+ → -
... but I assigned this to Mounir and he will try out the easy fix and see if that fixes the leak issue here, and if it does we should take the fix for fx4, assuming it seems like a safe fix.
Attached patch Patch v1 (obsolete) — Splinter Review
Attachment #479555 - Flags: review?(jonas)
Status: NEW → ASSIGNED
I think I'd prefer to call BindingDetached when the binding is removed. The dtor can run at more random times due to CC, so that's more error prone.
Comment on attachment 479555 [details] [diff] [review] Patch v1 Removing review request while waiting
Attachment #479555 - Flags: review?(jonas)
Attached patch Patch v2 (obsolete) — Splinter Review
Is that what you are expecting?
Attachment #479555 - Attachment is obsolete: true
Attachment #483942 - Flags: review?(jonas)
Comment on attachment 483942 [details] [diff] [review] Patch v2 Yes. Lets get this in sooner rather than later. All XBL changes scare me.
Attachment #483942 - Flags: review?(jonas)
Attachment #483942 - Flags: review+
Attachment #483942 - Flags: approval2.0+
So, the problem is, when calling BindingDetached, the destructor is called but when called in that situation, all methods inside the destructor will be undefined. I have no idea why :-/ I have a test case here: http://oldworld.fr/mozilla/xbl-test.xul (you need Remote XUL Manager extension to set the permissions). With the patch applied, if you remove a child, the bindings will be detached and _foo() will try to be called but the call will fail. Without the patch, the destructor will be called later and _foo() will be correctly called.
Attached patch Patch v2.1Splinter Review
Ok, I should detach before changing the document actually.
Attachment #483942 - Attachment is obsolete: true
Depends on: 606215
This is ready to be landed but according to Boris this has to be landed for b7 because it might break some extensions. For example, radio widget has been broken. Should I push that in b7 branch?
You'll need beltzners approval.
If this is an API change that would break people, then yes, please put it on the b7 relbranch. I've moved this bug to be a b7 blocker to reflect that. The relbranch is GECKO20b7pre_20101006_RELBRANCH
Comment on attachment 484683 [details] [diff] [review] Patch v2.1 a=beltzner for mozilla-central default and b7 relbranch
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b7
Depends on: 626935
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: