Bug 1868778 - Mark extensions process crashes as occurring in a background process. r=gsvelto,amejiamarmol,geckoview-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D195773
This commit is contained in:
William Durand 2023-12-08 21:10:33 +00:00
parent 4de3612bbf
commit 2c6088f94a
2 changed files with 49 additions and 8 deletions

View file

@ -60,8 +60,9 @@ export var ChildCrashHandler = {
return; return;
} }
// If dumpID is empty the process was likely killed by the system and we therefore do not // If dumpID is empty the process was likely killed by the system and
// want to report the crash. // we therefore do not want to report the crash. This includes most
// "expected" extensions process crashes on Android.
const dumpID = aSubject.get("dumpID"); const dumpID = aSubject.get("dumpID");
if (!dumpID) { if (!dumpID) {
Services.telemetry Services.telemetry
@ -73,12 +74,6 @@ export var ChildCrashHandler = {
debug`Notifying child process crash, dump ID ${dumpID}`; debug`Notifying child process crash, dump ID ${dumpID}`;
const [minidumpPath, extrasPath] = getPendingMinidump(dumpID); const [minidumpPath, extrasPath] = getPendingMinidump(dumpID);
// Report GPU process crashes as occuring in a background process, and others as foreground.
const processType =
aTopic === "compositor:process-aborted"
? "BACKGROUND_CHILD"
: "FOREGROUND_CHILD";
let remoteType = this.childMap.get(childID); let remoteType = this.childMap.get(childID);
this.childMap.delete(childID); this.childMap.delete(childID);
@ -88,6 +83,13 @@ export var ChildCrashHandler = {
remoteType = remoteType.split("=")[0]; remoteType = remoteType.split("=")[0];
} }
// Report GPU and extension process crashes as occuring in a background
// process, and others as foreground.
const processType =
aTopic === "compositor:process-aborted" || remoteType === "extension"
? "BACKGROUND_CHILD"
: "FOREGROUND_CHILD";
lazy.EventDispatcher.instance.sendRequest({ lazy.EventDispatcher.instance.sendRequest({
type: "GeckoView:ChildCrashReport", type: "GeckoView:ChildCrashReport",
minidumpPath, minidumpPath,

View file

@ -61,3 +61,42 @@ add_task(async function test_remoteType() {
); );
Assert.equal("webIsolated", aData?.remoteType, "expected remote type prefix"); Assert.equal("webIsolated", aData?.remoteType, "expected remote type prefix");
}); });
add_task(async function test_extensions_process_crash() {
const childID = 123;
const remoteType = "extension";
// Force-set a remote type for the process that we are going to "crash" next.
lazy.ChildCrashHandler.childMap.set(childID, remoteType);
// Mock a process crash being notified.
const propertyBag = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
Ci.nsIWritablePropertyBag2
);
propertyBag.setPropertyAsBool("abnormal", true);
propertyBag.setPropertyAsAString("dumpID", "a-dump-id");
// Set up a listener to receive the crash report event emitted by the handler.
let listener;
const crashReportPromise = new Promise(resolve => {
listener = {
onEvent(aEvent, aData, aCallback) {
resolve([aEvent, aData]);
},
};
});
lazy.EventDispatcher.instance.registerListener(listener, [
"GeckoView:ChildCrashReport",
]);
// Simulate a crash.
lazy.ChildCrashHandler.observe(propertyBag, "ipc:content-shutdown", childID);
const [aEvent, aData] = await crashReportPromise;
Assert.equal(
"GeckoView:ChildCrashReport",
aEvent,
"expected a child crash report"
);
Assert.equal("extension", aData?.remoteType, "expected remote type");
Assert.equal("BACKGROUND_CHILD", aData?.processType, "expected process type");
});