Bug 1457231 - Submit content process crash reports in GeckoView r=jchen
authorJames Willcox <snorp@snorp.net>
Tue, 29 May 2018 11:13:36 -0500
changeset 422035 951bf64cc7982ec8ea83222757bec6e291744e6f
parent 422034 68fd5d83cc0787e8240cca4851b6920fe27af43f
child 422036 d9d0a8abad4028f967d63fa8667a7c925c6d1de9
push id34114
push userbtara@mozilla.com
push dateSat, 09 Jun 2018 15:31:58 +0000
treeherdermozilla-central@e02a5155d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1457231
milestone62.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 1457231 - Submit content process crash reports in GeckoView r=jchen This will only be done if "native" crash reporting has been enabled in the GeckoRuntimeSettings. MozReview-Commit-ID: Kdm5mRye5zy
mobile/android/components/geckoview/GeckoViewStartup.js
mobile/android/modules/geckoview/ContentCrashHandler.jsm
mobile/android/modules/geckoview/moz.build
--- a/mobile/android/components/geckoview/GeckoViewStartup.js
+++ b/mobile/android/components/geckoview/GeckoViewStartup.js
@@ -52,16 +52,23 @@ GeckoViewStartup.prototype = {
         });
 
         if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT) {
           // Parent process only.
           this.setResourceSubstitutions();
 
           Services.mm.loadFrameScript(
               "chrome://geckoview/content/GeckoViewPromptContent.js", true);
+
+          GeckoViewUtils.addLazyGetter(this, "ContentCrashHandler", {
+            module: "resource://gre/modules/ContentCrashHandler.jsm",
+            observers: [
+              "ipc:content-shutdown",
+            ]
+          });
         }
         break;
       }
 
       case "profile-after-change": {
         // Parent process only.
         // ContentPrefServiceParent is needed for e10s file picker.
         GeckoViewUtils.addLazyGetter(this, "ContentPrefServiceParent", {
new file mode 100644
--- /dev/null
+++ b/mobile/android/modules/geckoview/ContentCrashHandler.jsm
@@ -0,0 +1,46 @@
+/* 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/. */
+
+"use strict";
+
+var EXPORTED_SYMBOLS = ["ContentCrashHandler"];
+
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+  AppConstants: "resource://gre/modules/AppConstants.jsm",
+  CrashSubmit: "resource://gre/modules/CrashSubmit.jsm",
+  Services: "resource://gre/modules/Services.jsm"
+});
+
+GeckoViewUtils.initLogging("ContentCrashHandler", this);
+
+var ContentCrashHandler = {
+  // The event listener for this is hooked up in GeckoViewStartup.js
+  observe(aSubject, aTopic, aData) {
+    aSubject.QueryInterface(Ci.nsIPropertyBag2);
+
+    const disableReporting = Cc["@mozilla.org/process/environment;1"].
+      getService(Ci.nsIEnvironment).get("MOZ_CRASHREPORTER_NO_REPORT");
+
+    if (!aSubject.get("abnormal") || !AppConstants.MOZ_CRASHREPORTER ||
+        disableReporting) {
+      return;
+    }
+
+    let dumpID = aSubject.get("dumpID");
+    if (!dumpID) {
+      Services.telemetry
+              .getHistogramById("FX_CONTENT_CRASH_DUMP_UNAVAILABLE")
+              .add(1);
+      return;
+    }
+
+    debug `Submitting content process crash, dump ID ${dumpID}`;
+    CrashSubmit.submit(dumpID, {}).then(crashID => {
+      debug `Crash submission successful: ${crashID}`;
+    }, ChromeUtils.reportError);
+  }
+};
--- a/mobile/android/modules/geckoview/moz.build
+++ b/mobile/android/modules/geckoview/moz.build
@@ -1,16 +1,17 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXTRA_JS_MODULES += [
     'AndroidLog.jsm',
+    'ContentCrashHandler.jsm',
     'GeckoViewAccessibility.jsm',
     'GeckoViewContent.jsm',
     'GeckoViewContentModule.jsm',
     'GeckoViewModule.jsm',
     'GeckoViewNavigation.jsm',
     'GeckoViewProgress.jsm',
     'GeckoViewRemoteDebugger.jsm',
     'GeckoViewSettings.jsm',