Skip to content

NPE in ExtractorMediaSource #3796

@ethanblake4

Description

@ethanblake4

Stack trace:

java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.android.exoplayer2.source.MediaSource$Listener.onSourceInfoRefreshed(com.google.android.exoplayer2.source.MediaSource, com.google.android.exoplayer2.Timeline, java.lang.Object)' on a null object reference
        at com.google.android.exoplayer2.source.ExtractorMediaSource.notifySourceInfoRefreshed(ExtractorMediaSource.java:380)
        at com.google.android.exoplayer2.source.ExtractorMediaSource.onSourceInfoRefreshed(ExtractorMediaSource.java:372)
        at com.google.android.exoplayer2.source.ExtractorMediaPeriod.maybeFinishPrepare(ExtractorMediaPeriod.java:555)
        at com.google.android.exoplayer2.source.ExtractorMediaPeriod.access$000(ExtractorMediaPeriod.java:51)
        at com.google.android.exoplayer2.source.ExtractorMediaPeriod$1.run(ExtractorMediaPeriod.java:153)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.os.HandlerThread.run(HandlerThread.java:65)

This happened randomly when playing a new queue in my music player app. I wasn't doing anything different than usual, but here is the relevant code, slightly edited for clarity, that was executing at the time:

val i = 0; while (i < dynamicSource.size) {
     dynamicSource.removeMediaSource(i)
}
val sources = MutableList(tracks.size, { z -> sourceFromTrack(tracks[z]).second})
dynamicSource.addMediaSources(sources)

dynamicSource is a DynamicConcatenatingMediaSource.

sourceFromTrack returns an ExtractorMediaSource based on a MediaSource that tails from a RandomAccessFile.

This was tested on a Pixel 2 XL running 8.0.1 with ExoPlayer 2.6.1. I've tested the app hundreds of times and never seen this issue before so I cannot reproduce it. It appears that this is the same as #1914 but that issue is closed.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions