AppLovin / AppLovin-MAX-SDK-Android

Other
223 stars 99 forks source link

IllegalStateException: Failed to load new ad - this instance is already destroyed #589

Open inidamleader opened 10 months ago

inidamleader commented 10 months ago

MAX SDK Version

12.0.0

Device/Platform Info

All android verion

Current Behavior

Crash on activity resume:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.inidamleader.ovtracker/com.inidamleader.ovtracker.layer.ui.main.MainActivity}: java.lang.IllegalStateException: Failed to load new ad - this instance is already destroyed for ad unit ID: 6fb9cee1b6057600 at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4034) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4066) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1969) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7127) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Caused by java.lang.IllegalStateException: Failed to load new ad - this instance is already destroyed for ad unit ID: 6fb9cee1b6057600 at com.applovin.impl.mediation.ads.MaxAdViewImpl.a(SourceFile:252) at com.applovin.impl.mediation.ads.MaxAdViewImpl.loadAd(SourceFile:240) at com.applovin.impl.mediation.ads.MaxAdViewImpl.onAdRefresh(SourceFile:649) at com.applovin.impl.sdk.e.AA(SourceFile:297) at com.applovin.impl.sdk.e.onReceive(SourceFile:228) at com.applovin.impl.sdk.AppLovinBroadcastManager.sendBroadcastSync(SourceFile:232) at com.applovin.impl.sdk.SessionTracker.Ft(SourceFile:219) at com.applovin.impl.sdk.SessionTracker.AA(SourceFile:159) at com.applovin.impl.sdk.SessionTracker.a(SourceFile:29) at com.applovin.impl.sdk.SessionTracker$1.onActivityResumed(SourceFile:69) at android.app.Application.dispatchActivityResumed(Application.java:264) at android.app.Activity.onResume(Activity.java:1403) at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:310) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1416) at android.app.Activity.performResume(Activity.java:7585) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4026) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4066) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1969) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7127) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Expected Behavior

Not to crash

How to Reproduce

Not reproducible

Additional Info

Screenshot 2023-11-27 at 10-03-43 OvTracker - com applovin impl mediation ads MaxAdViewImpl a - Firebase console

Str4tos commented 10 months ago

Duplicate issue: #583

inidamleader commented 10 months ago

It seems that either: 1- MaxAd Banner view use pattern singleton for creation which return the same instance after configuration change. 2- Or even after calling destroy on a MaxAd, this one keep refreshing and loading new content while it is already destroyed. Using a flag to check if destroy is called does not work because this is an intern error related to refreshing.

I think that there is a workaound that reduce considerably the number of crashes: It consists of stopping the auto refreshing just before the destruction:

    override fun destroy() {
        maxAdView?.stopAutoRefresh()
        maxAdView?.destroy()
        super.destroy()
    }
clee2005 commented 10 months ago

I'm seeing a very similar crash in our apps as well with only this SDK version. The only difference I can think of is that we are now showing the GDPR form which I believe will cause the app to Pause and then Resume which this exception seems to indicate. We are getting more and more of these exceptions driving our crash rate up above the acceptable threshold.

Exception java.lang.RuntimeException: at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4987) at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:5020) at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:54) at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2394) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:211) at android.os.Looper.loop (Looper.java:300) at android.app.ActivityThread.main (ActivityThread.java:8289) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:559) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:954) Caused by java.lang.IllegalStateException: at com.applovin.impl.mediation.ads.MaxAdViewImpl.a (SourceFile:252) at com.applovin.impl.mediation.ads.MaxAdViewImpl.loadAd (SourceFile:240) at com.applovin.impl.mediation.ads.MaxAdViewImpl.onAdRefresh (SourceFile:649) at com.applovin.impl.sdk.e.AA (SourceFile:297) at com.applovin.impl.sdk.e.onReceive (SourceFile:228) at com.applovin.impl.sdk.AppLovinBroadcastManager.sendBroadcastSync (SourceFile:232) at com.applovin.impl.sdk.SessionTracker.Ft (SourceFile:219) at com.applovin.impl.sdk.SessionTracker.AA (SourceFile:159) at com.applovin.impl.sdk.SessionTracker.a (SourceFile:29) at com.applovin.impl.sdk.SessionTracker$1.onActivityResumed (SourceFile:69) at android.app.Application.dispatchActivityResumed (Application.java:440) at android.app.Activity.dispatchActivityResumed (Activity.java:1511) at android.app.Activity.onResume (Activity.java:2093) at androidx.fragment.app.FragmentActivity.onResume (FragmentActivity.java:434) at com.donkeysoft.wordwowfree.RunnerActivity.onResume (RunnerActivity.java:1084) at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1585) at android.app.Activity.performResume (Activity.java:8674) at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4977)

AviNLeung commented 10 months ago

We are currently fixing the error related to ad refresh on pause/resume.

We made a server side change on November 28 so that the crash only happens in debug builds, so it should not be affecting external traffic anymore.

clee2005 commented 10 months ago

That's great that you are looking into it, but Google Play is reporting that this same exception happened as recent as 3 hours ago (from this email timestamp).

Chris

On Thu, Nov 30, 2023 at 2:40 PM AviNLeung @.***> wrote:

We are currently fixing the error related to ad refresh on pause/resume.

We made a server side change on November 28 so that the crash only happens in debug builds, so it should not be affecting external traffic anymore.

— Reply to this email directly, view it on GitHub https://github.com/AppLovin/AppLovin-MAX-SDK-Android/issues/589#issuecomment-1834433896, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMEYZ3D57AJF2TMCROPOKDYHDOJBAVCNFSM6AAAAAA73VSG4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZUGQZTGOBZGY . You are receiving this because you commented.Message ID: @.***>

AviNLeung commented 10 months ago

I am unable to see the email link from Google Play, but please let me know if the issue persists on release builds.

clee2005 commented 10 months ago

It is a release build and yes it persists still.

On Thu, Nov 30, 2023 at 8:51 PM AviNLeung @.***> wrote:

I am unable to see the email link from Google Play, but please let me know if the issue persists on release builds.

— Reply to this email directly, view it on GitHub https://github.com/AppLovin/AppLovin-MAX-SDK-Android/issues/589#issuecomment-1835282484, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMEYZ2PCR6NPINYW73RONTYHEZY7AVCNFSM6AAAAAA73VSG4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZVGI4DENBYGQ . You are receiving this because you commented.Message ID: @.***>

AviNLeung commented 10 months ago

FYI, we released a fix for this issue today in our newest SDK version 12.1.0(https://support.applovin.com/hc/en-us/articles/13887934767117-Changelog).