Bug 1407631 - Wait about 10 minutes after browser session start before scanning for unsubmitted crash reports. r=gsvelto

While the crash reporter client is submitting a crash report, the report itself
stays in the crashes directory. We suspect that in some cases, if the browser starts
up while the crash reporter client is still sending the report, the unsubmitted
crash report handler will also attempt to send the same report.

This patch makes the unsubmitted crash report handler wait approximately 10 minutes
after the session starts before doing the unsubmitted crash report scan.

MozReview-Commit-ID: KkrPDa1Qwv1

--HG--
extra : rebase_source : cafecef5776a21a76c64300eb53fdde28e09d18b
This commit is contained in:
Mike Conley 2017-10-24 16:55:24 -04:00
parent d37fe26642
commit dd33d08c01
3 changed files with 34 additions and 8 deletions

View File

@ -1112,9 +1112,7 @@ BrowserGlue.prototype = {
}, 5000);
if (AppConstants.MOZ_CRASHREPORTER) {
Services.tm.idleDispatchToMainThread(() => {
UnsubmittedCrashHandler.checkForUnsubmittedCrashReports();
});
UnsubmittedCrashHandler.scheduleCheckForUnsubmittedCrashReports();
}
if (AppConstants.platform == "win") {

View File

@ -28,6 +28,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
"resource:///modules/RecentWindow.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
"resource://gre/modules/Timer.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "clearTimeout",
"resource://gre/modules/Timer.jsm");
XPCOMUtils.defineLazyGetter(this, "gNavigatorBundle", function() {
const url = "chrome://browser/locale/browser.properties";
@ -41,6 +45,9 @@ const DAY = 24 * 60 * 60 * 1000; // milliseconds
const DAYS_TO_SUPPRESS = 30;
const MAX_UNSEEN_CRASHED_CHILD_IDS = 20;
// Time after which we will begin scanning for unsubmitted crash reports
const CHECK_FOR_UNSUBMITTED_CRASH_REPORTS_DELAY_MS = 60 * 10000; // 10 minutes
/**
* BrowserWeakMap is exactly like a WeakMap, but expects <xul:browser>
* objects only.
@ -585,6 +592,8 @@ this.UnsubmittedCrashHandler = {
// shouldShowPendingSubmissionsNotification().
suppressed: false,
_checkTimeout: null,
init() {
if (this.initialized) {
return;
@ -621,6 +630,11 @@ this.UnsubmittedCrashHandler = {
this.initialized = false;
if (this._checkTimeout) {
clearTimeout(this._checkTimeout);
this._checkTimeout = null;
}
if (!this.enabled) {
return;
}
@ -648,6 +662,14 @@ this.UnsubmittedCrashHandler = {
}
},
scheduleCheckForUnsubmittedCrashReports() {
this._checkTimeout = setTimeout(() => {
Services.tm.idleDispatchToMainThread(() => {
this.checkForUnsubmittedCrashReports();
});
}, CHECK_FOR_UNSUBMITTED_CRASH_REPORTS_DELAY_MS);
},
/**
* Scans the profile directory for unsubmitted crash reports
* within the past PENDING_CRASH_REPORT_DAYS days. If it

View File

@ -199,11 +199,17 @@ add_task(async function setup() {
env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
// nsBrowserGlue starts up UnsubmittedCrashHandler automatically
// so at this point, it is initialized. It's possible that it
// was initialized, but is preffed off, so it's inert, so we
// shut it down, make sure it's preffed on, and then restart it.
// Note that making the component initialize even when it's
// disabled is an intentional choice, as this allows for easier
// on a timer, so at this point, it can be in one of several states:
//
// 1. The timer hasn't yet finished, and an automatic scan for crash
// reports is pending.
// 2. The timer has already gone off and the scan has already completed.
// 3. The handler is disabled.
//
// To collapse all of these possibilities, we uninit the UnsubmittedCrashHandler
// to cancel the timer, make sure it's preffed on, and then restart it (which
// doesn't restart the timer). Note that making the component initialize
// even when it's disabled is an intentional choice, as this allows for easier
// simulation of startup and shutdown.
UnsubmittedCrashHandler.uninit();