TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.65k stars 3.08k forks source link

Strange freeze behavior when playing videos in the background #8030

Closed silvaDominic closed 2 years ago

silvaDominic commented 2 years ago

Checklist

Affected version

~21.14+

Steps to reproduce the bug

  1. Open a video
  2. Play it in the background
  3. After several minutes the video will freeze and
    • never return to playback
    • return to playback when unlocking the phone or tapping the volume up/down button

Expected behavior

A video should play in the background, possibly buffer, and return to play once buffered without any human interaction.

Actual behavior

Video freezes and does not return playing unless intervening.

Screenshots/Screen recordings

https://user-images.githubusercontent.com/12387334/158082304-f23e5d1a-7ad5-4c18-b5ab-9d58bff4797b.mp4

Logs

This is not the error log for the above video

Usually this does not produce an error. However, while listening to a fireplace video last night, it did. Unfortunately, I accidentally saved the non-formatted version. Sorry :/

I was able to produce an error on same video stream as above.

Exception

com.google.android.exoplayer2.ExoPlaybackException: Source error
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:580)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:246)
    at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect
    at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:346)
    at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
    at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
    at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:101)
    at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:64)
    at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:177)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:417)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:923)
Caused by: java.net.UnknownHostException: Unable to resolve host "[manifest.googlevideo.com](http://manifest.googlevideo.com/)": No address associated with hostname
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
    at java.net.InetAddress.getAllByName(InetAddress.java:1152)
    at com.android.okhttp.Dns$1.lookup(Dns.java:41)
    at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:178)
    at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:144)
    at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:86)
    at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:192)
    at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:144)
    at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:106)
    at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:400)
    at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:333)
    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
    at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:90)
    at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:30)
    at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:608)
    at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:498)
    at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:339)
    ... 9 more
Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
    at libcore.io.Linux.android_getaddrinfo(Native Method)
    at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
    at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202)
    at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
    ... 27 more


Affected Android/Custom ROM version

Android 11

Affected device model

Samsung 10e

Additional information

This started occurring during the same time issue 8029 started happening. I know this because there are 2 routines where I use the background player for extended periods of time:

After the update, I was unable to use the background player for extended periods of time and had to just play it via the video player. Typically what happens is after 2-5 minutes the audio playback will freeze. I will interact with the phone which will immediately resume playback and then playback will continue to freeze every 30-60s.

What is particularly weird is that it does not appear to be a buffering issue. As you can see in the video, playback returns after the phone is unlocked. I was not able to capture it, but it also often returns when simply using the volume up/down keys without unlocking the phone. Mind you, that my internet speed is 300Mb/s in the above video. For the videos I watched on the train prior to the issue, my connection was significantly slower than this, relying only on data and I still never had this issue.

TacoTheDank commented 2 years ago

Seeing as your phone is a Samsung device, have you made sure that it's not just the system killing the app in the background?

See this for info: https://dontkillmyapp.com/samsung#android-11

silvaDominic commented 2 years ago

@TacoTheDank Wow just tested it and this fixed the issue. I also tested with a Sony device and the issue was not present.

This is the line from the link you provided that gave it away:

"Despite Android team promise to enforce OEMs to be transparent about non-standard app killing, in Android 11 Samsung has introduced a new severe (default ON) restriction. Apps can no longer hold wake lock in foreground services. This breaks many use-cases, for instance health apps are now unable to gather sensoric data for their users."

Within the same week as the update that created bug #6989 I had installed a new major Samsung update. I suspected that could have something to do with it, but given that the only app affected was NewPipe, and that there was already another issue, I associated it with that update. I also didn't have issues with other services playing in the background like Pandora/Spotify so that led me to believe it was even less to do with the Samsung update.

Great tip and thanks! I can finally use the main feature I got NewPipe for lol.

silvaDominic commented 2 years ago

Closing.

Issue was caused by Samsung update turning on battery optimization by default for all apps. This explains why playback would resume on wake/phone interactions.

More info here: https://dontkillmyapp.com/samsung#android-11

TacoTheDank commented 2 years ago

I have a Samsung device too (albeit running Android 10), so I know this problem a little too well.

Glad I could help! :)