We are seeing a critical memory leak related to GMA WebView api (
https://developers.google.com/admob/android/browser/webview/api-for-ads) in our production app.
To reproduce this leak we are sharing a test app similar to our production app along with steps and video to reproduce
GMA SDK Version: com.google.android.gms:play-services-ads:23.0.0
Steps to reproduce (refer video):
1. Open test app
2. Quickly swipe back and forth between fragments
3. In between go back and again launch test app
4. Repeat steps 2 and 3 for some time and you should be able to see LeakCanary detection dialog
Following is the memory leak trace:
┬───
│ GC Root: Thread object
│
├─ WV.ed instance
│ Leaking: NO (PathClassLoader↓ is not leaking)
│ Thread name: 'CleanupReference'
│ ↓ Thread.contextClassLoader
├─ dalvik.system.PathClassLoader instance
│ Leaking: NO (zzbxk↓ is not leaking and A ClassLoader is never leaking)
│ ↓ ClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│ Leaking: NO (zzbxk↓ is not leaking)
│ ↓ Object[193]
├─ com.google.android.gms.internal.ads.zzbxk class
│ Leaking: NO (a class is never leaking)
│ ↓ static zzbxk.zza
│ ~~~
├─ com.google.android.gms.internal.ads.zzccr instance
│ Leaking: UNKNOWN
│ Retaining 16 B in 1 objects
│ ↓ zzayg.zza
│ ~~~
├─ com.google.android.gms.ads.nonagon.signalgeneration.z instance
│ Leaking: UNKNOWN
│ Retaining 171.6 kB in 3024 objects
│ e instance of com.gma.webviewtest.MainActivity with mDestroyed =
│ true
│ ↓ z.e
│ ~
╰→ com.gma.webviewtest.MainActivity instance
Leaking: YES (ObjectWatcher was watching this because com.gma.
webviewtest.MainActivity received Activity#onDestroy() callback and
Activity#mDestroyed is true)
Retaining 170.3 kB in 3000 objects
key = 772c5794-d3f1-4a1e-b574-efb34af09493
watchDurationMillis = 5789
retainedDurationMillis = 754
mApplication instance of android.app.Application
mBase instance of androidx.appcompat.view.ContextThemeWrapper
METADATA
Build.VERSION.SDK_INT: 31
Build.MANUFACTURER: Xiaomi
LeakCanary version: 3.0-alpha-1
App process name: com.gma.webviewtest
Class count: 26687
Instance count: 247080
Primitive array count: 149432
Object array count: 33101
Thread count: 80
Heap total bytes: 29816310
Bitmap count: 82
Bitmap total bytes: 4256526
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/com.gma.webviewtest/no_backup/androidx.work.
workdb
Stats: LruCache[maxSize=3000,hits=123887,misses=221172,hitRate=35%]
RandomAccess[bytes=10988277,reads=221172,travel=84039994842,range=36239076,size=
44175871]
Analysis duration: 38439 msNote: This was reported in our production app performance testing where the memory leaked was as high as 500 MB
Please let us know if anything else is needed.