jellyfin / jellyfin-android

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
1.51k stars 243 forks source link

Android occasionally kills app during background playback #219

Open SightSpirit opened 3 years ago

SightSpirit commented 3 years ago

Describe the bug

I use Jellyfin primarily for music—it's my de facto replacement for Google Play Music—and I often play music in the background while I am doing other things on my phone. Sometimes, I will open and switch among several apps in a short period of time, and this will sometimes cause my music to stop playing abruptly. When I switch back to the Jellyfin app, I see a black screen for a second before the splash-screen logo appears: basically, the app is starting up again, and my play queue is now empty.

Based on my limited knowledge of the Android backend, my hypothesis is that this is the result of some OS memory management. However, this issue has never happened to me with Google Play Music, Google Podcasts, or even the official VLC app, leading me to believe that there is some do-not-kill flag somewhere in each of those apps that gets set to true during playback.

This kind of unsolicited background app-killing can also be caused by Android's battery optimization service, but I have double-checked, and I have disabled that for Jellyfin. With that being the case, I am assuming that that is not related to this behavior.

To Reproduce

  1. Start playing some music in Jellyfin Android, with multiple tracks in your play queue.
  2. Open a few apps on the same Android device, particularly ones that demand significant amounts of memory. (Do not dismiss or kill any of them.)
  3. After the conclusion of (or possibly in the middle of) a non-final track, you may notice that your music has stopped playing altogether.
  4. Reopen the Jellyfin app, either from your launcher or your Recents screen.
  5. Watch in horror as the app initiates its startup sequence.

Expected behavior

My music should have continued uninterrupted!

Logs

(from server log, not client log; most addresses redacted; entries separated for clarity, and most relevant line emphasized)

[2020-10-30 15:30:46.917 -04:00] [WRN] [15] Emby.Server.Implementations.HttpServer.HttpListenerHost: HTTP Response 204 to "[IPv4 address]". Time (slow): 0:00:00.5782703. "http://[server domain]/Sessions/Playing/Progress"

[2020-10-30 15:31:48.000 -04:00] [WRN] [25] Emby.Server.Implementations.HttpServer.HttpListenerHost: HTTP Response 204 to "[IPv4 address]". Time (slow): 0:00:01.4999368. "http://[server domain]/Sessions/Playing/Progress"

--->[2020-10-30 15:31:53.874 -04:00] [WRN] [15] Emby.Server.Implementations.HttpServer.WebSocketConnection: WS "::ffff:192.168.1.7" error receiving data: "The remote party closed the WebSocket connection without completing the close handshake."

[2020-10-30 15:33:08.441 -04:00] [WRN] [10] Emby.Server.Implementations.HttpServer.HttpListenerHost: HTTP Response 200 to "[IPv4 address]". Time (slow): 0:00:00.665173. "http://[server domain]/web/bundle.js?v=30"

[2020-10-30 15:33:14.022 -04:00] [WRN] [25] Emby.Server.Implementations.HttpServer.HttpListenerHost: HTTP Response 200 to "[IPv4 address]". Time (slow): 0:00:00.5055901. "http://[server domain]/Users/9f9e195b3817408ca1c70da22a99f49f/Views"

System (please complete the following information):

nielsvanvelzen commented 3 years ago

This issue happens in our app because simply said it acts like a webbrowser and the website is put into the background when you switch apps. Not much we can do about that. However, our intent is to replace the playback with a native implementation to fix that.

39 is about the same problem.

jellyfin-bot commented 2 years ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.

If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.

This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.