Closed Bug 1142446 Opened 10 years ago Closed 7 years ago

Module sdk/panel does not destroy panel content

Categories

(Add-on SDK Graveyard :: General, defect)

x86_64
Linux
defect
Not set
major

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: michel.gutierrez, Unassigned)

References

Details

Attachments

(1 file)

Attached file bug-destroy.tar.gz
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0
Build ID: 20150224134236

Steps to reproduce:

- Create an addon that opens a addon sdk panel. 
- In the panel content script, start an interval timer that displays a console message 
periodically. 
- Open this panel from a toolbar button and close the panel. 
- In the panel onHide callback, call destroy() method on the panel object (either directly or in a timer callback)



Actual results:

- once the panel is open, you start seeing interval messages in the console
- when the panel is closed and destroyed, those messages keep appearing


Expected results:

I would have expected that once the panel is destroyed and the content window unloaded, everything would be clean and timers removed.
I attached a very simple addon demonstrating the problem.

Add-on console output:

console.info: bug-destroy: panel script started code
console.info: bug-destroy: tick 0
console.info: bug-destroy: tick 1
console.info: bug-destroy: tick 2
console.info: bug-destroy: tick 3
console.info: bug-destroy: destroyed
console.info: bug-destroy: window unloaded
console.info: bug-destroy: tick 4
console.info: bug-destroy: tick 5
console.info: bug-destroy: tick 6

It is important to note that if the panel script (data/panel.js) is loaded from the html file (data/panel.html) using <script src="panel.js"></script> instead of using contentScriptFile in the call to require("sdk/panel").Panel(), the problem does not appear anymore (you don't see any tick console message after "window unloaded".

This problem can very easily produce memory leaks since generally developers are not used to cleaning up things on the containing window unload, they rely on their browser to do so.
Component: Untriaged → General
Product: Firefox → Add-on SDK
Version: 36 Branch → unspecified
Severity: normal → major
Priority: -- → P1
+1 here. We got memory leaks in our extension, as we create panels for every new tab opened.
On tab created, we create panel with contentscript attached to transmit back and forth messages (using port API and postMessage) from tab document to panel document. On tab document's unload event, panel.destroy() is called with no effect (you simply can call destroy on the panel object multiple times and nothing happens and no errors triggered).
Confirming the bug.
Priority: P1 → --
I doubt this is going to be fixed any time soon (if at all), but I came across this too for a page-worker and ended up changing window.location to something like "data:text/plain,goodbye" to at least minimize the effects. Be aware that the content script might re-run in that case, so check window.location at the top of your script.
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: