Bug 741255 - ASSERTION: Oops! You're asking for a weak reference to an object that doesn't support that. during shutdown, with telemetry on stack; r=froydnj
authorAndres Hernandez [:andreshm] <andres@appcoast.com>
Mon, 07 May 2012 14:02:02 -0600
changeset 94484 49cbdb1ea4e2a4d7f44bd381d15d1125e2ac49a2
parent 94483 b1dc93af542d380daa03f1afabe842ba583bc721
child 94554 5586efaf687dd0bca43499d315876d1d6eb352f9
push id778
push usertim.taubert@gmx.de
push dateTue, 22 May 2012 09:21:42 +0000
treeherderfx-team@49cbdb1ea4e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs741255
milestone15.0a1
Bug 741255 - ASSERTION: Oops! You're asking for a weak reference to an object that doesn't support that. during shutdown, with telemetry on stack; r=froydnj
toolkit/components/telemetry/TelemetryPing.js
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -168,16 +168,17 @@ TelemetryPing.prototype = {
   _prevValues: {},
   // Generate a unique id once per session so the server can cope with
   // duplicate submissions.
   _uuid: generateUUID(),
   // Regex that matches histograms we carea bout during startup.
   _startupHistogramRegex: /SQLITE|HTTP|SPDY|CACHE|DNS/,
   _slowSQLStartup: {},
   _prevSession: null,
+  _hasWindowRestoredObserver : false,
 
   /**
    * When reflecting a histogram into JS, Telemetry hands us an object
    * with the following properties:
    * 
    * - min, max, histogram_type, sum: simple integers;
    * - counts: array of counts for histogram buckets;
    * - ranges: array of calculated bucket sizes.
@@ -621,16 +622,17 @@ TelemetryPing.prototype = {
       // This may change once about:telemetry is added.
       Telemetry.canRecord = false;
       return;
     }
     Services.obs.addObserver(this, "private-browsing", false);
     Services.obs.addObserver(this, "profile-before-change", false);
     Services.obs.addObserver(this, "sessionstore-windows-restored", false);
     Services.obs.addObserver(this, "quit-application-granted", false);
+    this._hasWindowRestoredObserver = true;
 
     // Delay full telemetry initialization to give the browser time to
     // run various late initializers. Otherwise our gathered memory
     // footprint and other numbers would be too optimistic.
     let self = this;
     this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     let timerCallback = function() {
       self._initialized = true;
@@ -650,20 +652,19 @@ TelemetryPing.prototype = {
     Telemetry.loadHistograms(file, loadCallback, sync);
   },
 
   /** 
    * Remove observers to avoid leaks
    */
   uninstall: function uninstall() {
     this.detachObservers()
-    try {
+    if (this._hasWindowRestoredObserver) {
       Services.obs.removeObserver(this, "sessionstore-windows-restored");
-    } catch (e) {
-      // Already observed this event.
+      this._hasWindowRestoredObserver = false;
     }
     Services.obs.removeObserver(this, "profile-before-change");
     Services.obs.removeObserver(this, "private-browsing");
     Services.obs.removeObserver(this, "quit-application-granted");
   },
 
   /**
    * This observer drives telemetry.
@@ -695,16 +696,17 @@ TelemetryPing.prototype = {
       if (aData == "enter") {
         this.detachObservers()
       } else {
         this.attachObservers()
       }
       break;
     case "sessionstore-windows-restored":
       Services.obs.removeObserver(this, "sessionstore-windows-restored");
+      this._hasWindowRestoredObserver = false;
       // fall through
     case "test-gather-startup":
       this.gatherStartupInformation();
       break;
     case "idle-daily":
       // Enqueue to main-thread, otherwise components may be inited by the
       // idle-daily category and miss the gather-telemetry notification.
       Services.tm.mainThread.dispatch((function() {