android / uamp

A sample audio app for Android
Apache License 2.0
13.06k stars 3.74k forks source link

MediaBrowser.disconnect missing? #484

Open HectorRicardo opened 2 years ago

HectorRicardo commented 2 years ago

Hello,

I noticed that there's no call to MediaBrowserCompat.disconnect anywhere in the repo.

Was this intentional? To never unbind the service? Or did you just forget?

joerogers commented 1 year ago

I believe this is a bug and causes the MusicService to permanently leak until the app is killed. I was trying to see how the team handled certain tricky situations, but because the MusicService is never destroyed they never encountered them.

Per the docs, the client should "connect" during onStart() and "disconnect during onStop(). Without calling disconnect the app is leaking memory and resources well after the user has finished using the app.

https://developer.android.com/guide/topics/media-apps/audio-app/building-a-mediabrowser-client