AppLovin / AppLovin-MAX-Unity-Plugin

115 stars 31 forks source link

Crash on iOS when sending the app to background before AL SDK initialisation #380

Open ltk-daniel-zapater opened 1 month ago

ltk-daniel-zapater commented 1 month ago

MAX Plugin Version

6.5.2

Unity Version

2022.3.22f1

Device/Platform Info

iOS

Current Behavior

App crashes when sent to background before AL SDK initialisation

Expected Behavior

App does not crash

How to Reproduce

Additional Info

santoshbagadi commented 1 month ago

@ltk-daniel-zapater thank you for raising the issue. We'll fix this in the next version of our plugin.

In the meantime, if you'd like to apply the fix, please update the following line in Assets/MaxSdk/AppLovin/Plugins/iOS/MAUnityAdManager.m

backgroundCallback(serializedParameters.UTF8String);

to

if ( backgroundCallback )
{
    backgroundCallback(serializedParameters.UTF8String);
}
ltk-daniel-zapater commented 1 month ago

Thank you for your quick response @santoshbagadi! Our solution was to add this at the beginning of MAUnityAdManager:forwardUnityEventWithArgs, so that nothing unnecessary is executed. Wouldn't it be correct?

if (backgroundCallback == nil)   
    return;
santoshbagadi commented 1 month ago

Yes, that would work too. I just wanted to give a quick fix while we are working on a more robust fix for this issue.

AndrewUrbanovich commented 6 days ago

Hi @santoshbagadi ! We have exact same issue in Unity 2021.3.37f (although it should be happening in every other unity version too) with AppLovin Max 6.5.2 And this is happening because we don't call MaxSdk.InitializeSdk() if there is no internet connection. Fix mentioned above with checking if backgroundCallback is configured is working. But we also have issue with long freezes on iOS when app is going to background and back. (It's not happening on our previous 6.4.4 version). Any advices?

AndrewUrbanovich commented 5 days ago

Regarding freezes in our app - it's also happening because of same part of new logic with backgroundCallbackEventsQueue. If we'll remove part with backgroundCallbackEventsQueue app working much better after returning from background.

image