Bug 1510340 - p1: reduce ExoPlayer default buffer size. r=snorp
authorJohn Lin <jolin@mozilla.com>
Tue, 26 Feb 2019 14:57:02 +0000
changeset 519411 da7bf617583897d5618d81d9c2594ecdc789a87c
parent 519410 759ec998fe87daa4c1fd49608fe35fabd01239a5
child 519412 63b009fbe2bce5aa33df21754f2dcd5fd7e4aa4a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1510340
milestone67.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 1510340 - p1: reduce ExoPlayer default buffer size. r=snorp Differential Revision: https://phabricator.services.mozilla.com/D20419
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsPlayer.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsPlayer.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoHlsPlayer.java
@@ -59,16 +59,19 @@ public class GeckoHlsPlayer implements B
      *  Gecko media pipleine (in cpp). Once HLSDemuxer is created later, we
      *  need to bridge this HLSResource to the created demuxer. And they share
      *  the same GeckoHlsPlayer.
      *  mPlayerId is a token used for Gecko media pipeline to obtain corresponding player.
      */
     private final int mPlayerId;
     private boolean mExoplayerSuspended = false;
 
+    private static final int DEFAULT_MIN_BUFFER_MS = 5 * 1000;
+    private static final int DEFAULT_MAX_BUFFER_MS = 10 * 1000;
+
     private enum MediaDecoderPlayState {
         PLAY_STATE_PREPARING,
         PLAY_STATE_PAUSED,
         PLAY_STATE_PLAYING
     }
     // Default value is PLAY_STATE_PREPARING and it will be set to PLAY_STATE_PLAYING
     // once HTMLMediaElement calls PlayInternal().
     private MediaDecoderPlayState mMediaDecoderPlayState = MediaDecoderPlayState.PLAY_STATE_PREPARING;
@@ -557,25 +560,21 @@ public class GeckoHlsPlayer implements B
 
         // Prepare customized renderer
         mRenderers = new GeckoHlsRendererBase[2];
         mVRenderer = new GeckoHlsVideoRenderer(mComponentEventDispatcher);
         mARenderer = new GeckoHlsAudioRenderer(mComponentEventDispatcher);
         mRenderers[0] = mVRenderer;
         mRenderers[1] = mARenderer;
 
-        // Use default values for constructing DefaultLoadControl except maxBufferMs.
-        // See Bug 1424168.
-        int maxBufferMs = Math.max(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
-                                   DefaultLoadControl.DEFAULT_MAX_BUFFER_MS / 2);
         DefaultLoadControl dlc =
             new DefaultLoadControl(
                 new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE),
-                DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
-                maxBufferMs, /*this value can eliminate the memory usage immensely by experiment*/
+                DEFAULT_MIN_BUFFER_MS,
+                DEFAULT_MAX_BUFFER_MS,
                 DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
                 DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS);
         // Create ExoPlayer instance with specific components.
         mPlayer = ExoPlayerFactory.newInstance(mRenderers, mTrackSelector, dlc);
         mPlayer.addListener(this);
 
         Uri uri = Uri.parse(url);
         mMediaDataSourceFactory = buildDataSourceFactory(ctx, BANDWIDTH_METER);