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

Live audio streams stop suddenly (player stuck in buffering state) #1285

Closed
atul14 opened this issue Feb 19, 2016 · 16 comments
Closed

Live audio streams stop suddenly (player stuck in buffering state) #1285

atul14 opened this issue Feb 19, 2016 · 16 comments
Assignees
Labels

Comments

@atul14
Copy link

atul14 commented Feb 19, 2016

Hi,

Am trying to play audio streams using ExoPlayer(sample application). Have observed an issue that the streams suddenly stop playing after some time, and in the logcat I can see the logs like this -

E/AudioTrack: Discontinuity detected [expected 158217189, got 157209116]

Few more observations to help pin point the diagnosis -

  1. Mostly happening with Samsung Devices
  2. Checked with two devices
    a. Samsung Galaxy J2, Android Version 5.1.1
    b. Samsung Galaxy S4, Android Version 5.0.1
  3. Happens with most of the streams. One sample stream tried is
    a. http://67.212.165.106:8191
  4. When the issue occurs, the player states show "Buffering"
  5. At some rare times, the stream recovers, but most of the times, it doesn't recover and just stops.

Please help with the issue resolution.

@atul14
Copy link
Author

atul14 commented Feb 22, 2016

Can anybody help with this issue?

@isidoroDigio
Copy link

Hi,

I'm experiencing this issue also with Samsung Galaxy S6, but I didn't post any result because I don't have access to the device yet. But @ojw28 the issue that you are referencing is for Android 4.1.2 and the issue happen in 5.1.1 so the patch will not correct the error, don't you?

@ojw28
Copy link
Contributor

ojw28 commented Feb 22, 2016

I'm not referencing that issue. I referenced this issue from that issue (i.e. the other way around ;)). @atul14 - Things would be less confusing if you didn't cross-post the same thing in multiple places. Thanks!

Regarding this issue - We'll take a look when we have a chance, although any additional debugging work you can do to resolve the issue directly would be much appreciated.

@isidoroDigio
Copy link

Hahaha my bad!

@atul14
Copy link
Author

atul14 commented Feb 22, 2016

@ojw28 Thanks for your revert on the issue. Will follow this thread only. I will try to find out some additional info as much is possible. Meanwhile, in case you need any other info from Logcat etc, will be glad to provide. Thanks..

Meanwhile, @isidoroDigio also got reports on this issue from Samsung Galaxy S6, S6 Edge and Edge +

So, primarily with Samsung devices.

@ojw28
Copy link
Contributor

ojw28 commented Feb 22, 2016

I could reproduce the issue on a Nexus 5X. I'm not convinced that this isn't just a serving issue. The stream provided above quite often returns a 400 response code rather than a valid response, so the server seems pretty flaky. How certain are you that this isn't simply a connectivity issue (hence transitioning into the buffering state whilst the client attempts to recover the connection, followed by idle in the case that recovery wasn't possible)?

@atul14
Copy link
Author

atul14 commented Feb 22, 2016

Hi @ojw28 Thanks for the observation

Here is one more stream showing the same behavior - http://192.69.212.61:8020/live.

Just to rule out serving/network issue, I attempted to play the same stream at the same time(on the same Network) - one on the Samsung phone and other on the other player on my desktop(VLC)

The phone showed again the same behavior(almost after 15 minutes stream stopped), while VLC continued to work fine.
Again saw the error E/AudioTrack: Discontinuity detected [expected 693454648, got 692586486] and stream abruptly stopped.

@atul14
Copy link
Author

atul14 commented Feb 24, 2016

Hello @ojw28 Did you get a chance to look into this? Will be glad to provide any more details that could help investigation.

@atul14
Copy link
Author

atul14 commented Feb 25, 2016

Hi @ojw28 I saw your comment on #398 , Although couldn't reproduce the issue with the link mentioned, I could do that with the other link that I have. Also captured the adb bugreport. Here is the dropbox link for that
https://www.dropbox.com/s/pakhy7kym0tr7fe/bugreport.txt.zip?dl=0

  1. Stream played is http://192.69.212.61:8020/live with latest ExoPlayer v1.5.6
  2. Device used is Samsung Galaxy J2, Android Version 5.1.1. Hope this could help in the investigation
  3. One observation(could just be a shot in the dark) - issue seems more with streams on a lower bitrate as compared to ones with higher bitrate. May be something do with buffering etc.

