зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305836, part 1 - Remove CCAnalyzer leak checker. r=jgriffin
This leak checker may be triggering a shutdown leak on Windows, doesn't work with e10s, and should not be needed now that ttaubert fixed the ++DOMWINDOW leak detector to work. The additional GCs and CCs this patch adds used to be run as part of cc-analyzer.js, and are needed to avoid window leaks in tests. MozReview-Commit-ID: IzZI6h2SCr2 --HG-- extra : rebase_source : 7bacc70e9f4b41208c1ef057faf53ed3af5d2e12
This commit is contained in:
Родитель
a90bd7a14c
Коммит
e3195a4d80
|
@ -9,5 +9,4 @@
|
|||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/mochitest-e10s-utils.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/browser-test.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/cc-analyzer.js"/>
|
||||
</overlay>
|
||||
|
|
|
@ -632,29 +632,19 @@ Tester.prototype = {
|
|||
// use a shrinking GC so that the JS engine will discard JIT code and
|
||||
// JIT caches more aggressively.
|
||||
|
||||
let checkForLeakedGlobalWindows = aCallback => {
|
||||
let shutdownCleanup = aCallback => {
|
||||
Cu.schedulePreciseShrinkingGC(() => {
|
||||
let analyzer = new CCAnalyzer();
|
||||
analyzer.run(() => {
|
||||
let results = [];
|
||||
for (let obj of analyzer.find("nsGlobalWindow ")) {
|
||||
let m = obj.name.match(/^nsGlobalWindow #(\d+)/);
|
||||
if (m && m[1] in this.openedWindows)
|
||||
results.push({ name: obj.name, url: m[1] });
|
||||
}
|
||||
aCallback(results);
|
||||
});
|
||||
// Run the GC and CC a few times to make sure that as much
|
||||
// as possible is freed.
|
||||
let numCycles = 3;
|
||||
for (i = 0; i < numCycles; i++) {
|
||||
Cu.forceGC();
|
||||
Cu.forceCC();
|
||||
}
|
||||
aCallback();
|
||||
});
|
||||
};
|
||||
|
||||
let reportLeaks = aResults => {
|
||||
for (let result of aResults) {
|
||||
let test = this.openedWindows[result.url];
|
||||
let msg = "leaked until shutdown [" + result.name +
|
||||
" " + (this.openedURLs[result.url] || "NULL") + "]";
|
||||
test.addResult(new testResult(false, msg, "", false));
|
||||
}
|
||||
};
|
||||
|
||||
let {AsyncShutdown} =
|
||||
Cu.import("resource://gre/modules/AsyncShutdown.jsm", {});
|
||||
|
@ -674,17 +664,9 @@ Tester.prototype = {
|
|||
|
||||
Services.ppmm.broadcastAsyncMessage("browser-test:collect-request");
|
||||
|
||||
checkForLeakedGlobalWindows(aResults => {
|
||||
if (aResults.length == 0) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
// After the first check, if there are reported leaked windows, sleep
|
||||
// for a while, to allow off-main-thread work to complete and free up
|
||||
// main-thread objects. Then check again.
|
||||
shutdownCleanup(() => {
|
||||
setTimeout(() => {
|
||||
checkForLeakedGlobalWindows(aResults => {
|
||||
reportLeaks(aResults);
|
||||
shutdownCleanup(() => {
|
||||
this.finish();
|
||||
});
|
||||
}, 1000);
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function CCAnalyzer() {
|
||||
}
|
||||
|
||||
CCAnalyzer.prototype = {
|
||||
clear: function () {
|
||||
this.callback = null;
|
||||
this.processingCount = 0;
|
||||
this.graph = {};
|
||||
this.roots = [];
|
||||
this.garbage = [];
|
||||
this.edges = [];
|
||||
this.listener = null;
|
||||
},
|
||||
|
||||
run: function (aCallback) {
|
||||
this.clear();
|
||||
this.callback = aCallback;
|
||||
|
||||
this.listener = Cc["@mozilla.org/cycle-collector-logger;1"].
|
||||
createInstance(Ci.nsICycleCollectorListener);
|
||||
|
||||
this.listener.disableLog = true;
|
||||
this.listener.wantAfterProcessing = true;
|
||||
|
||||
this.runCC(3);
|
||||
},
|
||||
|
||||
runCC: function (aCounter) {
|
||||
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
if (aCounter > 1) {
|
||||
utils.garbageCollect();
|
||||
setTimeout(this.runCC.bind(this, aCounter - 1), 0);
|
||||
} else {
|
||||
utils.garbageCollect(this.listener);
|
||||
this.processLog();
|
||||
}
|
||||
},
|
||||
|
||||
processLog: function () {
|
||||
// Process entire heap step by step in 5K chunks
|
||||
for (let i = 0; i < 5000; i++) {
|
||||
if (!this.listener.processNext(this)) {
|
||||
this.callback();
|
||||
this.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Next chunk on timeout.
|
||||
setTimeout(this.processLog.bind(this), 0);
|
||||
},
|
||||
|
||||
noteRefCountedObject: function (aAddress, aRefCount, aObjectDescription) {
|
||||
let o = this.ensureObject(aAddress);
|
||||
o.address = aAddress;
|
||||
o.refcount = aRefCount;
|
||||
o.name = aObjectDescription;
|
||||
},
|
||||
|
||||
noteGCedObject: function (aAddress, aMarked, aObjectDescription) {
|
||||
let o = this.ensureObject(aAddress);
|
||||
o.address = aAddress;
|
||||
o.gcmarked = aMarked;
|
||||
o.name = aObjectDescription;
|
||||
},
|
||||
|
||||
noteEdge: function (aFromAddress, aToAddress, aEdgeName) {
|
||||
let fromObject = this.ensureObject(aFromAddress);
|
||||
let toObject = this.ensureObject(aToAddress);
|
||||
fromObject.edges.push({name: aEdgeName, to: toObject});
|
||||
toObject.owners.push({name: aEdgeName, from: fromObject});
|
||||
|
||||
this.edges.push({
|
||||
name: aEdgeName,
|
||||
from: fromObject,
|
||||
to: toObject
|
||||
});
|
||||
},
|
||||
|
||||
describeRoot: function (aAddress, aKnownEdges) {
|
||||
let o = this.ensureObject(aAddress);
|
||||
o.root = true;
|
||||
o.knownEdges = aKnownEdges;
|
||||
this.roots.push(o);
|
||||
},
|
||||
|
||||
describeGarbage: function (aAddress) {
|
||||
let o = this.ensureObject(aAddress);
|
||||
o.garbage = true;
|
||||
this.garbage.push(o);
|
||||
},
|
||||
|
||||
ensureObject: function (aAddress) {
|
||||
if (!this.graph[aAddress])
|
||||
this.graph[aAddress] = new CCObject();
|
||||
|
||||
return this.graph[aAddress];
|
||||
},
|
||||
|
||||
find: function (aText) {
|
||||
let result = [];
|
||||
for (let address in this.graph) {
|
||||
let o = this.graph[address];
|
||||
if (!o.garbage && o.name.indexOf(aText) >= 0)
|
||||
result.push(o);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
function CCObject() {
|
||||
this.name = "";
|
||||
this.address = null;
|
||||
this.refcount = 0;
|
||||
this.gcmarked = false;
|
||||
this.root = false;
|
||||
this.garbage = false;
|
||||
this.knownEdges = 0;
|
||||
this.edges = [];
|
||||
this.owners = [];
|
||||
}
|
|
@ -7,7 +7,6 @@ mochikit.jar:
|
|||
content/jetpack-package-overlay.xul (jetpack-package-overlay.xul)
|
||||
content/jetpack-addon-harness.js (jetpack-addon-harness.js)
|
||||
content/jetpack-addon-overlay.xul (jetpack-addon-overlay.xul)
|
||||
content/cc-analyzer.js (cc-analyzer.js)
|
||||
content/chrome-harness.js (chrome-harness.js)
|
||||
content/mochitest-e10s-utils.js (mochitest-e10s-utils.js)
|
||||
content/shutdown-leaks-collector.js (shutdown-leaks-collector.js)
|
||||
|
|
|
@ -45,7 +45,6 @@ TEST_HARNESS_FILES.testing.mochitest += [
|
|||
'browser-harness.xul',
|
||||
'browser-test-overlay.xul',
|
||||
'browser-test.js',
|
||||
'cc-analyzer.js',
|
||||
'chrome-harness.js',
|
||||
'chunkifyTests.js',
|
||||
'gen_template.pl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче