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 bugreportto 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)
@tianyif Sure. The problem is related to my architecture and lifecycle. I have a
PlayerManagerclass that is injected into a ViewModel. The VM gets instances ofExoPlayerandDefaultPreloadManagerfrom thePlayerManger. The VM was also releasing theDefaultPreloadManagerinonClearedwhich in itself was fine. The problem is thatPlayerManageris injected as a singleton, and it is also injected into aService. 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 ofPlayerManagerwhich would provide the same instance ofDefaultPreloadManagerthat 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.