Bug 1480484 - add telemetry scalar to measure the count for blocked media element without audio track. r=cpearce,francois
authoralwu <alwu@mozilla.com>
Fri, 03 Aug 2018 13:21:03 -0700
changeset 430448 753fc72a27d586f8aa562f1ddb2c3fa90f9ec4f5
parent 430447 ddfa5cc2ea30007e1a26c235ead93879c37d9b2b
child 430449 431c15d94478f0362b43d18f0ebec0ab82dbdc0a
push id34405
push userncsoregi@mozilla.com
push dateWed, 08 Aug 2018 09:57:26 +0000
treeherdermozilla-central@c65991f3fa10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, francois
bugs1480484
milestone63.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 1480484 - add telemetry scalar to measure the count for blocked media element without audio track. r=cpearce,francois This is used to count the potiential number of the blocked autoplay media element without audio track even if user was enable autoplay. It might happen on three cases, 1. play -> loadedmetadata 2. loadedmetadata -> play 3. loadedmetadata -> has 'autoplay' keyword In first case we need to check whether the play invocation has been called, and check other other cases before the media starts playing. In addition, the scalar name isn't consist with other names is because of the 40 maximum limitation of the ping name. MozReview-Commit-ID: 6Qm6TD4ME8I
dom/html/HTMLMediaElement.cpp
toolkit/components/telemetry/Scalars.yaml
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4028,16 +4028,19 @@ HTMLMediaElement::UpdateHadAudibleAutopl
 {
   // If we're audible, and autoplaying...
   if ((Volume() > 0.0 && !Muted()) &&
       (!OwnerDoc()->HasBeenUserGestureActivated() || Autoplay())) {
     OwnerDoc()->SetDocTreeHadAudibleMedia();
     if (AutoplayPolicy::WouldBeAllowedToPlayIfAutoplayDisabled(*this)) {
       ScalarAdd(Telemetry::ScalarID::MEDIA_AUTOPLAY_WOULD_BE_ALLOWED_COUNT, 1);
     } else {
+      if (mReadyState >= HAVE_METADATA && !HasAudio()) {
+        ScalarAdd(Telemetry::ScalarID::MEDIA_BLOCKED_AUTOPLAY_NO_AUDIO_TRACK_COUNT, 1);
+      }
       ScalarAdd(Telemetry::ScalarID::MEDIA_AUTOPLAY_WOULD_NOT_BE_ALLOWED_COUNT, 1);
     }
   }
 }
 
 already_AddRefed<Promise>
 HTMLMediaElement::Play(ErrorResult& aRv)
 {
@@ -5498,16 +5501,23 @@ HTMLMediaElement::MetadataLoaded(const M
   DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
   if (IsVideo() && HasVideo()) {
     DispatchAsyncEvent(NS_LITERAL_STRING("resize"));
   }
   NS_ASSERTION(!HasVideo() || (mMediaInfo.mVideo.mDisplay.width > 0 &&
                                mMediaInfo.mVideo.mDisplay.height > 0),
                "Video resolution must be known on 'loadedmetadata'");
   DispatchAsyncEvent(NS_LITERAL_STRING("loadedmetadata"));
+  // The play invocation which was call by script had happened before media
+  // element loaded metadata.
+  if ((!mPaused && OwnerDoc() && !OwnerDoc()->HasBeenUserGestureActivated()) &&
+      !HasAudio() &&
+      (Volume() != 0 && !Muted())) {
+    ScalarAdd(Telemetry::ScalarID::MEDIA_BLOCKED_AUTOPLAY_NO_AUDIO_TRACK_COUNT, 1);
+  }
   if (mDecoder && mDecoder->IsTransportSeekable() &&
       mDecoder->IsMediaSeekable()) {
     ProcessMediaFragmentURI();
     mDecoder->SetFragmentEndTime(mFragmentEnd);
   }
   if (mIsEncrypted) {
     // We only support playback of encrypted content via MSE by default.
     if (!mMediaSource && Preferences::GetBool("media.eme.mse-only", true)) {
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -838,16 +838,32 @@ media:
       - cpearce@mozilla.com
       - alwu@mozilla.com
       - nohlmeier@mozilla.com
     release_channel_collection: opt-in
     record_in_processes:
       - main
       - content
 
+  blocked_autoplay_no_audio_track_count:
+    bug_numbers:
+      - 1480484
+    description: >
+      The number of HTMLMediaElement autoplays on HTMLMediaElements without an audio track which would not be allowed to play if block autoplay was enabled; we'd either prompt for permission to play or block outright depending on user preferences.
+    expires: "68"
+    kind: uint
+    notification_emails:
+      - cpearce@mozilla.com
+      - alwu@mozilla.com
+      - nohlmeier@mozilla.com
+    release_channel_collection: opt-in
+    record_in_processes:
+      - main
+      - content
+
   autoplay_would_be_allowed_count:
     bug_numbers:
       - 1476456
     description: >
       The number of HTMLMediaElement autoplays on audible HTMLMediaElements that would have been allowed (not blocked) by the autoplay policy if block autoplay was enabled.
     expires: "68"
     kind: uint
     notification_emails: