A memory leak of Activity instance after calling MobileAds.registerWebView()

144 views
Skip to first unread message

Ron K

unread,
Jun 21, 2023, 7:46:52 AM6/21/23
to Google Mobile Ads SDK Developers
* com.google.android.gms:play-services-ads:22.0.0  / 22.1.0 
* Android OS level : Android 13 (and others)
* Device : Samsung Galaxy S21 Plus ( and others)

Scenario:
  1. Activity is created
  2. Fragment is added to the Activity
  3. Fragment instantiates a layout view containing an instance of WebView
  4. Calling MobileAds.registerWebView() on that WebView instance
  5. Activity is destroyed by calling Activity.finish()
The scenario above results in a leak of Activity instance which is held within a class of the MobileAds SDK. Leak analysis as reported by LeakCanary:
    ┬───
    │ GC Root: Thread object
    │
    ├─ WV.mk instance
    │    Leaking: NO (PathClassLoader↓ is not leaking)
    │    Thread name: 'CleanupReference'
    │    ↓ Thread.contextClassLoader
    ├─ dalvik.system.PathClassLoader instance
    │    Leaking: NO (zzbrt↓ is not leaking and A ClassLoader is never leaking)
    │    ↓ ClassLoader.runtimeInternalObjects
    ├─ java.lang.Object[] array
    │    Leaking: NO (zzbrt↓ is not leaking)
    │    ↓ Object[115]
    ├─ com.google.android.gms.internal.ads.zzbrt class
    │    Leaking: NO (a class is never leaking)
    │    ↓ static zzbrt.zza
    │                   ~~~
    ├─ com.google.android.gms.internal.ads.zzbxp instance
    │    Leaking: UNKNOWN
    │    Retaining 16 B in 1 objects
    │    ↓ zzasv.zza
    │            ~~~
    ├─ com.google.android.gms.ads.nonagon.signalgeneration.z instance
    │    Leaking: UNKNOWN
    │    Retaining 236.5 kB in 3483 objects
    │    e instance of  com.example.Activity  with mDestroyed = true
    │    ↓ z.e
    │        ~
    ╰→ com.example.Activity instance




Mobile Ads SDK Forum Advisor

unread,
Jun 22, 2023, 12:26:06 PM6/22/23
to ron.k...@gmail.com, google-adm...@googlegroups.com

Hi Ron,

Thank you for reaching out to us.

With regard to your concern for the memory leak you've experienced, for us to further check it in our end, can you provide us the following information below?

  • Memory Profiler
  • Screen recording of the issue
  • Sample app project
  • Steps to replicate

You can provide the following details via reply on this thread or directly provide it to the link below.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002mVxMvQAK&entry.80707362=00185310

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

This message is in relation to case "ref:_00D1U1174p._5004Q2mVxMv:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team

 



Ron K

unread,
Jun 25, 2023, 10:45:47 AM6/25/23
to Google Mobile Ads SDK Developers
Unfortunately I cannot provide the additionally requested information, as the issue was discovered on a proprietary app.

I believe the data in the report above is more than enough for a competent software engineer to further check it in your end and pinpoint the issue.

Mobile Ads SDK Forum Advisor

unread,
Jun 26, 2023, 12:02:05 PM6/26/23
to ron.k...@gmail.com, google-adm...@googlegroups.com

Hi Ron,

Thank you for your response.

We tried to create a WebView in our end using this guide (https://developers.google.com/admob/android/webview), but we're unable to replicate your reported behavior, since it seems that this is only reproducible in your app, on which we are requested previously or a copy of memory profiler. Since your app may have additional functionality or use cases, then we may not indeed be able to replicate this in our end by only using our sample app. Requesting additional information is a big help for us to further investigate this. If you are still unable to provide it, you can modify one of our sample app (https://github.com/googleads/googleads-mobile-android-examples) to your implementation for us to further check this in our end.

Reply all
Reply to author
Forward
0 new messages