AppLovin / AppLovin-MAX-Unity-Plugin

130 stars 35 forks source link

SIGSEGV Crash on Android mobile games #283

Open HassannKhan opened 1 year ago

HassannKhan commented 1 year ago

MAX Plugin Version

5.11.3

Unity Version

2023.1.14f1

Device/Platform Info

Android 9, 10, 11, 12, 13

Current Behavior

A ton of crashes are reported every single day labelled as SIGSEGV.

These crashes and ANRs are affecting the production track of play store which means less organic downloads.

These crashes and ANRs can only be seen when AppLovin SDK plugin is used.

Expected Behavior

Expected behavior is that AppLovin ads run smoothly along side with Unity's incremental GC so users can spend longer play times on the game without crashes or ANRs

How to Reproduce

This happens when you are using Incremental GC that is enabled by default. If you disable incremental GC the crash will drop but the ANR will rise. There is not fix time when it happens. There are no known steps that can help to reproduce this issue locally.

The Size of player's mobile RAM doesn't have any impact on the crashes nor does the Android API level is relevant in this issue. Crashes can be seen only when Showing the ADS. If no ads are shown, no crashes are recorded even if the AppLovin plugin is still inside the project and Load Interstitial is called.

The Show Interstitial or Close button of Interstitial (callbacks basically) are suspected to be the main culprit.

Additional Info

No response

Lorenzo45 commented 1 year ago

Hi @Hassan1Khan - Thank you for the detailed report. The root cause appears to be in Unity's native libraries, specifically AndroidJavaProxy which our SDK uses to send callbacks for fullscreen ads while they are displayed. There is a ticket on Unity's Issue Tracker for this issue here: https://issuetracker.unity3d.com/issues/android-crash-on-android-when-androidjavaproxy-is-calling-from-multiple-threads

We're looking for ways to work around this issue on our end and we'll notify this thread when we have any updates.

In the meantime, could you answer a few questions to help us get a better understanding of the issue?

  1. What percentage of users are affected by this crash?
  2. Did this crash start happening recently?
  3. Did you upgrade your Unity version when the crashes started to appear? If so, which version of Unity were you on before the crashes appeared?
HassannKhan commented 1 year ago

@Lorenzo45 Thank you so much for your reply and I am so glad that someone finally said something about the issue. I was scratching my head for a long time on these issues, there's little to no information available about it.

As far as your questions are concerned.

  1. One out of 10 users are facing these crashes, the bad behavior threshold crossed and its increasing 0.30% every single day.

2- No they did not started happening recently, my application is new. But this issue has been there since the start. it can been seen in all of my apps.

3- Yes I upgraded unity version as well. The earlier version I used is 2022.3.5f Currently I am using 2023.1.14f1

SOME INFORMATION THAT MIGHT HELP

These errors are directly impacted with the Incremental GC feature of unity. If you turn it off, the crashes will reduce in numbers the app will go out of bad threshold but at the same time ANR errors will start to rise. They will go beyond bad behavior.

This is just my theory but I think there is a portion of memory allocated with the load of interstitial. Either before the show is called or after the show is called, they memory is freed by Garbage Collector however your SDK still tries to access it.

Questions that are concerned with me

The percentage of crashes reported each are unbearable and my app is losing the revenue along with the visibility on play store

Is there a way to stop or control the errors before there's some permanent fix to the issue?

Like what If I remove the CallBacks? Will it help? I see the callbacks are used to load next interstitial but I will manually load the ad at the start of each level.

Also the link that you sent, can you please explain this line? "[ANDROID] CRASH ON ANDROID WHEN ANDROIDJAVAPROXY IS CALLING FROM MULTIPLE THREADS"

Does it mean that the crash only happens after loading an ad for a few times?

I was thinking to track the load and show function so numberOfTimesAdLoad != numberOfTimesAdShow (meaning the app was crashed with last ShowInterstitial call) I will stop showing ad to that device. What do you think? Will it help?

I desperately want to control these crashes to refrain my app from crossing Bad Behavior Threshold of Google Play. Any valuable suggestion that you can add at this point is welcome.

Lorenzo45 commented 1 year ago

Thanks for the information. We'll likely have to implement the fix on our side but here are a couple things you can try:

  1. Implement the fix suggested here: https://forum.unity.com/threads/libil2cpp-so-method-cpp-il2cpp-vm-method-getparamcount-methodinfo-const-crash-in-android.1455493/#post-9275145
  2. Reduce the memory usage of your app. Video here to help you get started: https://www.youtube.com/watch?v=I9wB4Cvgz5g&ab_channel=Unity

Please share the results if you try these suggestions

HassannKhan commented 1 year ago

Thank you so much for your time. I can't appreciate your words enough and to get rid of the errors I'd love to try anything.

However, the reducing memory usage won't work in my case. The reason is because I have applovin integrated in 6 to 7 games and all of them are reporting the same crashes. Not all of them are same in memory usage and the gameplay sizes. Some are quite simple while other are complex.

I'd love to try the first workaround, to invoke AndroidJavaProxy but finding it hard to get the clear picture here?

I understand I need to invoke it before initialization of sdk. Correct me if I am wrong.

How can I use this with applovin? What androidjavaproxy do I have to invoke? Should I invoke the same as in MaxSDK used for callbacks?

Can you help me a little further with some working sample codes?

Lorenzo45 commented 1 year ago

Looks like this would be difficult to workaround on your end but we should have a fix going out in the next SDK release. We'll notify this thread when the SDK is released with the fix!

HassannKhan commented 1 year ago

When is the next release expected? I tried the solution and it doesn't work for my problem.

Lorenzo45 commented 1 year ago

We should release an update to our Unity Plugin with the fix within the next week

Lorenzo45 commented 1 year ago

Hi @Hassan1Khan - we’ve just released MAX Unity Plugin version 5.11.4 that should fix this crash: https://github.com/AppLovin/AppLovin-MAX-Unity-Plugin/releases/tag/release_5_11_4

Please let us know if this version fixes the crash for you.

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 30 days with no activity.