ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

HLS: Allows playback through gap > maxBufferMs

Open stevemayhew opened this issue 3 years ago • 1 comments

This change fixes #8959

The issue is caused because the current logic assumes it is fully buffered after fetching minBufferMs worth of GAP segments, which of course contain no samples. ExoPlayer normally jumps past the GAP but the infinite buffering stall prevents this.

The fix changes the HLS implementation of SequenceableLoader.getBufferedPositionUs() so to not report a GAP segment as potentially adding to the buffered time. This allows deferring to the SampleQueue, a more complete source of truth.

Note the jump to end of the GAP occurs with no buffer, and loading has not triggered so at least one handler loop is required to prevent false trigger of the "Playback stuck buffering and not loading" error.

stevemayhew avatar Jun 11 '21 16:06 stevemayhew

Feel free to simply take this, change it around a bit or suggest a completely different approach.

I've done developer testing on the change with the sample URL I sent with the bug, it skips the gap now fine.

There is one additional bug I'm looking at where the gap jumps cause the check for AudioTrack timestamps to report an error (again probably a false error because the actual time is exactly the end of the GAP):

com.google.android.exoplayer2.audio.AudioSink$UnexpectedDiscontinuityException: Unexpected audio track timestamp discontinuity: expected 78250666, got 130129999

stevemayhew avatar Jun 11 '21 17:06 stevemayhew

Apologies for the silence @stevemayhew, we're pretty busy focused getting media3 stable out. Can I get back this PR once we start working towards ExoPlayer 2.19/media3 1.1.0, where this PR will be included anyway?

christosts avatar Dec 09 '22 14:12 christosts

Absolutely, I can close it and move it to media3. I posted a question over there if there are any tools or best practices for doing this and preserving history.

I'm thinking to do the packaging move on a branch here in our ExoPlayer fork then moving it somehow to media3. If you guys have any tips on how you did that we'd appreciate it and just move our pull requests there

Thanks @christosts, and no worries on quick replies we're both pressed for schedules so totally understand

We're shipping with these changes in our current 2.15.1 release so will watch for issues and keep this pull up to date

stevemayhew avatar Dec 09 '22 21:12 stevemayhew

I posted a question over there if there are any tools or best practices for doing this and preserving history.

@marcbaechinger is the best person to answer https://github.com/androidx/media/issues/217 and I see he's already on it :)

We're shipping with these changes in our current 2.15.1 release so will watch for issues and keep this pull up to date

Thank you very much for your contributions

christosts avatar Dec 12 '22 17:12 christosts

@stevemayhew Thank you for this changes and PR. We are using it with Exo 2.18.1 and it works perfectly for our use cases in our project.

However we've identified one use case that is not covered and I want to ask if you can help on that also.

We have also VAST for ads played with Exo.

Problem is: If there is a stream with gap in the first segment and there is ad played before stream is started then the player remains stuck in buffering. Manual skip to any position will fix the issue with this PR changes as player will skip the gap also and resumes from first available segment.

Thanks!

sebastiangansca avatar Jan 18 '23 10:01 sebastiangansca

Closing all PRs on this deprecated project. We are now unable to merge PRs from here. If you would like us to consider this change again please file a new PR on the media3 project: https://github.com/androidx/media/pulls

icbaker avatar Apr 15 '24 09:04 icbaker

@icbaker thanks for the heads up, we definitely need to re-open this under Androidx as we are shipping with this change for over a year. Hopefully we can get more traction towards reviewing and merging it there.

@sebastiangansca VAST playback is not a use case we have tested with pre-roll, we use VAST to play trailers with no content (a SilenceMediaSource) with the extension-ima plugin. I would open a bug with AndroidX/Media3 with your use case (not a big migration from 2.18.1) once I have the pull request migrated then I can comment on it. Kind of pointless here as the ExoPlayer project is deprecated.

stevemayhew avatar Apr 15 '24 19:04 stevemayhew