-
Notifications
You must be signed in to change notification settings - Fork 430
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
Unrecoverable SocketTimeoutExceptions when playing live streams #726
Comments
Does this issue only reproduce with Please can you provide a complete way for us to reproduce the problem (i.e. media links, and ideally a fork of the demo app that performs the problematic series of |
The exception is in I am not able to reproduce it if I do
or
|
In media3 1.1.1, change change to
change |
I'm not able to reproduce this in the demo app using the provided instructions. I seeked around a lot in 'UHD (MP4, H265)' and didn't generate any playback errors. |
Please can you try reproducing with okhttp 4.12? It mentions some possibly-related changes in the release notes. (I'm still unable to repro with 4.11) |
Ok I can try okhttp 4.12. Can you try to connect to charles proxy and may add some throttling? On my side some times I cannot reproduce once for several hours. Sometimes it just happens 10 seconds after playback. I think that's the nature of thread contention issues. |
Yes it is still reproducible with 4.12.0 in media3 demo. |
This probably should be a bug report. But that template is too hard to edit.
All testing are based on media3 1.1.1 and okhttp 4.11.0.
Our live streams are based short DASH or HLS manifests of about two minutes long. So when users perform seeks on our programs, we need to create new stream urls and send them to
exoPlayer
. That means every time user seeks, we need to create a newMediaItem
instance and callexoPlayer.setMediaItem()
andexoPlayer.prepare()
.Users have been reporting random network connection issues (not real network issues of course) and the only way to recover is to force kill and restart the app. I am also able to reproduce this issue randomly. It turns out
exoPlayer
randomly throws someSocketTimeoutException
s if we performexoPlayer.setMediaItem()
andexoPlayer.prepare()
repeatedly on the sameexoPlayer
instance.media3
had this commit to workaround some issues inokhttp
regarding thread interruption: 80928e7. But looks likemedia3
is still using thread interruptions here and there. For example:https://github.com/androidx/media/blob/1.1.1/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/upstream/Loader.java#L386
https://github.com/androidx/media/blob/1.1.1/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/upstream/Loader.java#L293
The stack trace is:
I added some logging code in
media3
1.1.1 so the line number doesn't match original 1.1.1 tag. The Loader.txt and OkhttpDataSource.txt are the modified source files.Loader.txt
OkhttpDataSource.txt
The logcats.txt is the corresponding logcat printed when this issue is reproduced.
logcats.txt
I also added a break pointer at
Thread.interrupt()
method with stack trace dump and evaluation of expression at the start ofThread.interrupt
method:"At: " + System.currentTimeMillis() + " Thread " + Thread.currentThread().getId() + " " + Thread.currentThread().getName() + " try to interrupt " + this.getId() + " " + this.getName()
ThreadInterrupts.txt
When these
SocketTimeoutException
s happen, the data probably reaches the device correctly (since the 200 code and correctResponseBody
length). The methodOkhttpDataSource.open
parses out the 200 response code and correct body length. But whenOkhttpDataSource.read
is called, the method throwsIOException
s due to thread interruptions. I think when you callexoPlayer.prepare
with newMediaItem
s frequently, there are some thread contentions.For example, in the logcat file at
15:51:33.318
, the call toOkhttpDataSource.open
is successful with correct body length 16, but the followingOkhttpDataSource.read
is blocked and eventually causes a time out after 10 seconds.What's the suggested way to work around these
SocketTimeoutException
s?The text was updated successfully, but these errors were encountered: