Bug 1483703 - part4 : modify current telemtry scalar because we won't block media without audio track anymore. r=cpearce,francois
authoralwu <alwu@mozilla.com>
Wed, 22 Aug 2018 22:54:05 +0000
changeset 830951 bb9759881cd75c2a0cba3510f35166d160074e79
parent 830950 d915d805e9642c0e4cab3db3042bd9bdf5f2c5b7
child 830952 2b2cc1983172a567ec81830d4cc530616eb2aa74
push id118861
push userbmo:rhelmer@mozilla.com
push dateThu, 23 Aug 2018 11:42:47 +0000
reviewerscpearce, francois
bugs1483703
milestone63.0a1
Bug 1483703 - part4 : modify current telemtry scalar because we won't block media without audio track anymore. r=cpearce,francois Since we don't block media without audio track anymore, the original telemetry scalar becomes useless. We need to change its meaning in order to know the number of allowed autoplay without audio track. Differential Revision: https://phabricator.services.mozilla.com/D3673
dom/html/HTMLMediaElement.cpp
toolkit/components/telemetry/Scalars.yaml
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4042,24 +4042,24 @@ void
 HTMLMediaElement::UpdateHadAudibleAutoplayState()
 {
   // 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);
+      if (mReadyState >= HAVE_METADATA && !HasAudio()) {
+        ScalarAdd(Telemetry::ScalarID::MEDIA_ALLOWED_AUTOPLAY_NO_AUDIO_TRACK_COUNT, 1);
+      }
     } else {
       if (mReadyState < HAVE_METADATA) {
         mBlockedAsWithoutMetadata = true;
         ScalarAdd(Telemetry::ScalarID::MEDIA_BLOCKED_NO_METADATA, 1);
       }
-      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)
 {
@@ -5568,23 +5568,16 @@ 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 (mBlockedAsWithoutMetadata && !HasAudio()) {
     mBlockedAsWithoutMetadata = false;
     ScalarAdd(Telemetry::ScalarID::MEDIA_BLOCKED_NO_METADATA_ENDUP_NO_AUDIO_TRACK, 1);
   }
 
   if (mDecoder && mDecoder->IsTransportSeekable() &&
       mDecoder->IsMediaSeekable()) {
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -911,21 +911,21 @@ 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:
+  allowed_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.
+      The number of HTMLMediaElement autoplays on HTMLMediaElements without an audio track which would be allowed to play.
     expires: "68"
     kind: uint
     notification_emails:
       - cpearce@mozilla.com
       - alwu@mozilla.com
       - nohlmeier@mozilla.com
     release_channel_collection: opt-in
     record_in_processes: