Closed Bug 660880 Opened 13 years ago Closed 13 years ago

WidgetViews are not destroyed on window close

Categories

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

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ochameau, Assigned: ochameau)

References

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Fix this and add a test (obsolete) — Splinter Review
I think title is quite explicit.
WidgetView doesn't dispatch 'detach' event nor is destroyed when a browser window is closed.
Attachment #536333 - Flags: review?(rFobic)
Priority: -- → P1
Target Milestone: --- → 1.0
How severe is the leakage here?
Whiteboard: [triage:followup]
Comment on attachment 536333 [details] [diff] [review]
Fix this and add a test

Review of attachment 536333 [details] [diff] [review]:
-----------------------------------------------------------------

Just a small readability issues.

::: packages/addon-kit/lib/widget.js
@@ +320,5 @@
>      this._views.splice(idx, 1);
>    },
>    
> +  // Called on browser window closed, to destroy related views
> +  _onWindowClosed: function _onWindowClosed(window) {

Please either comment why it should be backwards or use

`for (let element in array)`

which is easier to read.

@@ +322,5 @@
>    
> +  // Called on browser window closed, to destroy related views
> +  _onWindowClosed: function _onWindowClosed(window) {
> +    for (let i = this._views.length - 1; i >= 0; i--) {
> +      let view = this._views[i];

I assume you're trying to find a view associated for that window. In that case can you please factor that out into separate function `getWindowView(window, views)` or similar. That would be much easier to understand and maintain.
Attachment #536333 - Flags: review?(rFobic) → review-
Actually it is not justified in this case to go backward.
I badly copy paste loop code from a piece of code that has to go backward and where this behavior is commented.
So I just use regular loop and added some additional comment.

myk: I'm more concerned about bug and addon breakage on window close than the leak. The leak is not that big as document should be destroyed, so we may end up with unecessary SDK WidgetViews objects. But what is really wrong with this bug is that when a window is closed and addon code use widget.postMessage or widget.port.emit, it will throw an exception and avoid next widget on following windows to receive the event/message.
Assignee: nobody → poirot.alex
Attachment #536333 - Attachment is obsolete: true
Attachment #536616 - Flags: review?(rFobic)
Comment on attachment 536616 [details] [diff] [review]
Use regular loop and add some comments.

Review of attachment 536616 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, thanks! Make sure to get a+ as well ;)
Attachment #536616 - Flags: review?(rFobic) → review+
Comment on attachment 536616 [details] [diff] [review]
Use regular loop and add some comments.

a=myk for landing during freeze.
Landed:
https://github.com/mozilla/addon-sdk/commit/22687408a3f46b8a2facadc51e5304d830cf19ce
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [triage:followup]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: