Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in ExtractorMediaSource #3796

Closed
ethanblake4 opened this issue Feb 5, 2018 · 2 comments
Closed

NPE in ExtractorMediaSource #3796

ethanblake4 opened this issue Feb 5, 2018 · 2 comments
Assignees
Labels

Comments

@ethanblake4
Copy link

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.

@tonihei
Copy link
Collaborator

tonihei commented Feb 5, 2018

Thanks for reporting. This is a bug caused by removing a currently playing or loading child MediaSource from the DynamicConcatenatingMediaSource. It seems this bug has been in the code all the time, but only recent changes in version 2.6.1 made the ExtractorMediaSource throw this NPE because of this bug.

We already have a fix which will be pushed to the dev-branch soon.

@tonihei tonihei added the bug label Feb 5, 2018
andrewlewis pushed a commit that referenced this issue Feb 8, 2018
This could happen when a media source is removed from a
DynamicConcatenatingMediaSource and one of its media periods is still active.
This media period is only removed by the player after the player received
a timeline update and thus we shouldn't release the removed child source
as long as it has active media periods.

Issue:#3796

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184522836
@tonihei
Copy link
Collaborator

tonihei commented Feb 9, 2018

Closing because issue is fixed on the dev branch.

@tonihei tonihei closed this as completed Feb 9, 2018
ojw28 pushed a commit that referenced this issue Feb 20, 2018
This could happen when a media source is removed from a
DynamicConcatenatingMediaSource and one of its media periods is still active.
This media period is only removed by the player after the player received
a timeline update and thus we shouldn't release the removed child source
as long as it has active media periods.

Issue:#3796

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=184522836
@google google locked and limited conversation to collaborators Jun 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants