AppLovin/AppLovin-MAX-Unity-Plugin

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

ltk-daniel-zapater opened this issue · 6 comments

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

  • Send the app to background before AppLovin SDK initialisation
  • It also happens if a iOS pop-up alert is shown before AL SDK is initialised

Additional Info

  • The crash happens because backgroundCallback is null in MAUnityAdManager:forwardUnityEventWithArgs
  • It also happens in previous AL SDK versions, at least in 6.5.1 and maybe in a few more

@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);
}

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;

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.

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?

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

We've just released a fix for this in v6.6.0 of our plugin.