Created
April 1, 2019 16:37
-
-
Save juliandescottes/b7c2431379c46e6ee67cb930fb0a817d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/devtools/client/framework/components/ToolboxController.js b/devtools/client/framework/components/ToolboxController.js | |
--- a/devtools/client/framework/components/ToolboxController.js | |
+++ b/devtools/client/framework/components/ToolboxController.js | |
@@ -131,16 +131,20 @@ class ToolboxController extends Componen | |
unhighlightTool(id) { | |
const { highlightedTools } = this.state; | |
if (highlightedTools.has(id)) { | |
highlightedTools.delete(id); | |
this.setState({ highlightedTools }); | |
} | |
} | |
+ getRef() { | |
+ return this; | |
+ } | |
+ | |
setDockOptionsEnabled(areDockOptionsEnabled) { | |
this.setState({ areDockOptionsEnabled }); | |
} | |
setHostTypes(hostTypes) { | |
this.setState({ hostTypes }); | |
} | |
diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js | |
--- a/devtools/client/framework/devtools.js | |
+++ b/devtools/client/framework/devtools.js | |
@@ -3,32 +3,42 @@ | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
"use strict"; | |
const {Cu} = require("chrome"); | |
const Services = require("Services"); | |
const {DevToolsShim} = require("chrome://devtools-startup/content/DevToolsShim.jsm"); | |
+const { setInterval } = Cu.import("resource://gre/modules/Timer.jsm"); | |
loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true); | |
loader.lazyRequireGetter(this, "ToolboxHostManager", "devtools/client/framework/toolbox-host-manager", true); | |
loader.lazyRequireGetter(this, "HUDService", "devtools/client/webconsole/hudservice", true); | |
loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry"); | |
loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm"); | |
loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm"); | |
const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} = | |
require("devtools/client/definitions"); | |
const EventEmitter = require("devtools/shared/event-emitter"); | |
const {getTheme, setTheme, addThemeObserver, removeThemeObserver} = | |
require("devtools/client/shared/theme"); | |
const FORBIDDEN_IDS = new Set(["toolbox", ""]); | |
const MAX_ORDINAL = 99; | |
+let weak; | |
+setInterval(function () { | |
+ Cu.forceGC(); Cu.forceCC(); | |
+ Cu.forceGC(); Cu.forceCC(); | |
+ Cu.forceGC(); Cu.forceCC(); | |
+ if (weak) { | |
+ dump("object still alive? "+weak.get()+"\n"); | |
+ } | |
+}, 3000); | |
/** | |
* DevTools is a class that represents a set of developer tools, it holds a | |
* set of tools and keeps track of open toolboxes in the browser. | |
*/ | |
function DevTools() { | |
this._tools = new Map(); // Map<toolId, tool> | |
this._themes = new Map(); // Map<themeId, theme> | |
@@ -537,32 +547,32 @@ DevTools.prototype = { | |
return toolId; | |
}, | |
async createToolbox(target, toolId, hostType, hostOptions) { | |
const manager = new ToolboxHostManager(target, hostType, hostOptions); | |
const toolbox = await manager.create(toolId); | |
- | |
this._toolboxes.set(target, toolbox); | |
this.emit("toolbox-created", toolbox); | |
toolbox.once("destroy", () => { | |
this.emit("toolbox-destroy", target); | |
}); | |
toolbox.once("destroyed", () => { | |
this._toolboxes.delete(target); | |
this.emit("toolbox-destroyed", target); | |
}); | |
await toolbox.open(); | |
this.emit("toolbox-ready", toolbox); | |
+ weak = Cu.getWeakReference(toolbox.component.getRef()); | |
return toolbox; | |
}, | |
/** | |
* Return the toolbox for a given target. | |
* | |
* @param {object} target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment