media: NPE in HlsSampleStreamWrapper

Version

Media3 1.6.1

More version details

No response

Devices that reproduce the issue

Seems to be happening across a wide variety of devices and android versions (Samsung, Redmi, Oppo, Sony, Motorozola devices on Android versions 10,11,12,13, and 15)

Devices that do not reproduce the issue

Unknown

Reproducible in the demo app?

No

Reproduction steps

Unfortunately I don’t have repro steps

Expected result

The app doesn’t crash

Actual result

The app crashes with the following stack trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.media3.exoplayer.hls.n.c()' on a null object reference
    at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.mapSampleQueuesToMatchTrackGroups(HlsSampleStreamWrapper.java:1370)
    at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.maybeFinishPrepare(HlsSampleStreamWrapper.java:1344)
    at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.$r8$lambda$UK4TNmzu4rF7l558xzg8C7fYdDI(HlsSampleStreamWrapper.java:0)
    at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper$$ExternalSyntheticLambda1.run(HlsSampleStreamWrapper:0)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.os.HandlerThread.run(HandlerThread.java:67)

Media

Seems to only be happening for HLS streams but I can’t point to any specific media.

Bug Report

  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

@tianyif Sure. The problem is related to my architecture and lifecycle. I have a PlayerManager class that is injected into a ViewModel. The VM gets instances of ExoPlayer and DefaultPreloadManager from the PlayerManger. The VM was also releasing the DefaultPreloadManager in onCleared which in itself was fine. The problem is that PlayerManager is injected as a singleton, and it is also injected into a Service. The crash happens if I exit the UI of the application while the service is running and return to the UI while the service continues to run. In this case, the VM would receive the same instance of PlayerManager which would provide the same instance of DefaultPreloadManager that it provided before… which has already been released. So then as soon as I tried playing anything, it crashes.

@tianyif Thank you! I will get a new app version with this change out asap and report back.