| author | Adam Gashlin <agashlin@mozilla.com> |
| Thu, 17 Jun 2021 18:06:35 +0000 | |
| changeset 583742 | fe2b9abdb53bf6d24ea184ebcb77350f38ea8405 |
| parent 583741 | 91f7b8dc86708e694233f5ddbd2c4213febf90fb |
| child 583743 | 8bcf35827a03386d64e4b89b5b3136bb848b77fe |
| push id | 38550 |
| push user | mlaza@mozilla.com |
| push date | Fri, 18 Jun 2021 09:20:56 +0000 |
| treeherder | mozilla-central@d70c3d846c39 [default view] [failures only] |
| perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
| reviewers | bytesized |
| bugs | 1703578 |
| milestone | 91.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
|
| browser/components/shell/ShellService.jsm | file | annotate | diff | comparison | revisions | |
| toolkit/components/telemetry/Histograms.json | file | annotate | diff | comparison | revisions |
--- a/browser/components/shell/ShellService.jsm +++ b/browser/components/shell/ShellService.jsm @@ -140,46 +140,75 @@ let ShellServiceInternal = { // We launch the WDBA to handle the registry writes, see // SetDefaultBrowserUserChoice() in // toolkit/mozapps/defaultagent/SetDefaultBrowser.cpp. // This is external in case an overzealous antimalware product decides to // quarrantine any program that writes UserChoice, though this has not // occurred during extensive testing. - if (!ShellService.checkAllProgIDsExist()) { - throw new Error("checkAllProgIDsExist() failed"); - } + let telemetryResult = "ErrOther"; + + try { + if (!ShellService.checkAllProgIDsExist()) { + telemetryResult = "ErrProgID"; + throw new Error("checkAllProgIDsExist() failed"); + } - if (!ShellService.checkBrowserUserChoiceHashes()) { - throw new Error("checkBrowserUserChoiceHashes() failed"); - } + if (!ShellService.checkBrowserUserChoiceHashes()) { + telemetryResult = "ErrHash"; + throw new Error("checkBrowserUserChoiceHashes() failed"); + } - const wdba = Services.dirsvc.get("XREExeF", Ci.nsIFile); - wdba.leafName = "default-browser-agent.exe"; - const aumi = XreDirProvider.getInstallHash(); + const wdba = Services.dirsvc.get("XREExeF", Ci.nsIFile); + wdba.leafName = "default-browser-agent.exe"; + const aumi = XreDirProvider.getInstallHash(); + + telemetryResult = "ErrLaunchExe"; + const exeProcess = await Subprocess.call({ + command: wdba.path, + arguments: ["set-default-browser-user-choice", aumi], + }); + telemetryResult = "ErrOther"; - const exeProcess = await Subprocess.call({ - command: wdba.path, - arguments: ["set-default-browser-user-choice", aumi], - }); + // Exit codes, see toolkit/mozapps/defaultagent/SetDefaultBrowser.h + const S_OK = 0; + const STILL_ACTIVE = 0x103; + const MOZ_E_NO_PROGID = 0xa0000001; + const MOZ_E_HASH_CHECK = 0xa0000002; + const MOZ_E_REJECTED = 0xa0000003; - // exit codes - const S_OK = 0; - const STILL_ACTIVE = 0x103; + const exeWaitTimeoutMs = 2000; // 2 seconds + const exeWaitPromise = exeProcess.wait(); + const timeoutPromise = new Promise(function(resolve, reject) { + setTimeout(() => resolve({ exitCode: STILL_ACTIVE }), exeWaitTimeoutMs); + }); + const { exitCode } = await Promise.race([exeWaitPromise, timeoutPromise]); - const exeWaitTimeoutMs = 2000; // 2 seconds - const exeWaitPromise = exeProcess.wait(); - const timeoutPromise = new Promise(function(resolve, reject) { - setTimeout(() => resolve({ exitCode: STILL_ACTIVE }), exeWaitTimeoutMs); - }); - const { exitCode } = await Promise.race([exeWaitPromise, timeoutPromise]); + if (exitCode != S_OK) { + telemetryResult = + new Map([ + [STILL_ACTIVE, "ErrExeTimeout"], + [MOZ_E_NO_PROGID, "ErrExeProgID"], + [MOZ_E_HASH_CHECK, "ErrExeHash"], + [MOZ_E_REJECTED, "ErrExeRejected"], + ]).get(exitCode) ?? "ErrExeOther"; + throw new Error( + `WDBA nonzero exit code ${exitCode}: ${telemetryResult}` + ); + } - if (exitCode != S_OK) { - throw new Error(`WDBA nonzero exit code ${exitCode}`); + telemetryResult = "Success"; + } finally { + try { + const histogram = Services.telemetry.getHistogramById( + "BROWSER_SET_DEFAULT_USER_CHOICE_RESULT" + ); + histogram.add(telemetryResult); + } catch (ex) {} } }, // override nsIShellService.setDefaultBrowser() on the ShellService proxy. setDefaultBrowser(claimAllTypes, forAllUsers) { // On Windows 10, our best chance is to set UserChoice, so try that first. if ( AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
--- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -11821,16 +11821,28 @@ "BROWSER_SET_DEFAULT_ERROR": { "record_in_processes": ["main"], "products": ["firefox", "fennec"], "expires_in_version": "never", "kind": "boolean", "releaseChannelCollection": "opt-out", "description": "True if the browser was unable to set Firefox as the default browser" }, + "BROWSER_SET_DEFAULT_USER_CHOICE_RESULT": { + "record_in_processes": ["main"], + "products": ["firefox"], + "operating_systems": ["windows"], + "expires_in_version": "96", + "kind": "categorical", + "labels": ["Success", "ErrProgID", "ErrHash", "ErrLaunchExe", "ErrExeTimeout", "ErrExeProgID", "ErrExeHash", "ErrExeRejected", "ErrExeOther", "ErrOther"], + "releaseChannelCollection": "opt-out", + "bug_numbers": [1703578], + "alert_emails": ["application-update-telemetry-alerts@mozilla.com", "agashlin@mozilla.com"], + "description": "Result of each attempt to set the default browser with SetDefaultBrowserUserChoice()" + }, "BROWSER_IS_ASSIST_DEFAULT": { "record_in_processes": ["main"], "products": ["firefox", "fennec"], "expires_in_version": "never", "kind": "boolean", "description": "The result of the default browser check for assist intent." }, "BROWSER_ATTRIBUTION_ERRORS": {