-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Increase playlist stuck target duration coefficient and catch BehindLiveWindowExceptions properly #7661
Conversation
generally this looks good to me but we need to keep track of those "copy" classes somewhere. In the event that ExoPlayer gets updated we would also have to check if have to update / replace / remove these copy classes as well. |
Yes, unfortunately, that's the only disadvantage of this, but I don't think we have a choice if we want to improve ExoPlayer's default behavior. |
I also currently don't like the PR as it introduces a bunch of copy-paste code... jada jada see above comments Wouldn't it be better if we implement the change into
We could also fork Exoplayer and build a custom version with the fix. However that might be to complex (e.g. the building part). Fun Fact: |
Let's please do this. It will be ironic and hilarious. |
what I just noticed: it should already be customizable. See this commit: |
Yes, but we need to pass an |
Uhm I don't see a problem here: --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java
+++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java
@@ -8,12 +8,17 @@ import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.SingleSampleMediaSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
+import com.google.android.exoplayer2.source.hls.HlsDataSourceFactory;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
+import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker;
+import com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistParserFactory;
+import com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker;
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
+import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.TransferListener;
public class PlayerDataSource {
@@ -45,7 +50,16 @@ public class PlayerDataSource {
return new HlsMediaSource.Factory(cachelessDataSourceFactory)
.setAllowChunklessPreparation(true)
.setLoadErrorHandlingPolicy(
- new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY));
+ new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY))
+ .setPlaylistTrackerFactory(
+ (dataSourceFactory, loadErrorHandlingPolicy, playlistParserFactory) ->
+ new DefaultHlsPlaylistTracker(
+ dataSourceFactory,
+ loadErrorHandlingPolicy,
+ playlistParserFactory,
+ /* playlistStuckTargetDurationCoefficient */ 10.0
+ )
+ );
}
public DashMediaSource.Factory getLiveDashMediaSourceFactory() { |
134578b
to
81e6bea
Compare
81e6bea
to
7c2af00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost perfect
app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java
Show resolved
Hide resolved
Importing database into this APK is causing it to close at the splash screen without crashing. This isn't happening on other PR APKs. Edit: It's happening on all the 3 APKs I downloaded just now: seamless switching, livestream quality selector, and this. Maybe a bug slipped into the dev branch? |
See #7674. I just need to rebase all my PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have anything to add, code looks good, the comment by litetex just needs to be solved :-)
Instead of trying to reload the play queue manager and then throwing an error, BehindLiveWindowExceptions now make the app seek to the default playback position, like recommended by ExoPlayer. The buffering state is shown in this case. Error handling of other exceptions is not changed.
…o allow more stucking on HLS livestreams ExoPlayer's default behavior is to use a multiplication of target segment by a coefficient (3,5). This coefficient (and this behavior) cannot be customized without using a custom HlsPlaylistTracker right now. New behavior is to wait 15 seconds before throwing a PlaylistStuckException. This should improve a lot HLS live streaming on (very) low-latency livestreams with buffering issues, especially on YouTube with their HLS manifests.
…Tracker They seem to be wrong, by looking at the class work and at the return of CustomHlsPlaylistTracker's methods.
7c2af00
to
52cc4a0
Compare
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
Watched some livestreams for a few minutes and everything worked fine 😄
What is it?
Description of the changes in your PR
Set a bigger delay before throwing a
PlaylistStuckException
(15 * TARGET_DURATION_OF_A_SEGMENT
) than ExoPlayer's delay (3.5 * TARGET_DURATION_OF_A_SEGMENT
), to improve streaming experience on livestreams.Indeed, I noticed that sometimes, YouTube HLS manifests of livestreams are being stuck sometimes randomly, for a few seconds, and sometimes very frequently (I don't know if that's a YouTube throttling or not), where livestreams on the website/biggest official clients are playing mostly fine. For low or ultralow latency livestreams, this stucking results right now in a exception which is thrown very quickly (sometimes after 1 or 2 second), which makes the livestream unplayable.
This PR also fixes a bug when ExoPlayer encounter a
BehindLiveWindowException
: the play queue manager was reloaded to try to reload the stream and then an error was thrown. It makes no sense to do this, so this PR makes the player seek instead to the default position, preparing again ExoPlayer (like recommended by ExoPlayer's website) and don't throw an error.Fixes the following issue(s)
No issue I found was opened for these bugs.
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence