Bug 848994 - p7. Filter front-end notifications - r?cpearce
Pref "media.decoder-doctor.notifications-allowed" defines which notifications
may be forwarded to the front-end (based on the web-console message ID for
that situation). This allows fine-grained filtering.
The current default is to only notify the user about Widevine requests when WMF
and Silverlight are missing (because Widevine does not include an AAC decoder).
MozReview-Commit-ID: KPFH5XjuwnZ
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -3,16 +3,17 @@
/* 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/. */
#include "DecoderDoctorDiagnostics.h"
#include "mozilla/dom/DecoderDoctorNotificationBinding.h"
#include "mozilla/Logging.h"
+#include "mozilla/Preferences.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsIObserverService.h"
#include "nsITimer.h"
#include "nsIWeakReference.h"
#include "nsPluginHost.h"
static mozilla::LazyLogModule sDecoderDoctorLog("DecoderDoctor");
@@ -282,19 +283,41 @@ DecoderDoctorDocumentWatcher::ReportAnal
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Media"),
mDocument,
nsContentUtils::eDOM_PROPERTIES,
aReportStringId,
aParams.IsEmpty() ? nullptr : params,
aParams.IsEmpty() ? 0 : 1);
- // For now, disable all front-end notifications by default.
- // TODO: Future bugs will use finer-grained filtering instead.
- if (Preferences::GetBool("media.decoderdoctor.enable-notification-bar", false)) {
+ // "media.decoder-doctor.notifications-allowed" controls which notifications
+ // may be dispatched to the front-end. It either contains:
+ // - '*' -> Allow everything.
+ // - Comma-separater list of ids -> Allow if aReportStringId (from
+ // dom.properties) is one of them.
+ // - Nothing (missing or empty) -> Disable everything.
+ nsAdoptingCString filter =
+ Preferences::GetCString("media.decoder-doctor.notifications-allowed");
+ filter.StripWhitespace();
+ bool allowed = false;
+ if (!filter || filter.IsEmpty()) {
+ // Allow nothing.
+ } else if (filter.EqualsLiteral("*")) {
+ allowed = true;
+ } else for (uint32_t start = 0; start < filter.Length(); ) {
+ int32_t comma = filter.FindChar(',', start);
+ uint32_t end = (comma >= 0) ? uint32_t(comma) : filter.Length();
+ if (strncmp(aReportStringId, filter.Data() + start, end - start) == 0) {
+ allowed = true;
+ break;
+ }
+ // Skip comma. End of line will be caught in for 'while' clause.
+ start = end + 1;
+ }
+ if (allowed) {
DispatchNotification(
mDocument->GetInnerWindow(), aNotificationType, aParams);
}
}
enum SilverlightPresence {
eNoSilverlight,
eSilverlightDisabled,
@@ -435,17 +458,17 @@ DecoderDoctorDocumentWatcher::Synthesize
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
"MediaCannotPlayNoDecoders", unplayableFormats);
return;
}
if (!unplayableFormats.IsEmpty()) {
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
- if (Preferences::GetBool("media.decoderdoctor.verbose", false)) {
+ if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {
ReportAnalysis(
dom::DecoderDoctorNotificationType::Can_play_but_some_missing_decoders,
"MediaNoDecoders", unplayableFormats);
}
return;
}
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, decoders available for all requested formats",
this, mDocument);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -346,16 +346,23 @@ pref("media.webm.intel_decoder.enabled",
#ifdef MOZ_APPLEMEDIA
#ifdef MOZ_WIDGET_UIKIT
pref("media.mp3.enabled", true);
#endif
pref("media.apple.mp3.enabled", true);
pref("media.apple.mp4.enabled", true);
#endif
+
+// Filter what triggers user notifications.
+// See DecoderDoctorDocumentWatcher::ReportAnalysis for details.
+pref("media.decoder-doctor.notifications-allowed", "MediaWidevineNoWMFNoSilverlight");
+// Whether we report partial failures.
+pref("media.decoder-doctor.verbose", false);
+
#ifdef MOZ_WEBRTC
pref("media.navigator.enabled", true);
pref("media.navigator.video.enabled", true);
pref("media.navigator.load_adapt", true);
pref("media.navigator.load_adapt.measure_interval",1000);
pref("media.navigator.load_adapt.avg_seconds",3);
pref("media.navigator.load_adapt.high_load","0.90");
pref("media.navigator.load_adapt.low_load","0.40");