Bug 1357297 - Restrict media decode issues that show user notification - r=jwwang

The media prefs "media.decoder-doctor.decode-{errors,warnings}-allowed" list
which decode issue codes will show the "Report Site Issue" notification.

Default: NS_ERROR_DOM_MEDIA_DEMUXER_ERR and NS_ERROR_DOM_MEDIA_METADATA_ERR,
which are the kinds of errors we currently care most about, and have more
chance to fix.

MozReview-Commit-ID: JbY2pwv4TXP

--HG--
extra : rebase_source : 65809f5eb3ace85e25b01c0d1cdfdd068c467ca0
This commit is contained in:
Gerald Squelart 2017-04-19 09:42:45 +12:00
parent 86ada480e9
commit 58096b0b9e
2 changed files with 31 additions and 1 deletions

View File

@ -410,6 +410,33 @@ AllowNotification(const NotificationAndReportStringId& aNotification)
StringListContains(filter, aNotification.mReportStringId);
}
static bool
AllowDecodeIssue(const MediaResult& aDecodeIssue, bool aDecodeIssueIsError)
{
if (aDecodeIssue == NS_OK) {
// 'NS_OK' means we are not actually reporting a decode issue, so we
// allow the report.
return true;
}
// "media.decoder-doctor.decode-{errors,warnings}-allowed" controls which
// decode issues may be dispatched to the front-end. It either contains:
// - '*' -> Allow everything.
// - Comma-separater list of ids -> Allow if the issue name is one of them.
// - Nothing (missing or empty) -> Disable everything.
nsAdoptingCString filter =
Preferences::GetCString(aDecodeIssueIsError
? "media.decoder-doctor.decode-errors-allowed"
: "media.decoder-doctor.decode-warnings-allowed");
if (filter.EqualsLiteral("*")) {
return true;
}
nsCString decodeIssueName;
GetErrorName(aDecodeIssue.Code(), static_cast<nsACString&>(decodeIssueName));
return StringListContains(filter, decodeIssueName);
}
static void
ReportAnalysis(nsIDocument* aDocument,
const NotificationAndReportStringId& aNotification,
@ -462,7 +489,8 @@ ReportAnalysis(nsIDocument* aDocument,
ReportToConsole(aDocument, aNotification.mReportStringId, params);
}
if (AllowNotification(aNotification)) {
if (AllowNotification(aNotification) &&
AllowDecodeIssue(aDecodeIssue, aDecodeIssueIsError)) {
DispatchNotification(
aDocument->GetInnerWindow(), aNotification, aIsSolved,
aFormats,

View File

@ -390,6 +390,8 @@ pref("media.decoder-doctor.notifications-allowed", "MediaWMFNeeded,MediaWidevine
#else
pref("media.decoder-doctor.notifications-allowed", "MediaWMFNeeded,MediaWidevineNoWMF,MediaCannotInitializePulseAudio,MediaCannotPlayNoDecoders,MediaUnsupportedLibavcodec");
#endif
pref("media.decoder-doctor.decode-errors-allowed", "NS_ERROR_DOM_MEDIA_DEMUXER_ERR, NS_ERROR_DOM_MEDIA_METADATA_ERR");
pref("media.decoder-doctor.decode-warnings-allowed", "NS_ERROR_DOM_MEDIA_DEMUXER_ERR, NS_ERROR_DOM_MEDIA_METADATA_ERR");
// Whether we report partial failures.
pref("media.decoder-doctor.verbose", false);
// Whether DD should consider WMF-disabled a WMF failure, useful for testing.