From 8386d617bfeeed310b48996b095ec8fb8901cb65 Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 15 Sep 2020 13:34:49 +0100 Subject: [PATCH] Fix OOM-is-prevented test OOM-ing :) This test is intended to check that DefaultLoadControl will cause playback to fail as "stuck buffering" rather than OOM-ing, in the case that its target buffer size is reached and playback still hasn't started. Unfortunately, the target buffer size is ~130MB, and when running on some setups an OOM actually ends up happening before this much memory is allocated. This change makes the target buffer size much smaller to avoid the problem. PiperOrigin-RevId: 331748208 --- .../java/com/google/android/exoplayer2/ExoPlayerTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index b8f10a2dc2..444640256f 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -7330,6 +7330,10 @@ public final class ExoPlayerTest { @Test public void infiniteLoading_withSmallAllocations_oomIsPreventedByLoadControl_andThrowsStuckBufferingIllegalStateException() { + DefaultLoadControl loadControl = + new DefaultLoadControl.Builder() + .setTargetBufferBytes(10 * C.DEFAULT_BUFFER_SEGMENT_SIZE) + .build(); MediaSource continuouslyAllocatingMediaSource = new FakeMediaSource( new FakeTimeline(/* windowCount= */ 1), ExoPlayerTestRunner.VIDEO_FORMAT) { @@ -7387,6 +7391,7 @@ public final class ExoPlayerTest { new ExoPlayerTestRunner.Builder(context) .setActionSchedule(actionSchedule) .setMediaSources(continuouslyAllocatingMediaSource) + .setLoadControl(loadControl) .build(); ExoPlaybackException exception =