Bug 1542440 - Recycle sample directly rather than through CodecProxy. r=jya
authorJohn Lin <jolin@mozilla.com>
Mon, 08 Apr 2019 09:16:20 +0000
changeset 468379 7c78dd202b344a1d1b0e3d04626822945a914a32
parent 468378 c568adf3602bce1d618a00f3e97b7361b8d540db
child 468380 ad81972ae3f690ae475ecaadf9454cb1074b3532
push id35835
push useraciure@mozilla.com
push dateMon, 08 Apr 2019 19:00:29 +0000
treeherdermozilla-central@40456af7da1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1542440
milestone68.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 1542440 - Recycle sample directly rather than through CodecProxy. r=jya mJavaDecoder is invalid after the decoder is shut down and should never be used. Differential Revision: https://phabricator.services.mozilla.com/D26438
dom/media/platforms/android/RemoteDataDecoder.cpp
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Sample.java
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -238,17 +238,17 @@ class RemoteVideoDecoder : public Remote
           &RemoteVideoDecoder::ProcessOutput, std::move(aSample)));
       MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
       Unused << rv;
       return;
     }
 
     AssertOnTaskQueue();
     if (GetState() == State::SHUTDOWN) {
-      mJavaDecoder->DisposeOutput(aSample);
+      aSample->Dispose();
       return;
     }
 
     UniquePtr<VideoData::Listener> releaseSample(
         new CompositeListener(mJavaDecoder, aSample));
 
     BufferInfo::LocalRef info = aSample->Info();
     MOZ_ASSERT(info);
@@ -422,17 +422,17 @@ class RemoteAudioDecoder : public Remote
       MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
       Unused << rv;
       return;
     }
 
     AssertOnTaskQueue();
 
     if (GetState() == State::SHUTDOWN || !aBuffer->IsValid()) {
-      mJavaDecoder->DisposeOutput(aSample);
+      aSample->Dispose();
       return;
     }
 
     RenderOrReleaseOutput autoRelease(mJavaDecoder, aSample);
 
     BufferInfo::LocalRef info = aSample->Info();
     MOZ_ASSERT(info);
 
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
@@ -407,28 +407,16 @@ public final class CodecProxy {
             Log.e(LOGTAG, "remote fail to release output:" + sample.info.presentationTimeUs);
             e.printStackTrace();
         }
         sample.dispose();
 
         return true;
     }
 
-    // Dispose Sample objects without sending requests to remote codec.
-    // Native callbacks use this method instead of releaseOutput() to save
-    // unnecessary IPC calls when recycling samples that have been released by
-    // release() or flush().
-    @WrapForJNI
-    public void disposeOutput(final Sample sample) {
-        if (mOutputSurface != null) {
-            mSurfaceOutputs.remove(sample);
-        }
-        sample.dispose();
-    }
-
     /* package */ void reportError(final boolean fatal) {
         mCallbacks.reportError(fatal);
     }
 
     private synchronized SampleBuffer getOutputBuffer(final int id) {
         if (mRemote == null) {
             Log.e(LOGTAG, "cannot get buffer#" + id + " from an ended codec");
             return null;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Sample.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Sample.java
@@ -93,16 +93,17 @@ public final class Sample implements Par
         cryptoInfo.set(crypto.numSubSamples,
                        crypto.numBytesOfClearData,
                        crypto.numBytesOfEncryptedData,
                        crypto.key,
                        crypto.iv,
                        crypto.mode);
     }
 
+    @WrapForJNI
     public void dispose() {
         if (isEOS()) {
             return;
         }
 
         bufferId = NO_BUFFER;
         info.set(0, 0, 0, 0);
         if (cryptoInfo != null) {