Closed Bug 1579943 Opened 5 years ago Closed 3 months ago

ext-theme.js leaks memory because per-window themes are not cleared when a window is closed

Categories

(WebExtensions :: Themes, defect, P2)

defect

Tracking

(firefox134 fixed)

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: robwu, Assigned: baku)

References

Details

Attachments

(1 file, 1 obsolete file)

I spotted the following error while running toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors_perwindow.js.
The test creates a new window, applies a theme to it, closes the window and then unloads the extension (relevant source). The error happens because the unload handler iterates over all keys in windowOverrides and then tries to detach the theme from the window. But as the error shows, the window isn't around any more. If you look at ext-theme.js, then it is obvious that the Theme is never cleaned up when a window is removed. This should be fixed.

Console message: [JavaScript Error: "Invalid window ID: 32" {file: "resource://gre/modules/ExtensionUtils.jsm" line: 54}]
ExtensionError@resource://gre/modules/ExtensionUtils.jsm:54:49
getWindow@chrome://extensions/content/parent/ext-tabs-base.js:1535:13
unload@chrome://extensions/content/parent/ext-theme.js:392:23
onShutdown@chrome://extensions/content/parent/ext-theme.js:428:15
ExtensionAPI/<@resource://gre/modules/ExtensionCommon.jsm:356:14
wrapper@resource://gre/modules/ExtensionCommon.jsm:300:14
emit@resource://gre/modules/ExtensionCommon.jsm:327:32
emit@resource://gre/modules/Extension.jsm:1752:25
shutdown@resource://gre/modules/Extension.jsm:2378:10
receiveMessage@resource://specialpowers/SpecialPowersParent.jsm:1048:26

This bug in themes code results in memory leaks. Do you know who can work on this?

Flags: needinfo?(ntim.bugs)
Flags: needinfo?(jaws)
Priority: -- → P1
Whiteboard: webext?

I don't actively have time to work on this, sorry.

Flags: needinfo?(ntim.bugs)
Assignee: nobody → jaws
Status: NEW → ASSIGNED
Flags: needinfo?(jaws)
Whiteboard: webext?
Assignee: jaws → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(rob)

I'll take over. Thanks for the initial patch.

Assignee: nobody → rob
Status: NEW → ASSIGNED
Flags: needinfo?(rob)

(not a P1, and I'm not actively working on this because I'm mentoring a couple of bugs related to the theme API, and don't want to stomp on that with this change. Will revisit this bug later)

Priority: P1 → P2
Attachment #9097465 - Attachment is obsolete: true
Severity: normal → S3
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4de5fe0d2708 remove webext theme memory leak with closing windows, r=robwu
Regressions: 1928115
Assignee: rob → amarchesini
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: