Leak in cuddlefish.js (with add-on Copy Tiny Url 0.4), many compartments system principal

RESOLVED FIXED

Status

Add-on SDK
General
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: aryx, Unassigned)

Tracking

(Blocks: 1 bug, {mlk})

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [MemShrink:P3])

Attachments

(2 attachments)

Created attachment 595692 [details]
copy tiny url 0.4

Firefox 10.0 32-bit Windows XP SP 3
Firefox Nightly 2012-02-08 Windows XP SP 3

If you install the Copy Tiny Url add-on in version 0.4 (see attachment), there are many compartments System Principal even after disabling the add-on, nightly blames cuddlefish.js for these.

Steps to reproduce:
1. Create a new profile.
2. Install the add-on.
3. Open the add-on manager, disable the add-on.
4. Open about:memory?verbose and close all other tabs.
5. Click 'Minimize memory usage'.

Actual result:
Still many compartments like this:
 compartment([System Principal], resource://jid1-epxk6cb8p5cx9w-at-jetpack/api-utils/lib/cuddlefish.js, 0x55b0000)

Add-on SDK version is 1.4.3

The main.js contains this:

var data = require("self").data;
var Request = require("request").Request;
const tabs = require("tabs");
let clipboard = require("clipboard");
var copy_tinyurl = {
    onTrack: function (window) {
        var doc = window.document;
        if (doc.documentElement.getAttribute("windowtype") !== "navigator:browser") return;
        // Modify the window!   
        if (doc.getElementById("urlbar") !== null && doc.getElementById("copy_tinyurl_icon") === null) {
            var urlbar = doc.getElementById("urlbar");
            var urlbarIcons = doc.getElementById("urlbar-icons");
            var copy_tinyurl_icon = doc.createElement('a');
            copy_tinyurl_icon.id = "copy_tinyurl_icon";
            copy_tinyurl_icon.class = "urlbar-icon";
            copy_tinyurl_icon.hidden = false;
            copy_tinyurl_icon.style.display = "inline-block";
            copy_tinyurl_icon.style.width = "16px";
            copy_tinyurl_icon.style.height = "16px";
            copy_tinyurl_icon.style.background = "url(" + data.url("icon-16.png") + ")";
            copy_tinyurl_icon.onclick = function () {
                if (tabs.activeTab.url.indexOf("http://") == 0 || tabs.activeTab.url.indexOf("https://") == 0) {
                    Request({
                        url: "http://tinyurl.com/api-create.php?url=" + encodeURIComponent(tabs.activeTab.url),
                        onComplete: function (response) {
                            clipboard.set(response.text);
                            urlbar.value = response.text;
 
                        }
                    }).get();
 
                }
 
            }
 
 
            urlbarIcons.appendChild(copy_tinyurl_icon);
        }
    },
    onUntrack: function (window) {
        // Clean up
        var doc = window.document;
        if (doc.documentElement.getAttribute("windowtype") !== "navigator:browser") return;
        // Modify the window!  
        if (doc.getElementById("copy_tinyurl_icon") !== null) {
            var copy_tinyurl_icon = doc.getElementById("copy_tinyurl_icon");
            copy_tinyurl_icon.parentNode.removeChild(copy_tinyurl_icon);
        }
    }
};
var winUtils = require("window-utils");
var tracker = new winUtils.WindowTracker(copy_tinyurl);
Created attachment 595693 [details]
about:memory?verbose content with cuddlefish.js leak
Alex, is this the same as bug 724433, or fixed by your patch there?
Depends on: 724433
Whiteboard: [MemShrink] → [triage:followup][MemShrink]
Blocks: 700547
Bug 726485 sounds rather similar, and it wasn't fixed by bug 724433, IIUC.
I think that you shouldn't be leaking with bug 724433 being fixed,
if you remove const tabs = require("tabs"); and stop using this API.
`tabs` requires `windows` which is leaking.

Otherwise, it should be completely fixed though bug 724404.
Whiteboard: [triage:followup][MemShrink] → [triage:followup][MemShrink:P3]

Comment 5

5 years ago
It is fixed by bug 724433 and  bug 724404.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Keywords: mlk
Whiteboard: [triage:followup][MemShrink:P3] → [MemShrink:P3]
You need to log in before you can comment on or make changes to this bug.