Bug 1287987 - Record VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE telemetry - r=kamidphish
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 19 Jul 2016 17:47:45 +1000
changeset 306049 3f4268be982986a087206a5bc950fa5f17a4c09a
parent 306048 b30a96d890b60d296ec1830f0743ee03716971ed
child 306050 bd2f3939764154062cf4d65c8a39bd461df10c44
push id79765
push usercbook@mozilla.com
push dateThu, 21 Jul 2016 14:26:34 +0000
treeherdermozilla-inbound@ab54bfc55266 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish
bugs1287987
milestone50.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 1287987 - Record VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE telemetry - r=kamidphish MozReview-Commit-ID: FJk7Jn5mqTp
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3085,21 +3085,61 @@ HTMLMediaElement::ReportTelemetry()
       uint32_t percentage = 100 * droppedFrames / totalFrames;
       LOG(LogLevel::Debug,
           ("Reporting telemetry DROPPED_FRAMES_IN_VIDEO_PLAYBACK"));
       Telemetry::Accumulate(Telemetry::VIDEO_DROPPED_FRAMES_PROPORTION,
                             percentage);
     }
   }
 
-  Telemetry::Accumulate(Telemetry::VIDEO_PLAY_TIME_MS, SECONDS_TO_MS(mPlayTime.Total()));
-  LOG(LogLevel::Debug, ("%p VIDEO_PLAY_TIME_MS = %f", this, mPlayTime.Total()));
-
-  Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_MS, SECONDS_TO_MS(mHiddenPlayTime.Total()));
-  LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_MS = %f", this, mHiddenPlayTime.Total()));
+  double playTime = mPlayTime.Total();
+  double hiddenPlayTime = mHiddenPlayTime.Total();
+
+  Telemetry::Accumulate(Telemetry::VIDEO_PLAY_TIME_MS, SECONDS_TO_MS(playTime));
+  LOG(LogLevel::Debug, ("%p VIDEO_PLAY_TIME_MS = %f", this, playTime));
+
+  Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_MS, SECONDS_TO_MS(hiddenPlayTime));
+  LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_MS = %f", this, hiddenPlayTime));
+
+  if (playTime > 0.0 &&
+      mMediaInfo.HasVideo() &&
+      mMediaInfo.mVideo.mImage.height > 0) {
+    // We have actually played some valid video -> Report hidden/total ratio.
+    uint32_t hiddenPercentage = uint32_t(hiddenPlayTime / playTime * 100.0 + 0.5);
+
+    // Keyed by audio+video or video alone, and by a resolution range.
+    nsCString key(mMediaInfo.HasAudio() ? "AV," : "V,");
+    static const struct { int32_t mH; const char* mRes; } sResolutions[] = {
+      {  240, "0<h<=240" },
+      {  480, "240<h<=480" },
+      {  576, "480<h<=576" },
+      {  720, "576<h<=720" },
+      { 1080, "720<h<=1080" },
+      { 2160, "1080<h<=2160" }
+    };
+    const char* resolution = "h>2160";
+    int32_t height = mMediaInfo.mVideo.mImage.height;
+    for (const auto& res : sResolutions) {
+      if (height <= res.mH) {
+        resolution = res.mRes;
+        break;
+      }
+    }
+    key.AppendASCII(resolution);
+
+    Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE,
+                          key,
+                          hiddenPercentage);
+    // Also accumulate all percentages in an "All" key.
+    Telemetry::Accumulate(Telemetry::VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE,
+                          NS_LITERAL_CSTRING("All"),
+                          hiddenPercentage);
+    LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE = %u, keys: '%s' and 'All'",
+                          this, hiddenPercentage, key.get()));
+  }
 }
 
 void HTMLMediaElement::UnbindFromTree(bool aDeep,
                                       bool aNullParent)
 {
   if (!mPaused && mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
     Pause();
   }