Backed out changesets d35ca21dada8, 772774b9be23, and 6d4536c5fa38 (bug 1131638) for bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 16 Mar 2015 12:44:49 -0400
changeset 250396 3a27c2da51d1
parent 250395 ad1f181d8593
child 250397 becc3f84ea4e
push id4571
push userryanvm@gmail.com
push date2015-03-16 16:44 +0000
treeherdermozilla-beta@3a27c2da51d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1131638
milestone37.0
backs outd35ca21dada8
772774b9be23
6d4536c5fa38
Backed out changesets d35ca21dada8, 772774b9be23, and 6d4536c5fa38 (bug 1131638) for bustage.
dom/media/MediaDecoder.h
dom/media/MediaDecoderReader.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
dom/media/fmp4/MP4Reader.cpp
dom/media/fmp4/MP4Reader.h
dom/media/fmp4/PlatformDecoderModule.h
dom/media/fmp4/SharedDecoderManager.cpp
dom/media/fmp4/SharedDecoderManager.h
dom/media/fmp4/wmf/WMFDecoderModule.h
dom/media/mediasource/MediaSourceReader.h
gfx/layers/D3D9SurfaceImage.cpp
gfx/layers/D3D9SurfaceImage.h
gfx/layers/ImageContainer.h
gfx/layers/client/ImageClient.cpp
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -933,18 +933,17 @@ public:
   class FrameStatistics {
   public:
 
     FrameStatistics() :
         mReentrantMonitor("MediaDecoder::FrameStats"),
         mParsedFrames(0),
         mDecodedFrames(0),
         mPresentedFrames(0),
-        mDroppedFrames(0),
-        mCorruptFrames(0) {}
+        mDroppedFrames(0) {}
 
     // Returns number of frames which have been parsed from the media.
     // Can be called on any thread.
     uint32_t GetParsedFrames() {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mParsedFrames;
     }
 
@@ -961,23 +960,17 @@ public:
     uint32_t GetPresentedFrames() {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mPresentedFrames;
     }
 
     // Number of frames that have been skipped because they have missed their
     // compoisition deadline.
     uint32_t GetDroppedFrames() {
-      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-      return mDroppedFrames + mCorruptFrames;
-    }
-
-    uint32_t GetCorruptedFrames() {
-      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-      return mCorruptFrames;
+      return mDroppedFrames;
     }
 
     // Increments the parsed and decoded frame counters by the passed in counts.
     // Can be called on any thread.
     void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
                              uint32_t aDropped) {
       if (aParsed == 0 && aDecoded == 0 && aDropped == 0)
         return;
@@ -989,21 +982,16 @@ public:
 
     // Increments the presented frame counters.
     // Can be called on any thread.
     void NotifyPresentedFrame() {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       ++mPresentedFrames;
     }
 
-    void NotifyCorruptFrame() {
-      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-      ++mCorruptFrames;
-    }
-
   private:
 
     // ReentrantMonitor to protect access of playback statistics.
     ReentrantMonitor mReentrantMonitor;
 
     // Number of frames parsed and demuxed from media.
     // Access protected by mReentrantMonitor.
     uint32_t mParsedFrames;
@@ -1012,18 +1000,16 @@ public:
     // Access protected by mReentrantMonitor.
     uint32_t mDecodedFrames;
 
     // Number of decoded frames which were actually sent down the rendering
     // pipeline to be painted ("presented"). Access protected by mReentrantMonitor.
     uint32_t mPresentedFrames;
 
     uint32_t mDroppedFrames;
-
-    uint32_t mCorruptFrames;
   };
 
   // Return the frame decode/paint related statistics.
   FrameStatistics& GetFrameStatistics() { return mFrameStats; }
 
   // Increments the parsed and decoded frame counters by the passed in counts.
   // Can be called on any thread.
   virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -261,18 +261,16 @@ public:
   }
 
   // Returns true if the reader implements RequestAudioData()
   // and RequestVideoData() asynchronously, rather than using the
   // implementation in this class to adapt the old synchronous to
   // the newer async model.
   virtual bool IsAsync() const { return false; }
 
