AppLovin / AppLovin-MAX-SDK-Android

Other
228 stars 102 forks source link

App crashes due Out of Memory on InMobi and Unity providers #720

Closed sacastrillon closed 1 month ago

sacastrillon commented 1 month ago

MAX SDK Version

12.6.0

Device/Platform Info

Android

Crashes/ANRs per Day

~ 3K +

Percentage of Users Affected

2.5K

First Occurrence of Crash/ANR

We've been experiencing these types of crashes for a few months now. Initially, we thoroughly reviewed our implementation within the Grindr app, but ultimately, we obtained logs from the SDK providers that shed more light on the issue.

Exception and Stack Trace

InMobi

java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 2938960 free bytes and 2870KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
                                                                                                        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:684)
                                                                                                        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
                                                                                                        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:62)
                                                                                                        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
                                                                                                        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
                                                                                                        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1714)
                                                                                                        at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1561)
                                                                                                        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1432)
                                                                                                        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1638)
                                                                                                        at com.inmobi.media.o3.b(DbStore.kt:12)
                                                                                                        at com.inmobi.media.v2.c(ConfigDao.kt:3)
                                                                                                        at com.inmobi.media.u2$b$a.handleMessage(ConfigComponent.kt:552)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:242)
                                                                                                        at android.os.Looper.loop(Looper.java:362)
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:85)
Collapse

Unity

          Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
       at java.lang.Thread.nativeCreate(Thread.java)
       at java.lang.Thread.start(Thread.java:883)
       at com.unity3d.services.ads.gmascar.managers.BiddingBaseManager.uploadSignals(BiddingBaseManager.java:130)
       at com.unity3d.services.ads.gmascar.managers.BiddingBaseManager.attemptUpload(BiddingBaseManager.java:108)
       at com.unity3d.services.ads.gmascar.managers.BiddingBaseManager.onSignalsReady(BiddingBaseManager.java:102)
       at com.unity3d.services.ads.gmascar.managers.BiddingBaseManager$1.onSignalsReady(BiddingBaseManager.java:80)
       at com.unity3d.services.ads.gmascar.handlers.BiddingSignalsHandler.onSignalsCollected(BiddingSignalsHandler.java:32)
       at com.unity3d.scar.adapter.common.signals.SignalsCollectorBase$GMAScarDispatchCompleted.run(SignalsCollectorBase.java:73)
       at com.unity3d.scar.adapter.common.DispatchGroup.notifyGroup(DispatchGroup.java:31)
       at com.unity3d.scar.adapter.common.DispatchGroup.leave(DispatchGroup.java:21)
       at com.unity3d.scar.adapter.common.signals.SignalCallbackListener.onSuccess(SignalCallbackListener.java:33)
       at com.unity3d.scar.adapter.v2300.signals.QueryInfoCallback.onSuccess(QueryInfoCallback.java:19)
       at com.google.android.gms.internal.ads.zzbvw.zzc(com.google.android.gms:play-services-ads-lite@@23.2.0:2)
       at com.google.android.gms.internal.ads.zzcbc.zzdF(com.google.android.gms:play-services-ads-lite@@23.2.0:5)
       at com.google.android.gms.internal.ads.zzbae.onTransact(com.google.android.gms:play-services-ads-base@@23.2.0:3)
       at android.os.Binder.transact(Binder.java:914)
       at m.anf.bh(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:8)
       at com.google.android.gms.ads.internal.signals.a.f(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:15)
       at com.google.android.gms.ads.nonagon.signalgeneration.ak.b(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:292)
       at m.chu.run(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:30)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at m.bba.a(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:1)
       at com.google.android.gms.ads.internal.util.f.a(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:1)
       at m.bba.dispatchMessage(:com.google.android.gms.policy_ads_fdr_dynamite@243220707@243220703034.668972300.668972300:1)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7386)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

How to Reproduce

Left the app running for a 5 ~ 10 min

Reproducible in the demo app?

Not Tested

Additional Info

No response

alvarshahanji commented 1 month ago

For issues related to low memory, here are some of the suggestions posted in an earlier post you can try, especially Selective Init API on low RAM devices:

  1. Reduce the memory usage of your app as much as possible.
  2. Avoid SDK initializations or ad loading when heavy operations are taking place (e.g., app launching or scene loading). Adding a delay before initializing the MAX SDK or loading ads has shown to reduce ANRs.
  3. Reduce the number of ad networks for low-RAM devices by using a separate set of ad units with fewer ad networks enabled and initialize the MAX SDK using our Selective Init API to ensure that only those ad networks are initialized (to reduce ANRs while minimizing ad revenue loss).
  4. As a last resort, you can reduce ads for low-RAM devices.

Also, reach out to InMobi and Unity teams directly.