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

Internal runtime error while adding new source to ConcatenatingMediaSource #4814

Closed
jaloveast1k opened this issue Sep 14, 2018 · 4 comments
Closed
Assignees
Labels

Comments

@jaloveast1k
Copy link

jaloveast1k commented Sep 14, 2018

So, I just updated from version
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.1'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.8.1'
to version
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.4'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.8.4'
And on most devices and emulators application started crashing, even tho it's still works fine on my main OnePlus 3 Android 8.0.

Exception occurs once I add an additional data source(-s) to ConcatenatingMediaSource in order to start preloading process of the next clips.
Here is first exception:

09-14 10:46:49.718 E/ExoPlayerImplInternal: Internal runtime error.
    java.lang.IllegalStateException
        at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:81)
        at com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker.start(DefaultHlsPlaylistTracker.java:99)
        at com.google.android.exoplayer2.source.hls.HlsMediaSource.prepareSourceInternal(HlsMediaSource.java:373)
        at com.google.android.exoplayer2.source.BaseMediaSource.prepareSource(BaseMediaSource.java:137)
        at com.google.android.exoplayer2.source.CompositeMediaSource.prepareChildSource(CompositeMediaSource.java:109)
        at com.google.android.exoplayer2.source.ConcatenatingMediaSource.addMediaSourceInternal(ConcatenatingMediaSource.java:554)
        at com.google.android.exoplayer2.source.ConcatenatingMediaSource.handleMessage(ConcatenatingMediaSource.java:468)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.deliverMessage(ExoPlayerImplInternal.java:861)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageToTarget(ExoPlayerImplInternal.java:829)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageInternal(ExoPlayerImplInternal.java:811)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:328)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:154)
        at android.os.HandlerThread.run(HandlerThread.java:61)`

And here is the second one, that happens right after the first "internal" one:
`09-14 10:46:49.860 E/AndroidRuntime: FATAL EXCEPTION: ExoPlayerImplInternal:Handler
    Process: media.soundstream.soundstream, PID: 8193
    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.upstream.Loader.release()' on a null object reference
        at com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker.stop(DefaultHlsPlaylistTracker.java:113)
        at com.google.android.exoplayer2.source.hls.HlsMediaSource.releaseSourceInternal(HlsMediaSource.java:404)
        at com.google.android.exoplayer2.source.BaseMediaSource.releaseSource(BaseMediaSource.java:150)
        at com.google.android.exoplayer2.source.CompositeMediaSource.releaseSourceInternal(CompositeMediaSource.java:65)
        at com.google.android.exoplayer2.source.ConcatenatingMediaSource.releaseSourceInternal(ConcatenatingMediaSource.java:423)
        at com.google.android.exoplayer2.source.BaseMediaSource.releaseSource(BaseMediaSource.java:150)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:802)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:731)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:353)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:154)
        at android.os.HandlerThread.run(HandlerThread.java:61)

I checked out the source code of DefaultHlsPlaylistTracker and I am kinda confused. The only place where initialPlaylistLoader sets to non null value is.. right after it gets checked on being non-null and Exception gets thrown.

Thank you in advance.

@ojw28
Copy link
Contributor

ojw28 commented Sep 14, 2018

Are you by any chance calling releaseSource on HlsMediaSource instances directly from application code? You shouldn't do that if so (see the releaseSource Javadoc).

@ojw28
Copy link
Contributor

ojw28 commented Sep 14, 2018

Or prepareSource for that matter. In general you shouldn't be calling any methods directly on an HlsMediaSource instance (its methods are for use by the player).

@ojw28 ojw28 self-assigned this Sep 14, 2018
@jaloveast1k
Copy link
Author

jaloveast1k commented Sep 14, 2018

Nope, I am not. Just creating those sources and feeding them to concatenatingMediaSource.
Like this:

for (int i = 0; i < playlist.size(); i++) {
    concatenatingMediaSource.addMediaSource(createMediaSource(playlist.get(i)));
}

private MediaSource createMediaSource(PlayerClipPresentationModel clip) {
        final Uri uri = getUri(clip);
        return hlsMediaSourceFactory.createMediaSource(uri);
}

The only release call I make is player.release(); once user is done with playing.
And in this particular case this is never happens.

First MediaSource doesn't cause a problem, it starts playing, everything is fine. But once I fetch next clips (1 or 2) and try to add them this exception occurs.

I also must say that an application with previous version of exoplayer (2.8.1) worked perfectly fine in production on 10k+ devices.

@ojw28 ojw28 added bug and removed need more info labels Sep 14, 2018
@ojw28 ojw28 assigned AquilesCanta and unassigned ojw28 Sep 14, 2018
@ojw28
Copy link
Contributor

ojw28 commented Sep 14, 2018

@AquilesCanta - f1fe1c4 broke the ability to call createMediaSource more than once on a HlsMediaSource.Factory. Please could you take a look?

@jaloveast1k - As a workaround you can create a new HlsMediaSource.Factory for each new instance of HlsMediaSource that you need to instantiate.

ojw28 pushed a commit that referenced this issue Sep 20, 2018
…instance

This allows creating multiple HLS media sources from a single Factory, as
required by the interface.

Issue:#4814

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213297850
@ojw28 ojw28 closed this as completed Sep 24, 2018
@google google locked and limited conversation to collaborators Jan 31, 2019
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

3 participants