-  virtual void DisableHardwareAcceleration() {}
-
 protected:
   virtual ~MediaDecoderReader();
 
   // Overrides of this function should decodes an unspecified amount of
   // audio data, enqueuing the audio data in mAudioQueue. Returns true
   // when there's more audio to decode, false if the audio is finished,
   // end of file has been reached, or an un-recoverable read error has
   // occured. This function blocks until the decode is complete.
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -239,18 +239,16 @@ MediaDecoderStateMachine::MediaDecoderSt
   mDecodeThreadWaiting(false),
   mDropAudioUntilNextDiscontinuity(false),
   mDropVideoUntilNextDiscontinuity(false),
   mDecodeToSeekTarget(false),
   mWaitingForDecoderSeek(false),
   mCancelingSeek(false),
   mCurrentTimeBeforeSeek(0),
   mLastFrameStatus(MediaDecoderOwner::NEXT_FRAME_UNINITIALIZED),
-  mCorruptFrames(30),
-  mDisabledHardwareAcceleration(false),
   mDecodingFrozenAtStateDecoding(false),
   mSentLoadedMetadataEvent(false),
   mSentFirstFrameLoadedEvent(false)
 {
   MOZ_COUNT_CTOR(MediaDecoderStateMachine);
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
   static bool sPrefCacheInit = false;
@@ -3000,33 +2998,16 @@ void MediaDecoderStateMachine::RenderVid
   }
 
   VERBOSE_LOG("playing video frame %lld (queued=%i, state-machine=%i, decoder-queued=%i)",
               aData->mTime, VideoQueue().GetSize() + mReader->SizeOfVideoQueueInFrames(),
               VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames());
 
   VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
   if (container) {
-    if (aData->mImage && !aData->mImage->IsValid()) {
-      MediaDecoder::FrameStatistics& frameStats = mDecoder->GetFrameStatistics();
-      frameStats.NotifyCorruptFrame();
-      // If more than 10% of the last 30 frames have been corrupted, then try disabling
-      // hardware acceleration. We use 10 as the corrupt value because RollingMean<>
-      // only supports integer types.
-      mCorruptFrames.insert(10);
-      if (!mDisabledHardwareAcceleration &&
-          mReader->VideoIsHardwareAccelerated() &&
-          frameStats.GetPresentedFrames() > 30 &&
-          mCorruptFrames.mean() >= 1 /* 10% */) {
-        DecodeTaskQueue()->Dispatch(NS_NewRunnableMethod(mReader, &MediaDecoderReader::DisableHardwareAcceleration));
-        mDisabledHardwareAcceleration = true;
-      }
-    } else {
-      mCorruptFrames.insert(0);
-    }
     container->SetCurrentFrame(ThebesIntSize(aData->mDisplay), aData->mImage,
                                aTarget);
     MOZ_ASSERT(container->GetFrameDelay() >= 0 || IsRealTime());
   }
 }
 
 void MediaDecoderStateMachine::ResyncAudioClock()
 {
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -85,17 +85,16 @@ hardware (via AudioStream).
 #include "mozilla/Attributes.h"
 #include "nsThreadUtils.h"
 #include "MediaDecoder.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "MediaDecoderReader.h"
 #include "MediaDecoderOwner.h"
 #include "MediaMetadataManager.h"
 #include "MediaDecoderStateMachineScheduler.h"
-#include "mozilla/RollingMean.h"
 
 class nsITimer;
 
 namespace mozilla {
 
 class AudioSegment;
 class VideoSegment;
 class MediaTaskQueue;
@@ -1135,20 +1134,16 @@ protected:
   // Stores presentation info required for playback. The decoder monitor
   // must be held when accessing this.
   MediaInfo mInfo;
 
   mozilla::MediaMetadataManager mMetadataManager;
 
   MediaDecoderOwner::NextFrameStatus mLastFrameStatus;
 
-  mozilla::RollingMean<uint32_t, uint32_t> mCorruptFrames;
-
-  bool mDisabledHardwareAcceleration;
-
   // mDecodingFrozenAtStateDecoding: turn on/off at
   //                                 SetDormant/Seek,Play.
   bool mDecodingFrozenAtStateDecoding;
 
   // True if we are back from DECODER_STATE_DORMANT state and
   // LoadedMetadataEvent was already sent.
   bool mSentLoadedMetadataEvent;
   // True if we are back from DECODER_STATE_DORMANT state and
--- a/dom/media/fmp4/MP4Reader.cpp
+++ b/dom/media/fmp4/MP4Reader.cpp
@@ -570,36 +570,16 @@ MP4Reader::GetDecoderData(TrackType aTra
 
 Microseconds
 MP4Reader::GetNextKeyframeTime()
 {
   MonitorAutoLock mon(mDemuxerMonitor);
   return mDemuxer->GetNextKeyframeTime();
 }
 
-void
-MP4Reader::DisableHardwareAcceleration()
-{
-  if (HasVideo() && !mIsEncrypted && mSharedDecoderManager) {
-    mPlatform->DisableHardwareAcceleration();
-
-    const VideoDecoderConfig& video = mDemuxer->VideoConfig();
-    if (!mSharedDecoderManager->Recreate(mPlatform, video, mLayersBackendType, mDecoder->GetImageContainer())) {
-      MonitorAutoLock mon(mVideo.mMonitor);
-      mVideo.mError = true;
-      if (mVideo.HasPromise()) {
-        mVideo.RejectPromise(DECODE_ERROR, __func__);
-      }
-    } else {
-      MonitorAutoLock lock(mVideo.mMonitor);
-      ScheduleUpdate(kVideo);
-    }
-  }
-}
-
 bool
 MP4Reader::ShouldSkip(bool aSkipToNextKeyframe, int64_t aTimeThreshold)
 {
   // The MP4Reader doesn't do normal skip-to-next-keyframe if the demuxer
   // has exposes where the next keyframe is. We can then instead skip only
   // if the time threshold (the current playback position) is after the next
   // keyframe in the stream. This means we'll only skip frames that we have
   // no hope of ever playing.
@@ -632,19 +612,17 @@ MP4Reader::RequestVideoData(bool aSkipTo
     if (!eos && NS_FAILED(mVideo.mDecoder->Flush())) {
       NS_WARNING("Failed to skip/flush video when skipping-to-next-keyframe.");
     }
     mDecoder->NotifyDecodedFrames(parsed, 0, parsed);
   }
 
   MonitorAutoLock lock(mVideo.mMonitor);
   nsRefPtr<VideoDataPromise> p = mVideo.mPromise.Ensure(__func__);
-  if (mVideo.mError) {
-    mVideo.mPromise.Reject(DECODE_ERROR, __func__);
-  } else if (eos) {
+  if (eos) {
     mVideo.mPromise.Reject(END_OF_STREAM, __func__);
   } else {
     ScheduleUpdate(kVideo);
   }
 
   return p;
 }
 
--- a/dom/media/fmp4/MP4Reader.h
+++ b/dom/media/fmp4/MP4Reader.h
@@ -76,18 +76,16 @@ public:
     MOZ_OVERRIDE;
 
   virtual nsresult ResetDecode() MOZ_OVERRIDE;
 
   virtual nsRefPtr<ShutdownPromise> Shutdown() MOZ_OVERRIDE;
 
   virtual bool IsAsync() const MOZ_OVERRIDE { return true; }
 
-  virtual void DisableHardwareAcceleration() MOZ_OVERRIDE;
-
 private:
 
   bool InitDemuxer();
   void ReturnOutput(MediaData* aData, TrackType aTrack);
 
   // Sends input to decoder for aTrack, and output to the state machine,
   // if necessary.
   void Update(TrackType aTrack);
--- a/dom/media/fmp4/PlatformDecoderModule.h
+++ b/dom/media/fmp4/PlatformDecoderModule.h
@@ -130,18 +130,16 @@ public:
   // If more audio codec is to be supported, SupportsAudioMimeType will have
   // to be extended
   virtual bool SupportsAudioMimeType(const char* aMimeType);
   virtual bool SupportsVideoMimeType(const char* aMimeType);
 
   // Indicates if the video decoder requires AVCC format.
   virtual bool DecoderNeedsAVCC(const mp4_demuxer::VideoDecoderConfig& aConfig);
 
-  virtual void DisableHardwareAcceleration() {}
-
 protected:
   PlatformDecoderModule() {}
   virtual ~PlatformDecoderModule() {}
   // Caches pref media.fragmented-mp4.use-blank-decoder
   static bool sUseBlankDecoder;
   static bool sFFmpegDecoderEnabled;
   static bool sGonkDecoderEnabled;
   static bool sAndroidMCDecoderPreferred;
--- a/dom/media/fmp4/SharedDecoderManager.cpp
+++ b/dom/media/fmp4/SharedDecoderManager.cpp
@@ -88,32 +88,16 @@ SharedDecoderManager::CreateVideoDecoder
     nsresult rv = mDecoder->Init();
     NS_ENSURE_SUCCESS(rv, nullptr);
   }
 
   nsRefPtr<SharedDecoderProxy> proxy(new SharedDecoderProxy(this, aCallback));
   return proxy.forget();
 }
 
-bool
-SharedDecoderManager::Recreate(PlatformDecoderModule* aPDM,
-                               const mp4_demuxer::VideoDecoderConfig& aConfig,
-                               layers::LayersBackend aLayersBackend,
-                               layers::ImageContainer* aImageContainer)
-{
-  mDecoder->Flush();
-  mDecoder->Shutdown();
-  mDecoder = aPDM->CreateVideoDecoder(aConfig, aLayersBackend, aImageContainer, mTaskQueue, mCallback);
-  if (!mDecoder) {
-    return false;
-  }
-  nsresult rv = mDecoder->Init();
-  return rv == NS_OK;
-}
-
 void
 SharedDecoderManager::Select(SharedDecoderProxy* aProxy)
 {
   if (mActiveProxy == aProxy) {
     return;
   }
   SetIdle(mActiveProxy);
 
--- a/dom/media/fmp4/SharedDecoderManager.h
+++ b/dom/media/fmp4/SharedDecoderManager.h
@@ -35,21 +35,16 @@ public:
   void Select(SharedDecoderProxy* aProxy);
   void SetIdle(MediaDataDecoder* aProxy);
   void ReleaseMediaResources();
   void Shutdown();
 
   friend class SharedDecoderProxy;
   friend class SharedDecoderCallback;
 
-  bool Recreate(PlatformDecoderModule* aPDM,
-    const mp4_demuxer::VideoDecoderConfig& aConfig,
-    layers::LayersBackend aLayersBackend,
-    layers::ImageContainer* aImageContainer);
-
 private:
   virtual ~SharedDecoderManager();
   void DrainComplete();
 
   nsRefPtr<MediaDataDecoder> mDecoder;
   nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
   SharedDecoderProxy* mActiveProxy;
   MediaDataDecoderCallback* mActiveCallback;
--- a/dom/media/fmp4/wmf/WMFDecoderModule.h
+++ b/dom/media/fmp4/wmf/WMFDecoderModule.h
@@ -32,21 +32,16 @@ public:
   virtual already_AddRefed<MediaDataDecoder>
   CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
                      FlushableMediaTaskQueue* aAudioTaskQueue,
                      MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
 
   bool SupportsVideoMimeType(const char* aMimeType) MOZ_OVERRIDE;
   bool SupportsAudioMimeType(const char* aMimeType) MOZ_OVERRIDE;
 
-  virtual void DisableHardwareAcceleration() MOZ_OVERRIDE
-  {
-    sDXVAEnabled = false;
-  }
-
   // Accessors that report whether we have the required MFTs available
   // on the system to play various codecs. Windows Vista doesn't have the
   // H.264/AAC decoders if the "Platform Update Supplement for Windows Vista"
   // is not installed.
   static bool HasAAC();
   static bool HasH264();
 
   // Called on main thread.
--- a/dom/media/mediasource/MediaSourceReader.h
+++ b/dom/media/mediasource/MediaSourceReader.h
@@ -79,22 +79,16 @@ public:
 
   bool HasAudio() MOZ_OVERRIDE
   {
     return mInfo.HasAudio();
   }
 
   void NotifyTimeRangesChanged();
 
-  virtual void DisableHardwareAcceleration() MOZ_OVERRIDE {
-    if (GetVideoReader()) {
-      GetVideoReader()->DisableHardwareAcceleration();
-    }
-  }
-
   // We can't compute a proper start time since we won't necessarily
   // have the first frame of the resource available. This does the same
   // as chrome/blink and assumes that we always start at t=0.
   virtual int64_t ComputeStartTime(const VideoData* aVideo, const AudioData* aAudio) MOZ_OVERRIDE { return 0; }
 
   // Buffering heuristics don't make sense for MSE, because the arrival of data
   // is at least partly controlled by javascript, and javascript does not expect
   // us to sit on unplayed data just because it may not be enough to play
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -12,17 +12,16 @@
 
 namespace mozilla {
 namespace layers {
 
 
 D3D9SurfaceImage::D3D9SurfaceImage()
   : Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
   , mSize(0, 0)
-  , mValid(false)
 {}
 
 D3D9SurfaceImage::~D3D9SurfaceImage()
 {
   if (mTexture) {
     gfxWindowsPlatform::sD3D9SurfaceImageUsed -= mSize.width * mSize.height * 4;
   }
 }
@@ -149,47 +148,41 @@ D3D9SurfaceImage::SetData(const Data& aD
   mTexture = texture;
   mShareHandle = shareHandle;
   mSize = gfx::IntSize(region.width, region.height);
   mQuery = query;
 
   return S_OK;
 }
 
-bool
-D3D9SurfaceImage::IsValid()
-{
-  EnsureSynchronized();
-  return mValid;
-}
-
 void
 D3D9SurfaceImage::EnsureSynchronized()
 {
   RefPtr<IDirect3DQuery9> query = mQuery;
   if (!query) {
     // Not setup, or already synchronized.
     return;
   }
   int iterations = 0;
-  while (iterations < 10) {
-    HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH);
-    if (hr == S_FALSE) {
-      Sleep(1);
-      iterations++;
-      continue;
-    }
-    if (hr == S_OK) {
-      mValid = true;
-    }
-    break;
+  while (iterations < 10 && S_FALSE == query->GetData(nullptr, 0, D3DGETDATA_FLUSH)) {
+    Sleep(1);
+    iterations++;
   }
   mQuery = nullptr;
 }
 
+HANDLE
+D3D9SurfaceImage::GetShareHandle()
+{
+  // Ensure the image has completed its synchronization,
+  // and safe to used by the caller on another device.
+  EnsureSynchronized();
+  return mShareHandle;
+}
+
 const D3DSURFACE_DESC&
 D3D9SurfaceImage::GetDesc() const
 {
   return mDesc;
 }
 
 gfx::IntSize
 D3D9SurfaceImage::GetSize()
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -36,36 +36,39 @@ public:
 
   // Copies the surface into a sharable texture's surface, and initializes
   // the image.
   HRESULT SetData(const Data& aData);
 
   // Returns the description of the shared surface.
   const D3DSURFACE_DESC& GetDesc() const;
 
+  // Returns the HANDLE that can be used to open the image as a shared resource.
+  // If the operation to copy the original resource to the shared resource
+  // hasn't finished yet, this function blocks until the synchronization is
+  // complete.
+  HANDLE GetShareHandle();
+
   gfx::IntSize GetSize() MOZ_OVERRIDE;
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
 
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; }
 
-  virtual bool IsValid() MOZ_OVERRIDE;
-
 private:
 
   // Blocks the calling thread until the copy operation started in SetData()
   // is complete, whereupon the texture is safe to use.
   void EnsureSynchronized();
 
   gfx::IntSize mSize;
   RefPtr<IDirect3DTexture9> mTexture;
   RefPtr<IDirect3DQuery9> mQuery;
   RefPtr<TextureClient> mTextureClient;
   HANDLE mShareHandle;
   D3DSURFACE_DESC mDesc;
-  bool mValid;
 };
 
 } // namepace layers
 } // namespace mozilla
 
 #endif // GFX_D3DSURFACEIMAGE_H
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -168,18 +168,16 @@ public:
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() = 0;
 
   virtual GrallocImage* AsGrallocImage()
   {
     return nullptr;
   }
 
-  virtual bool IsValid() { return true; }
-
 protected:
   Image(void* aImplData, ImageFormat aFormat) :
     mImplData(aImplData),
     mSerial(++sSerialCounter),
     mFormat(aFormat),
     mSent(false)
   {}
 
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -142,23 +142,16 @@ ImageClientSingle::UpdateImage(ImageCont
 {
   AutoLockImage autoLock(aContainer);
 
   Image *image = autoLock.GetImage();
   if (!image) {
     return false;
   }
 
-  // Don't try to update to an invalid image. We return true because the caller
-  // would attempt to recreate the ImageClient otherwise, and that isn't going
-  // to help.
-  if (!image->IsValid()) {
-    return true;
-  }
-
   if (mLastPaintedImageSerial == image->GetSerial()) {
     return true;
   }
 
   RefPtr<TextureClient> texture = image->AsSharedImage()
                                 ? image->AsSharedImage()->GetTextureClient(this)
                                 : nullptr;