Closed
Description
Media3 Version
Media3 1.0.1
Devices that reproduce the issue
Android emulator API 33
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
- Connect MediaController in one process to MediaSession (via MediaSessionService) in another process.
- Do some minimal interaction.
- Release MediaController.
- Wait for MediaSessionService to be destroyed.
- Wait a long time to really make sure that Android will give up the Service references. Mash the Android Studio Profiler GC button.
- Observe MediaSessionService leaking, via LeakCanary, Android Studio Profiler, and StrictMode setClassInstanceLimit.
Expected result
MediaSessionService garbage collected
Actual result
MediaSessionService leaks. Is this a known leak or expected? If so, is there a workaround? If it's not clear what's going on here I can work on a repro.
It looks like something (Binder-related I assume) is keeping a reference to MediaSessionStub.
====================================
HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS
References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.
5665 bytes retained by leaking objects
Signature: ee46fed2ca31f02081399eeb1f2a47c36a7e8daf
┬───
│ GC Root: Global variable in native code
│
├─ androidx.media3.session.MediaSessionStub instance
│ Leaking: UNKNOWN
│ Retaining 16.5 kB in 252 objects
│ ↓ MediaSessionStub.connectedControllersManager
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
├─ androidx.media3.session.ConnectedControllersManager instance
│ Leaking: UNKNOWN
│ Retaining 15.7 kB in 245 objects
│ ↓ ConnectedControllersManager.sessionImpl
│ ~~~~~~~~~~~
├─ androidx.media3.session.MediaSessionImpl instance
│ Leaking: UNKNOWN
│ Retaining 14.6 kB in 221 objects
│ context instance of com.bubenheimer.rucksack.d.CW
│ ↓ MediaSessionImpl.context
│ ~~~~~~~
╰→ com.bubenheimer.rucksack.d.CW instance
Leaking: YES (ObjectWatcher was watching this because com.bubenheimer.rucksack.d.CW received Service#onDestroy()
callback and Service not held by ActivityThread)
Retaining 5.7 kB in 95 objects
key = 4ec1a0de-07d9-487f-b346-18fa0fe5c9f5
watchDurationMillis = 1233
retainedDurationMillis = 229
mApplication instance of com.bubenheimer.rucksack.d.D
mBase instance of android.app.ContextImpl
====================================
0 LIBRARY LEAKS
A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
====================================
0 UNREACHABLE OBJECTS
An unreachable object is still in memory but LeakCanary could not find a strong reference path
from GC roots.
====================================
METADATA
Please include this in bug reports and Stack Overflow questions.
Build.VERSION.SDK_INT: 33
Build.MANUFACTURER: Google
LeakCanary version: 2.10
App process name: com.bubenheimer.rucksack
Class count: 28631
Instance count: 179207
Primitive array count: 132734
Object array count: 25331
Thread count: 36
Heap total bytes: 27161738
Bitmap count: 0
Bitmap total bytes: 0
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/com.bubenheimer.rucksack/databases/com.google.android.datatransport.events
Db 2: open /data/user/0/com.bubenheimer.rucksack/databases/rucksack-16885692033713938602.db
Stats: LruCache[maxSize=3000,hits=108537,misses=178040,hitRate=37%]
RandomAccess[bytes=9035219,reads=178040,travel=58762959483,range=32300280,size=40283652]
Heap dump reason: 1 retained objects, app is visible
Analysis duration: 25266 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-com.bubenheimer.rucksack/2023-04-20_12-46-30_323.hprof
Heap dump timestamp: 1682009225088
Heap dump duration: 4144 ms
Media
N/A
Bug Report
- You will email the zip file produced by
adb bugreport
to [email protected] after filing this issue.