Bug 615956 - The content-shutdown callback should return quickly, to allow the dead child process to be reaped [r=mbrubeck]
authorMark Finkle <mfinkle@mozilla.com>
Thu, 09 Dec 2010 23:46:40 -0500
changeset 67106 f173c4baee6303331d44f2ea662883f34820beeb
parent 67105 2ba6c90b7fb335083b609f03f5ffb839277f98bb
child 67107 eae956a047cfe6f2d194d885dadc59f80b21e16f
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs615956
Bug 615956 - The content-shutdown callback should return quickly, to allow the dead child process to be reaped [r=mbrubeck]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2091,62 +2091,65 @@ var ContentCrashObserver = {
     if (aTopic != "ipc:content-shutdown") {
       Cu.reportError("ContentCrashObserver unexpected topic: " + aTopic);
       return;
     }
 
     if (!aSubject.QueryInterface(Ci.nsIPropertyBag2).hasKey("abnormal"))
       return;
 
+    let dumpID = aSubject.hasKey("dumpID") ? aSubject.getProperty("dumpID") : null;
+
     // Spin through the open tabs and resurrect the out-of-process tabs. Resurrection
     // does not auto-reload the content. We delay load the content as needed.
     Browser.tabs.forEach(function(aTab) {
       if (aTab.browser.getAttribute("remote") == "true")
         aTab.resurrect();
     })
 
-    // Ask the user if we should reload or close the current tab. Other tabs
-    // will be reloaded when selected.
-    let title = Elements.browserBundle.getString("tabs.crashWarningTitle");
-    let message = Elements.browserBundle.getString("tabs.crashWarningMsg");
-    let submitText = Elements.browserBundle.getString("tabs.crashSubmitReport");
-    let reloadText = Elements.browserBundle.getString("tabs.crashReload");
-    let closeText = Elements.browserBundle.getString("tabs.crashClose");
-    let buttons = Ci.nsIPrompt.BUTTON_POS_1_DEFAULT +
-                  (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
-                  (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
-
-    // Only show the submit checkbox if we have a crash report we can submit
-    if (!aSubject.hasKey("dumpID"))
-      submitText = null;
-
-    let submit = { value: true };
-    let reload = Services.prompt.confirmEx(window, title, message, buttons, closeText, reloadText, null, submitText, submit);
-    if (reload) {
-      // Fire a TabSelect event to kick start the restore process
-      let event = document.createEvent("Events");
-      event.initEvent("TabSelect", true, false);
-      event.lastTab = null;
-      Browser.selectedTab.chromeTab.dispatchEvent(event);
-    } else {
-      // If this is the only tab, we need to pre-fab a new tab. We should never
-      // have zero open tabs
-      if (Browser.tabs.length == 1)
-        Browser.addTab(Browser.getHomePage(), false, null, { getAttention: false });
-
-      // Close this tab, it could be the reason we crashed. The undo-close-tab
-      // system will pick it up.
-      Browser.closeTab(Browser.selectedTab);
-    }
-
-    // Submit the report, if we have one and the user wants to submit it
-    if (submit.value && aSubject.hasKey("dumpID")) {
-      let dumpID = aSubject.getProperty("dumpID");
-      this.CrashSubmit.submit(dumpID, Elements.stack, null, null);
-    }
+    // Execute the UI prompt after the notification has had a chance to return and close the child process
+    setTimeout(function(self) {
+      // Ask the user if we should reload or close the current tab. Other tabs
+      // will be reloaded when selected.
+      let title = Elements.browserBundle.getString("tabs.crashWarningTitle");
+      let message = Elements.browserBundle.getString("tabs.crashWarningMsg");
+      let submitText = Elements.browserBundle.getString("tabs.crashSubmitReport");
+      let reloadText = Elements.browserBundle.getString("tabs.crashReload");
+      let closeText = Elements.browserBundle.getString("tabs.crashClose");
+      let buttons = Ci.nsIPrompt.BUTTON_POS_1_DEFAULT +
+                    (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
+                    (Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
+  
+      // Only show the submit checkbox if we have a crash report we can submit
+      if (!dumpID)
+        submitText = null;
+  
+      let submit = { value: true };
+      let reload = Services.prompt.confirmEx(window, title, message, buttons, closeText, reloadText, null, submitText, submit);
+      if (reload) {
+        // Fire a TabSelect event to kick start the restore process
+        let event = document.createEvent("Events");
+        event.initEvent("TabSelect", true, false);
+        event.lastTab = null;
+        Browser.selectedTab.chromeTab.dispatchEvent(event);
+      } else {
+        // If this is the only tab, we need to pre-fab a new tab. We should never
+        // have zero open tabs
+        if (Browser.tabs.length == 1)
+          Browser.addTab(Browser.getHomePage(), false, null, { getAttention: false });
+  
+        // Close this tab, it could be the reason we crashed. The undo-close-tab
+        // system will pick it up.
+        Browser.closeTab(Browser.selectedTab);
+      }
+  
+      // Submit the report, if we have one and the user wants to submit it
+      if (submit.value && dumpID)
+        self.CrashSubmit.submit(dumpID, Elements.stack, null, null);
+    }, 0, this);
   }
 };
 
 var MemoryObserver = {
   observe: function mo_observe() {
     window.QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
     Components.utils.forceGC();