ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Android - OutOfMemoryError

Open ahmadbajwa8282 opened this issue 3 years ago • 4 comments

ExoPlayer Version

2.17.1

Devices that reproduce the issue

Redmi 9C Android 10 Redmi 6 Android 9

Devices that do not reproduce the issue

POCO X3 Samsung A32

Reproducible in the demo app?

No

Reproduction steps

not Reproduced.

Expected result

The video should be playing.

Actual result

Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again at java.lang.Thread.nativeCreate(Thread.java) at java.lang.Thread.start(Thread.java:883) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:975) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1382) at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:630) at com.google.android.exoplayer2.upstream.Loader$LoadTask.execute(Loader.java:7) at com.google.android.exoplayer2.upstream.Loader.startLoading(Loader.java:7) at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.startLoading(ProgressiveMediaPeriod.java:7) at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.prepare(ProgressiveMediaPeriod.java:7) at com.google.android.exoplayer2.source.MaskingMediaPeriod.prepare(MaskingMediaPeriod.java:2) at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeUpdateLoadingPeriod(ExoPlayerImplInternal.java:15) at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:8) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:225) at android.os.HandlerThread.run(HandlerThread.java:67)

Media

Not applicable

Bug Report

  • [ ] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

ahmadbajwa8282 avatar May 28 '22 05:05 ahmadbajwa8282

We need more info for this to be actionable. As this is an OutOfMemory I would suggest you try to reproduce this in the demo app and then create a bug report just after the issue happened in the demo app. Then you can send the bug report to [email protected] together with the URI to the media that produced that error.

This way you make the issue actionable for us and we can investigate your problem.

You was telling us you already sent a bug report, but I haven't found the email in the group. Sorry if I missed this, you can help me by telling me the subject you used or by sending the email again with subject 'Issue #10303'.

marcbaechinger avatar May 30 '22 10:05 marcbaechinger

Sorry for that. I did not forward any email related to this issue. This issue is only ouccers in production and I Don't know on which video it is producing OOM.

ahmadbajwa8282 avatar Jun 06 '22 05:06 ahmadbajwa8282

For what it's worth we were getting similar stack, in our case this is caused by the release technique

 /**
   * Releases {@link #keepSessionIdAudioTrack} asynchronously, if it is non-{@code null}.
   */
  private void releaseKeepSessionIdAudioTrack() {
    if (keepSessionIdAudioTrack == null) {
      return;
    }

    // AudioTrack.release can take some time, so we call it on a background thread.
    final AudioTrack toRelease = keepSessionIdAudioTrack;
    keepSessionIdAudioTrack = null;
    new Thread() {
      @Override
      public void run() {
        toRelease.release();
      }
    }.start();
  }

That causes issues in case of rapid exoplayer creation / release ( viewpager2 ) as there is not warranty when this release is going to happen. So in case of rapid scrolling or reinitializaiton in case of error this can happen.

daber avatar Oct 25 '22 09:10 daber

I can reliably reproduce the problem. Some Huawei devices have a limit on the number of threads, the maximum number of threads is 500, once the number of threads exceeds this, this crash will occur. Is to play the video in ExoPlay, if the loop is set, there will be too many Load threads created, depending on the number of threads will create 5, some will create 19.

If we don't turn loop on, then there will only be one thread of Load, which leads to this crash if we load multiple videos at the same time and loop them at the same time

Hopefully you can solve the problem of creating too many threads

By the way, the devices with this problem are Huawei Android 7.0,level 24, Android 8.0.0,level 26, Android 8.1.0,level 27

LQ753799168 avatar Nov 08 '23 07:11 LQ753799168