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

Memory Leak error MediaBrowserService.ServiceBinder.mBase #70

Closed
Kolyall opened this issue Apr 22, 2022 · 5 comments
Closed

Memory Leak error MediaBrowserService.ServiceBinder.mBase #70

Kolyall opened this issue Apr 22, 2022 · 5 comments
Assignees

Comments

@Kolyall
Copy link

Kolyall commented Apr 22, 2022

Example:
https://github.com/Kolyall/MediaBrowserServiceLeak
Error:

┬───
    │ GC Root: Global variable in native code
    │
    ├─ android.service.media.MediaBrowserService$ServiceBinder instance
    │    Leaking: UNKNOWN
    │    Retaining 10,1 kB in 96 objects
    │    this$0 instance of androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi26$MediaBrowserServiceApi26
    │    ↓ MediaBrowserService$ServiceBinder.this$0
    │                                        ~~~~~~
    ├─ androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi26$MediaBrowserServiceApi26 instance
    │    Leaking: YES (Service not held by ActivityThread)
    │    Retaining 9,6 kB in 95 objects
    │    mBase instance of com.github.kolya.myapplication.service.MusicService
    │    ↓ ContextWrapper.mBase
    ╰→ com.github.kolya.myapplication.service.MusicService instance
    ​     Leaking: YES (ObjectWatcher was watching this because com.github.kolya.myapplication.service.MusicService
    ​     received Service#onDestroy() callback and Service not held by ActivityThread)
    ​     Retaining 7,7 kB in 81 objects
    ​     key = 64f61139-e21a-47d3-8759-b1c9c5be6d83
    ​     watchDurationMillis = 5199
    ​     retainedDurationMillis = 178
    ​     mApplication instance of android.app.Application
    ​     mBase instance of android.app.ContextImpl

    METADATA

    Build.VERSION.SDK_INT: 29
    Build.MANUFACTURER: Google
    LeakCanary version: 2.8.1
    App process name: com.github.kolya.myapplication
    Stats: LruCache[maxSize=3000,hits=34152,misses=85683,hitRate=28%]
    RandomAccess[bytes=3961419,reads=85683,travel=23994363586,range=16504510,size=21876036]
    Analysis duration: 3061 ms
@raghav2945
Copy link

Any update on this?

We (Audiomack) are also experiencing the same problem. Could someone please have a look.

34134 bytes retained by leaking objects
    Signature: 0f0ab14a66b16eeae7988b3415bfdc35ce9d42
    ┬───
    │ GC Root: Global variable in native code
    │
    ├─ android.service.media.MediaBrowserService$ServiceBinder instance
    │    Leaking: UNKNOWN
    │    Retaining 34.7 kB in 607 objects
    │    this$0 instance of androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi26$MediaBrowserServiceApi26
    │    ↓ MediaBrowserService$ServiceBinder.this$0
    │                                        ~~~~~~
    ├─ androidx.media.MediaBrowserServiceCompat$MediaBrowserServiceImplApi26$MediaBrowserServiceApi26 instance
    │    Leaking: YES (Service not held by ActivityThread)
    │    Retaining 34.1 kB in 606 objects
    │    mBase instance of com.audiomack.playback.MusicService
    │    ↓ ContextWrapper.mBase
    ╰→ com.audiomack.playback.MusicService instance
    ​     Leaking: YES (ObjectWatcher was watching this because com.audiomack.playback.MusicService received
    ​     Service#onDestroy() callback and Service not held by ActivityThread)
    ​     Retaining 32.8 kB in 594 objects
    ​     key = 01674233-fcdd-4b67-9f0c-3e71a87465eb
    ​     watchDurationMillis = 5046
    ​     retainedDurationMillis = 33
    ​     mApplication instance of com.audiomack.MainApplication
    ​     mBase instance of android.app.ContextImpl


METADATA

    Build.VERSION.SDK_INT: 29
    Build.MANUFACTURER: Google
    LeakCanary version: 2.7
    App process name: com.audiomack
    Stats: LruCache[maxSize=3000,hits=9611,misses=134435,hitRate=6%]
    RandomAccess[bytes=7038717,reads=134435,travel=77402448250,range=32208329,size=38741613]
    Heap dump reason: 9 retained objects, app is visible
    Analysis duration: 36965 ms
    Heap dump duration: 4190 ms

@bubenheimer
Copy link

bubenheimer commented Apr 20, 2023

It's this: https://issuetracker.google.com/issues/220795151

Supposedly "fixed" years ago, but no.

I first reported this issue 6 years ago, and Google did not even look at it: https://issuetracker.google.com/issues/37137738

Was hoping the implied "fix" meant switching to Media3 and MediaSessionService/MediaLibraryService, but after a huge refactoring effort I see a comparable leak there now: #346

@tonihei tonihei assigned tonihei and unassigned marcbaechinger Apr 25, 2023
@tonihei
Copy link
Collaborator

tonihei commented Apr 25, 2023

As noted above, this is essentially a duplicate of the issue tracked at https://issuetracker.google.com/issues/220795151

The underlying issue is an Android platform bug that got fixed in Android 13 (API 33) with no good way to backport/workaround the problem on earlier platform versions. So the leak detections above can't be solved as they are both on API 29.

@bubenheimer : You stated on the linked platform bug that this is still present in Android 14 DP2. Are you certain is the exact same leak mentioned here and in the bug, or are you referring to #346 (which is different and can be fixed in Media3)?

@bubenheimer
Copy link

I've just repro'ed my own issue again (https://issuetracker.google.com/issues/37137738) on my production app (based on MediaBrowserServiceCompat), on API 33. This is distinct from #346. Maybe it's not the same as https://issuetracker.google.com/issues/220795151 (which does not have a repro, but looks the same as this reproable Github issue), the leak trace looks different. They all seem to make MediaBrowserServiceCompat leak without recourse.

@tonihei
Copy link
Collaborator

tonihei commented Apr 25, 2023

Let's continue tracking the platform andandroidx.media related issues on the linked bugs where they belong and close this one. #346 can be addressed separately.

@tonihei tonihei closed this as completed Apr 25, 2023
@androidx androidx locked and limited conversation to collaborators Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants