Backed out 2 changesets (bug 1517252)
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 11 Feb 2019 17:58:36 -0500
changeset 509648 ed5ff29947ed
parent 509647 b6b545883295
child 509649 1ea7b51ef5bb
push id1938
push userryanvm@gmail.com
push dateMon, 11 Feb 2019 23:33:35 +0000
treeherdermozilla-release@1ea7b51ef5bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1517252
milestone65.0.1
backs out8097c227b3e2
e02a44e4106a
Backed out 2 changesets (bug 1517252) Backed out changeset 8097c227b3e2 (bug 1517252) Backed out changeset e02a44e4106a (bug 1517252)
dom/media/hls/HLSDecoder.cpp
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsRendererBase.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -47,45 +47,46 @@ class HLSResourceCallbacksSupport
 };
 
 HLSResourceCallbacksSupport::HLSResourceCallbacksSupport(HLSDecoder* aDecoder)
     : mMutex("HLSResourceCallbacksSupport"), mDecoder(aDecoder) {
   MOZ_ASSERT(mDecoder);
 }
 
 void HLSResourceCallbacksSupport::Detach() {
-  MOZ_ASSERT(NS_IsMainThread());
   MutexAutoLock lock(mMutex);
   mDecoder = nullptr;
 }
 
 void HLSResourceCallbacksSupport::OnDataArrived() {
   HLS_DEBUG("HLSResourceCallbacksSupport", "OnDataArrived.");
   MutexAutoLock lock(mMutex);
   if (!mDecoder) {
     return;
   }
   RefPtr<HLSResourceCallbacksSupport> self = this;
   NS_DispatchToMainThread(NS_NewRunnableFunction(
       "HLSResourceCallbacksSupport::OnDataArrived", [self]() -> void {
+        MutexAutoLock lock(self->mMutex);
         if (self->mDecoder) {
           self->mDecoder->NotifyDataArrived();
         }
       }));
 }
 
 void HLSResourceCallbacksSupport::OnError(int aErrorCode) {
   HLS_DEBUG("HLSResourceCallbacksSupport", "onError(%d)", aErrorCode);
   MutexAutoLock lock(mMutex);
   if (!mDecoder) {
     return;
   }
   RefPtr<HLSResourceCallbacksSupport> self = this;
   NS_DispatchToMainThread(NS_NewRunnableFunction(
-      "HLSResourceCallbacksSupport::OnError", [self]() -> void {
+      "HLSResourceCallbacksSupport::OnDataArrived", [self]() -> void {
+        MutexAutoLock lock(self->mMutex);
         if (self->mDecoder) {
           // Since HLS source should be from the Internet, we treat all resource
           // errors from GeckoHlsPlayer as network errors.
           self->mDecoder->NetworkError(
               MediaResult(NS_ERROR_FAILURE, "HLS error"));
         }
       }));
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsAudioRenderer.java
@@ -8,17 +8,16 @@ import android.media.MediaCodec;
 import android.media.MediaCodec.BufferInfo;
 import android.media.MediaCodec.CryptoInfo;
 import android.os.Build;
 import android.util.Log;
 
 import org.mozilla.geckoview.BuildConfig;
 
 import com.google.android.exoplayer2.C;
-import com.google.android.exoplayer2.ExoPlaybackException;
 import com.google.android.exoplayer2.Format;
 import com.google.android.exoplayer2.RendererCapabilities;
 import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
 import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
 import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
 import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
 import com.google.android.exoplayer2.util.MimeTypes;
 
@@ -98,17 +97,17 @@ public class GeckoHlsAudioRenderer exten
     }
 
     @Override
     protected void handleReconfiguration(DecoderInputBuffer bufferForRead) {
         // Do nothing
     }
 
     @Override
-    protected void handleFormatRead(DecoderInputBuffer bufferForRead) throws ExoPlaybackException {
+    protected void handleFormatRead(DecoderInputBuffer bufferForRead) {
         onInputFormatChanged(mFormatHolder.format);
     }
 
     @Override
     protected void handleEndOfStream(DecoderInputBuffer bufferForRead) {
         mInputStreamEnded = true;
         mDemuxedInputSamples.offer(GeckoHLSSample.EOS);
     }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsRendererBase.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsRendererBase.java
@@ -6,17 +6,16 @@ package org.mozilla.gecko.media;
 
 import android.util.Log;
 
 import org.mozilla.geckoview.BuildConfig;
 
 import com.google.android.exoplayer2.BaseRenderer;
 import com.google.android.exoplayer2.C;
 import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
-import com.google.android.exoplayer2.ExoPlaybackException;
 import com.google.android.exoplayer2.Format;
 import com.google.android.exoplayer2.FormatHolder;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.Iterator;
 
@@ -37,19 +36,19 @@ public abstract class GeckoHlsRendererBa
 
     protected ByteBuffer mInputBuffer = null;
     protected ArrayList<Format> mFormats = new ArrayList<Format>();
     protected boolean mInitialized = false;
     protected boolean mWaitingForData = true;
     protected boolean mInputStreamEnded = false;
     protected long mFirstSampleStartTime = Long.MIN_VALUE;
 
-    protected abstract void createInputBuffer() throws ExoPlaybackException;
+    protected abstract void createInputBuffer();
     protected abstract void handleReconfiguration(DecoderInputBuffer bufferForRead);
-    protected abstract void handleFormatRead(DecoderInputBuffer bufferForRead) throws ExoPlaybackException;
+    protected abstract void handleFormatRead(DecoderInputBuffer bufferForRead);
     protected abstract void handleEndOfStream(DecoderInputBuffer bufferForRead);
     protected abstract void handleSamplePreparation(DecoderInputBuffer bufferForRead);
     protected abstract void resetRenderer();
     protected abstract boolean clearInputSamplesQueue();
     protected abstract void notifyPlayerInputFormatChanged(Format newFormat);
 
     private DecoderInputBuffer mBufferForRead =
         new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
@@ -141,17 +140,17 @@ public abstract class GeckoHlsRendererBa
         // Referring to ExoPlayer's MediaCodec related renderers, only video
         // renderer handles this.
     }
 
     protected void updateCSDInfo(Format format) {
         // do nothing.
     }
 
-    protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
+    protected void onInputFormatChanged(Format newFormat) {
         Format oldFormat;
         try {
             oldFormat = mFormats.get(mFormats.size() - 1);
         } catch (IndexOutOfBoundsException e) {
             oldFormat = null;
         }
         if (DEBUG) {
             Log.d(LOGTAG, "[onInputFormatChanged] old : " + oldFormat +
@@ -166,40 +165,36 @@ public abstract class GeckoHlsRendererBa
             resetRenderer();
             maybeInitRenderer();
         }
 
         updateCSDInfo(newFormat);
         notifyPlayerInputFormatChanged(newFormat);
     }
 
-    protected void maybeInitRenderer() throws ExoPlaybackException {
+    protected void maybeInitRenderer() {
         if (mInitialized || mFormats.size() == 0) {
             return;
         }
         if (DEBUG) { Log.d(LOGTAG, "Initializing ... "); }
-        try {
-            createInputBuffer();
-            mInitialized = true;
-        } catch (OutOfMemoryError e) {
-            throw ExoPlaybackException.createForRenderer(new RuntimeException(e), getIndex());
-        }
+        createInputBuffer();
+        mInitialized = true;
     }
 
     /*
      * The place we get demuxed data from HlsMediaSource(ExoPlayer).
      * The data will then be converted to GeckoHLSSample and deliver to
      * GeckoHlsDemuxerWrapper for further use.
      * If the return value is ture, that means a GeckoHLSSample is queued
      * successfully. We can try to feed more samples into queue.
      * If the return value is false, that means we might encounter following
      * situation 1) not initialized 2) input stream is ended 3) queue is full.
      * 4) format changed. 5) exception happened.
      */
-    protected synchronized boolean feedInputBuffersQueue() throws ExoPlaybackException {
+    protected synchronized boolean feedInputBuffersQueue() {
         if (!mInitialized || mInputStreamEnded || isQueuedEnoughData()) {
             // Need to reinitialize the renderer or the input stream has ended
             // or we just reached the maximum queue size.
             return false;
         }
 
         mBufferForRead.data = mInputBuffer;
         if (mBufferForRead.data != null) {
@@ -244,17 +239,17 @@ public abstract class GeckoHlsRendererBa
     private void maybeNotifyDataArrived() {
         if (mWaitingForData && isQueuedEnoughData()) {
             if (DEBUG) { Log.d(LOGTAG, "onDataArrived"); }
             mPlayerEventDispatcher.onDataArrived(getTrackType());
             mWaitingForData = false;
         }
     }
 
-    private void readFormat() throws ExoPlaybackException {
+    private void readFormat() {
         mflagsOnlyBuffer.clear();
         int result = readSource(mFormatHolder, mflagsOnlyBuffer, true);
         if (result == C.RESULT_FORMAT_READ) {
             onInputFormatChanged(mFormatHolder.format);
         }
     }
 
     @Override
@@ -288,17 +283,17 @@ public abstract class GeckoHlsRendererBa
     }
 
     /*
      * This is called by ExoPlayerImplInternal.java.
      * ExoPlayer checks the status of renderer, i.e. isReady() / isEnded(), and
      * calls renderer.render by passing its wall clock time.
      */
     @Override
-    public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
+    public void render(long positionUs, long elapsedRealtimeUs) {
         if (BuildConfig.DEBUG_BUILD) {
             Log.d(LOGTAG, "positionUs = " + positionUs +
                           ", mInputStreamEnded = " + mInputStreamEnded);
         }
         if (mInputStreamEnded) {
             return;
         }
         if (mFormats.size() == 0) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsVideoRenderer.java
@@ -8,17 +8,16 @@ import android.media.MediaCodec;
 import android.media.MediaCodec.BufferInfo;
 import android.media.MediaCodec.CryptoInfo;
 import android.os.Build;
 import android.util.Log;
 
 import org.mozilla.geckoview.BuildConfig;
 
 import com.google.android.exoplayer2.C;
-import com.google.android.exoplayer2.ExoPlaybackException;
 import com.google.android.exoplayer2.Format;
 import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
 import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
 import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
 import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
 import com.google.android.exoplayer2.RendererCapabilities;
 import com.google.android.exoplayer2.util.MimeTypes;
 
@@ -130,32 +129,27 @@ public class GeckoHlsVideoRenderer exten
             RendererCapabilities.ADAPTIVE_NOT_SEAMLESS;
         int formatSupport = decoderCapable ?
             RendererCapabilities.FORMAT_HANDLED :
             RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES;
         return adaptiveSupport | formatSupport;
     }
 
     @Override
-    protected final void createInputBuffer() throws ExoPlaybackException {
+    protected final void createInputBuffer() {
         assertTrue(mFormats.size() > 0);
         // Calculate maximum size which might be used for target format.
         Format currentFormat = mFormats.get(mFormats.size() - 1);
         mCodecMaxValues = getCodecMaxValues(currentFormat, mStreamFormats);
         // Create a buffer with maximal size for reading source.
         // Note : Though we are able to dynamically enlarge buffer size by
         // creating DecoderInputBuffer with specific BufferReplacementMode, we
         // still allocate a calculated max size buffer for it at first to reduce
         // runtime overhead.
-        try {
-            mInputBuffer = ByteBuffer.wrap(new byte[mCodecMaxValues.inputSize]);
-        } catch (OutOfMemoryError e) {
-            Log.e(LOGTAG, "cannot allocate input buffer of size " + mCodecMaxValues.inputSize, e);
-            throw ExoPlaybackException.createForRenderer(new Exception(e), getIndex());
-        }
+        mInputBuffer = ByteBuffer.wrap(new byte[mCodecMaxValues.inputSize]);
     }
 
     @Override
     protected void resetRenderer() {
         if (DEBUG) { Log.d(LOGTAG, "[resetRenderer] mInitialized = " + mInitialized); }
         if (mInitialized) {
             mRendererReconfigured = false;
             mRendererReconfigurationState = RECONFIGURATION_STATE.NONE;
@@ -182,17 +176,17 @@ public class GeckoHlsVideoRenderer exten
                 byte[] data = currentFormat.initializationData.get(i);
                 bufferForRead.data.put(data);
             }
             mRendererReconfigurationState = RECONFIGURATION_STATE.QUEUE_PENDING;
         }
     }
 
     @Override
-    protected void handleFormatRead(DecoderInputBuffer bufferForRead) throws ExoPlaybackException {
+    protected void handleFormatRead(DecoderInputBuffer bufferForRead) {
         if (mRendererReconfigurationState == RECONFIGURATION_STATE.QUEUE_PENDING) {
             if (DEBUG) { Log.d(LOGTAG, "[feedInput][QUEUE_PENDING] 2 formats in a row."); }
             // We received two formats in a row. Clear the current buffer of any reconfiguration data
             // associated with the first format.
             bufferForRead.clear();
             mRendererReconfigurationState = RECONFIGURATION_STATE.WRITE_PENDING;
         }
         onInputFormatChanged(mFormatHolder.format);