Bug 1140131 - pre-instantiate some xpcom services used by the debugger to avoid recursive instantiation. r=jlongster
☠☠ backed out by 0f81d7f9485d ☠ ☠
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 08 May 2015 11:02:11 +1000
changeset 274322 1bae19c2d494d4ca9f8fddcd27dc5c7b2dc5ec17
parent 274321 406c618c6cac430a253e142e38ea9951c34aaa25
child 274323 0f81d7f9485d2ff61cdde929b363a6bddf30ab7b
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlongster
bugs1140131
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1140131 - pre-instantiate some xpcom services used by the debugger to avoid recursive instantiation. r=jlongster
toolkit/devtools/server/actors/script.js
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -34,16 +34,27 @@ loader.lazyRequireGetter(this, "mapURITo
 let TYPED_ARRAY_CLASSES = ["Uint8Array", "Uint8ClampedArray", "Uint16Array",
       "Uint32Array", "Int8Array", "Int16Array", "Int32Array", "Float32Array",
       "Float64Array"];
 
 // Number of items to preview in objects, arrays, maps, sets, lists,
 // collections, etc.
 let OBJECT_PREVIEW_MAX_ITEMS = 10;
 
+// The debugger may be called as XPCOM services are instantiated. The debugger
+// itself uses xpcom services to fetch the source code for such services, with
+// the end result being that we attempt to recursively create some services,
+// which results in the component manager asserting in debug builds
+// (ASSERTION: Recursive GetService!). We solve this by pre-creating the
+// following services when the debugger is attached. See bug 1140131 for more.
+const REQUIRED_SERVICES = [
+  "@mozilla.org/addons/integration;1",
+  "@mozilla.org/uriloader/handler-service;1"
+];
+
 /**
  * Call PromiseDebugging.getState on this Debugger.Object's referent and wrap
  * the resulting `value` or `reason` properties in a Debugger.Object instance.
  *
  * See dom/webidl/PromiseDebugging.webidl
  *
  * @returns Object
  *          An object of one of the following forms:
@@ -654,16 +665,19 @@ ThreadActor.prototype = {
 
     if (this.state !== "detached") {
       return { error: "wrongState",
                message: "Current state is " + this.state };
     }
 
     this._state = "attached";
 
+    // now's a good time to instantiate the services we need.
+    REQUIRED_SERVICES.map(cid => Cc[cid].getService(Ci.nsISupports));
+
     update(this._options, aRequest.options || {});
     this.sources.reconfigure(this._options);
     this.sources.on('newSource', (name, source) => {
       this.onNewSource(source);
     });
 
     // Initialize an event loop stack. This can't be done in the constructor,
     // because this.conn is not yet initialized by the actor pool at that time.