Bug 1368596 - Add telemetry to track how often deprecated configs are passed to navigator.requestMediaKeySystemAccess(). r?gerald,r?francois draft
authorChris Pearce <cpearce@mozilla.com>
Tue, 30 May 2017 14:26:15 +1200
changeset 586278 d797b263377f2fa0b02bf49349e978034b448dd3
parent 586242 ddc0acd34a19a25571c5cd7e740ec028b96f26f2
child 630943 f633a7dced2e584a689ba991be2cca29d8811686
push id61353
push userbmo:cpearce@mozilla.com
push dateTue, 30 May 2017 04:13:44 +0000
reviewersgerald, francois
bugs1368596
milestone55.0a1
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/MediaKeySystemAccessManager.cpp
toolkit/components/telemetry/Histograms.json
--- 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,
@@ -188,16 +191,33 @@ MediaKeySystemAccessManager::Request(Det
   MediaKeySystemConfiguration config;
   if (MediaKeySystemAccess::GetSupportedConfig(
         aKeySystem, aConfigs, config, &diagnostics, 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
@@ -8316,16 +8316,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,