@ojw28
Copy link
Contributor

ojw28 commented Feb 25, 2016

I don't think the "Discontinuity Detected" log messages are relevant to this issue. Instead, I think the issue occurs when the client's connection to the server is broken. ExoPlayer tries to recover, and one of two things happens:

  • ExoPlayer fails to re-establish a connection, an error is propagated and the state transitions to idle. This is working as intended.
  • ExoPlayer succeeds in re-establishing a connection, but the player gets stuck in a buffering state. There's an issue with how we're recovering the connection where the player incorrectly gauges how much media is buffered, causing it to get stuck thinking there's not sufficient media for playback to resume.

I think the second possibility is what you're seeing. If it is, you can work around the issue by ensuring that you always pass 0 as the third argument to ExoPlayer.Factory.newInstance. This should allow for successful recovery in the second case. Please could you test this and verify that it fixes the issue for you? We can investigate a proper fix in due course, but it might take a while.

@ojw28 ojw28 added the bug label Feb 25, 2016
@ojw28 ojw28 changed the title Audio Streams stop suddenly with "Discontinuity Detected" Audio Streams stop suddenly (player stuck in buffering state) Feb 25, 2016
@ojw28
Copy link
Contributor

ojw28 commented Feb 25, 2016

By the way, the issue isn't device specific. It can be reproduced across all devices fairly easily as follows:

  1. Play the stream for ~5 minutes.
  2. Quickly toggle WiFi off and on again using the pull-down drawer. This will force a connection break.

@atul14
Copy link
Author

atul14 commented Feb 25, 2016

Thanks @ojw28, will test the suggested solution and confirm

@ojw28 ojw28 changed the title Audio Streams stop suddenly (player stuck in buffering state) Live audio streams stop suddenly (player stuck in buffering state) Feb 25, 2016
@atul14
Copy link
Author

atul14 commented Feb 26, 2016

Hi @ojw28 tried the recommended solution, works well. Now the stream recovers automatically, though I experience a minor slutter of 2-3 seconds. Here is what I see in logcat now(and the audio restarts) -

02-26 06:12:56.718 30776-32211/com.test E/AudioTrack: Discontinuity detected [expected 347432789, got 346489886]
02-26 06:12:57.219 30776-32211/com.test W/AudioTrack: releaseBuffer() track 0xaf8c1580 disabled due to previous underrun, restarting
02-26 06:12:59.591 30776-32211/com.test W/AudioTrack: releaseBuffer() track 0xaf8c1580 disabled due to previous underrun, restarting

I guess, for now it's good to go. Thanks for that !! Do keep us posted on progress if there's a better fix !

Just a side note, don't know I was experiencing this issue more with Samsung devices, rather than other ones I tried(Lenovo, Nexus etc)

Thanks again.

@ojw28 ojw28 self-assigned this Feb 26, 2016
@atul14
Copy link
Author

atul14 commented Mar 3, 2016

HI @ojw28 After applying the fix and update, we are still getting reports regarding the issue from our live users in the Play Store.

Basically the issue seems to be related to buffering and recovery in case of low bandwidth networks or poor streams. The audio continuously slutters at times

Is there a plan soon to prioritize a fix for this?

Thanks

@ojw28
Copy link
Contributor

ojw28 commented Mar 6, 2016

Continuous stuttering will occur with the workaround in place specifically when there is insufficient bandwidth between the server and device. This is because the workaround is to set minRebufferMs=0. This is the duration of media that needs to be re-buffered for playback to resume after buffering. When it's set to 0 toggling between buffering and playing can occur rapidly if media is being fetched but at insufficient rate.

Once a "proper" fix is in place it will no longer be necessary to set minRebufferMs=0. The default value of 5000 will cause less frequent toggling between buffering and playing. Note however that playback will not be smooth. If there's insufficient bandwidth then there's not much we can do.

ojw28 added a commit that referenced this issue Jun 15, 2016
- Code is simpler. We only ever reset all tracks.
- Allows the standalone media clock to be updated properly. This
  allows simpler recovery for live streams in ExtractorSampleSource.
- Fixes #1285 and paves the way for a fix for #758.

Issue: #1285
Issue: #758
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120530682
@ojw28
Copy link
Contributor

ojw28 commented Aug 31, 2016

This issue is fixed properly in the dev-v2 branch.

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