Bug 1368596 - Add telemetry to track how often deprecated configs are passed to navigator.requestMediaKeySystemAccess(). r=gerald,r=francois
authorChris Pearce <cpearce@mozilla.com>
Tue, 30 May 2017 21:34:55 +1200
changeset 409576 33c7495a708fc89bc8e730daab1b13b4b93b605e
parent 409575 fe2dfb7338a49e5e0c0b19be457a040d9288d1d4
child 409577 07fe4661db8f181e17ae1cc33e92c7e106947d89
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, francois
bugs1368596
milestone55.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
Bug 1368596 - Add telemetry to track how often deprecated configs are passed to navigator.requestMediaKeySystemAccess(). r=gerald,r=francois MozReview-Commit-ID: IQ6zRRb31Vc
dom/media/eme/MediaKeySystemAccess.h
dom/media/eme/MediaKeySystemAccessManager.cpp
toolkit/components/telemetry/Histograms.json
--- a/dom/media/eme/MediaKeySystemAccess.h
+++ b/dom/media/eme/MediaKeySystemAccess.h
@@ -61,17 +61,18 @@ public:
                               const nsAString& aKeySystem,
                               MediaKeySystemStatus aStatus);
 
   static bool GetSupportedConfig(
     const nsAString& aKeySystem,
     const Sequence<MediaKeySystemConfiguration>& aConfigs,
     MediaKeySystemConfiguration& aOutConfig,
     DecoderDoctorDiagnostics* aDiagnostics,
-    bool aIsPrivateBrowsing);
+    bool aIsPrivateBrowsing,
+    const std::function<void(const char*)>& aDeprecationLogFn);
 
   static bool KeySystemSupportsInitDataType(const nsAString& aKeySystem,
                                             const nsAString& aInitDataType);
 
   static nsCString ToCString(
     const Sequence<MediaKeySystemConfiguration>& aConfig);
 
 private:
--- a/dom/media/eme/MediaKeySystemAccessManager.cpp
+++ b/dom/media/eme/MediaKeySystemAccessManager.cpp
@@ -16,16 +16,17 @@
 #endif
 #ifdef XP_MACOSX
 #include "nsCocoaFeatures.h"
 #endif
 #include "nsPrintfCString.h"
 #include "nsContentUtils.h"
 #include "nsIScriptError.h"
 #include "mozilla/Unused.h"
+#include "nsDataHashtable.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaKeySystemAccessManager)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END
@@ -164,19 +165,21 @@ MediaKeySystemAccessManager::Request(Det
     // chrome, so we can show some UI to explain how the user can rectify
     // the situation.
     MediaKeySystemAccess::NotifyObservers(mWindow, aKeySystem, status);
     aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR, message);
     return;
   }
 
   nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
+  nsDataHashtable<nsCharPtrHashKey, bool> warnings;
   std::function<void(const char*)> deprecationWarningLogFn =
-    [doc](const char* aMsgName) {
+    [&](const char* aMsgName) {
       EME_LOG("Logging deprecation warning '%s' to WebConsole.", aMsgName);
+      warnings.Put(aMsgName, true);
       nsString uri;
       if (doc) {
         Unused << doc->GetDocumentURI(uri);
       }
       const char16_t* params[] = { uri.get() };
       nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                       NS_LITERAL_CSTRING("Media"),
                                       doc,
@@ -192,16 +195,33 @@ MediaKeySystemAccessManager::Request(Det
   MediaKeySystemConfiguration config;
   if (MediaKeySystemAccess::GetSupportedConfig(
         aKeySystem, aConfigs, config, &diagnostics, isPrivateBrowsing, deprecationWarningLogFn)) {
     RefPtr<MediaKeySystemAccess> access(
       new MediaKeySystemAccess(mWindow, aKeySystem, config));
     aPromise->MaybeResolve(access);
     diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
                                           aKeySystem, true, __func__);
+
+    // Accumulate telemetry to report whether we hit deprecation warnings.
+    if (warnings.Get("MediaEMENoCapabilitiesDeprecatedWarning")) {
+      Telemetry::Accumulate(
+        Telemetry::HistogramID::MEDIA_EME_REQUEST_DEPRECATED_WARNINGS, 1);
+      EME_LOG("MEDIA_EME_REQUEST_DEPRECATED_WARNINGS "
+              "MediaEMENoCapabilitiesDeprecatedWarning");
+    } else if (warnings.Get("MediaEMENoCodecsDeprecatedWarning")) {
+      Telemetry::Accumulate(
+        Telemetry::HistogramID::MEDIA_EME_REQUEST_DEPRECATED_WARNINGS, 2);
+      EME_LOG("MEDIA_EME_REQUEST_DEPRECATED_WARNINGS "
+              "MediaEMENoCodecsDeprecatedWarning");
+    } else {
+      Telemetry::Accumulate(
+        Telemetry::HistogramID::MEDIA_EME_REQUEST_DEPRECATED_WARNINGS, 0);
+      EME_LOG("MEDIA_EME_REQUEST_DEPRECATED_WARNINGS No warnings");
+    }
     return;
   }
   // Not to inform user, because nothing to do if the corresponding keySystem
   // configuration is not supported.
   aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
                         NS_LITERAL_CSTRING("Key system configuration is not supported"));
   diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
                                         aKeySystem, false, __func__);
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8347,16 +8347,25 @@
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com"],
     "bug_numbers": [1366639],
     "expires_in_version": "60",
     "kind": "enumerated",
     "n_values": 50,
     "description": "Counts of the maximum number of shared memory buffers used for transferring video frames between the CDM and Gecko processes during playback of DRM'd video. Reported once per CDMVideoDecoder instance, i.e., once per JavaScript SourceBuffer during playback of video using EME."
   },
+  "MEDIA_EME_REQUEST_DEPRECATED_WARNINGS": {
+    "record_in_processes": ["main", "content"],
+    "alert_emails": ["cpearce@mozilla.com"],
+    "bug_numbers": [1368596],
+    "expires_in_version": "60",
+    "kind": "enumerated",
+    "n_values": 10,
+    "description": "Counts types of deprecation warnings logged on every successful call to navigator.requestMediaKeySystemAccess(). 0=No warnings logged, 1=MediaEMENoCapabilitiesDeprecatedWarning, 2=MediaEMENoCodecsDeprecatedWarning."
+  },
   "MEDIACACHE_WATERMARK_KB": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["gsquelart@mozilla.com"],
     "bug_numbers": [1366929],
     "expires_in_version": "60",
     "kind": "linear",
     "high": 520000,
     "n_buckets": 66,