Bug 1343437 - 'media.playback.warnings-as-errors' pref - r?jya draft
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 03 Mar 2017 16:10:48 +1100
changeset 493018 4df751f295c4a0782e460df22ababc8484cf359f
parent 493017 6475ff690d974ef3b5cdf8f5142b815f06dfe345
child 547738 0650f87a3b42c492c77a8fb8bd5a724c2d6d308a
push id47625
push usergsquelart@mozilla.com
push dateFri, 03 Mar 2017 05:16:08 +0000
reviewersjya
bugs1343437
milestone54.0a1
Bug 1343437 - 'media.playback.warnings-as-errors' pref - r?jya If 'media.playback.warnings-as-errors' is true, warnings coming from demuxer's Init will be treated as errors, causing playback to fail. Currently set to false by default. This could be later changed to catch and diagnose more issues. MozReview-Commit-ID: BTaZ6TbIbNG
dom/media/MediaFormatReader.cpp
dom/media/MediaPrefs.h
dom/media/mediasource/TrackBuffersManager.cpp
modules/libpref/init/all.js
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1259,16 +1259,21 @@ MediaFormatReader::AsyncReadMetadata()
 }
 
 void
 MediaFormatReader::OnDemuxerInitDone(const MediaResult& aResult)
 {
   MOZ_ASSERT(OnTaskQueue());
   mDemuxerInitRequest.Complete();
 
+  if (aResult != NS_OK && MediaPrefs::MediaWarningsAsErrors()) {
+    mMetadataPromise.Reject(aResult, __func__);
+    return;
+  }
+
   mDemuxerInitDone = true;
 
   UniquePtr<MetadataTags> tags(MakeUnique<MetadataTags>());
 
   RefPtr<PDMFactory> platform;
   if (!IsWaitingOnCDMResource()) {
     platform = new PDMFactory();
   }
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -164,16 +164,19 @@ private:
   // Flac
   DECL_MEDIA_PREF("media.ogg.flac.enabled",                   FlacInOgg, bool, false);
   DECL_MEDIA_PREF("media.flac.enabled",                       FlacEnabled, bool, true);
 
 #if !defined(RELEASE_OR_BETA)
   DECL_MEDIA_PREF("media.rust.test_mode",                     RustTestMode, bool, false);
 #endif
 
+  // Error/warning handling, Decoder Doctor
+  DECL_MEDIA_PREF("media.playback.warnings-as-errors",        MediaWarningsAsErrors, bool, false);
+
 public:
   // Manage the singleton:
   static MediaPrefs& GetSingleton();
   static bool SingletonExists();
 
 private:
   template<class T> friend class StaticAutoPtr;
   static StaticAutoPtr<MediaPrefs> sInstance;
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TrackBuffersManager.h"
 #include "ContainerParser.h"
+#include "MediaPrefs.h"
 #include "MediaSourceDemuxer.h"
 #include "MediaSourceUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/SizePrintfMacros.h"
 #include "mozilla/StateMirroring.h"
 #include "SourceBufferResource.h"
 #include "SourceBuffer.h"
 #include "WebMDemuxer.h"
@@ -853,16 +854,22 @@ TrackBuffersManager::ResetDemuxingState(
     ->Track(mDemuxerInitRequest);
 }
 
 void
 TrackBuffersManager::OnDemuxerResetDone(const MediaResult& aResult)
 {
   MOZ_ASSERT(OnTaskQueue());
   mDemuxerInitRequest.Complete();
+
+  if (aResult != NS_OK && MediaPrefs::MediaWarningsAsErrors()) {
+      RejectAppend(aResult, __func__);
+      return;
+  }
+
   // mInputDemuxer shouldn't have been destroyed while a demuxer init/reset
   // request was being processed. See bug 1239983.
   MOZ_DIAGNOSTIC_ASSERT(mInputDemuxer);
 
   if (aResult != NS_OK && mParentDecoder && mParentDecoder->GetOwner()) {
     mParentDecoder->GetOwner()->DecodeWarning(aResult);
   }
 
@@ -935,16 +942,21 @@ TrackBuffersManager::InitializationSegme
 void
 TrackBuffersManager::OnDemuxerInitDone(const MediaResult& aResult)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_DIAGNOSTIC_ASSERT(mInputDemuxer, "mInputDemuxer has been destroyed");
 
   mDemuxerInitRequest.Complete();
 
+  if (aResult != NS_OK && MediaPrefs::MediaWarningsAsErrors()) {
+      RejectAppend(aResult, __func__);
+      return;
+  }
+
   MediaInfo info;
 
   uint32_t numVideos = mInputDemuxer->GetNumberTracks(TrackInfo::kVideoTrack);
   if (numVideos) {
     // We currently only handle the first video track.
     mVideoTracks.mDemuxer =
       mInputDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
     MOZ_ASSERT(mVideoTracks.mDemuxer);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -603,16 +603,19 @@ pref("media.video_stats.enabled", true);
 
 // Whether to check the decoder supports recycling.
 pref("media.decoder.recycle.enabled", false);
 
 // Log level for cubeb, the audio input/output system. Valid values are
 // "verbose", "normal" and "" (log disabled).
 pref("media.cubeb.log_level", "");
 
+// Set to true to force demux/decode warnings to be treated as errors.
+pref("media.playback.warnings-as-errors", false);
+
 // Weather we allow AMD switchable graphics
 pref("layers.amd-switchable-gfx.enabled", true);
 
 // Whether to use async panning and zooming
 pref("layers.async-pan-zoom.enabled", true);
 
 // Whether to enable event region building during painting
 pref("layout.event-regions.enabled", false);