googleads-mobile-unity: Crashes caused by the ads plugin
We are having a lot of crashes reported on Firebase Crashlytics and on Android Vitals. As it is not reproducible on our test environment, it took us several weeks to finally find out what was causing all these errors.
When we removed and stopped using the Google Mobile Ads plugin, absolutely all the crashes were gone. To be sure, we added it again and just a few minutes after the update was live the crashes started to happen again.
There are a few different stack traces causing the crashes:
CRASH 1
il2cpp::vm::Method::GetParamCount(MethodInfo const*)
scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
UnityJavaProxy_invoke(_JNIEnv*, _jobject*, long long, _jstring*, _jobjectArray*)
CRASH 2
std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)
std::_Rb_tree_iterator<DelayedCallManager::Callback> std::_Rb_tree<DelayedCallManager::Callback, DelayedCallManager::Callback, std::_Identity<DelayedCallManager::Callback>, std::less<DelayedCallManager::Callback>, memory_pool<DelayedCallManager::Callback> >::_M_insert_<DelayedCallManager::Callback const&>(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, DelayedCallManager::Callback const&)
CallDelayed(CallObjectState (*)(Object*, void*), PPtr<Object>, float, void*, float, CallObjectState (*)(void*), DelayedCallManager::DelayedCallMode)
Coroutine::HandleIEnumerableCurrentReturnValue(ScriptingObjectPtr)
Coroutine::ProcessCoroutineCurrent()
Coroutine::Run(bool*)
MonoBehaviour::TryCreateAndRunCoroutine(ScriptingObjectPtr, ScriptingMethodPtr, Coroutine**)
MonoBehaviour::StartCoroutineManaged2(ScriptingObjectPtr)
MonoBehaviour_CUSTOM_StartCoroutineManaged2(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
EventHandler_1_Invoke_mBF3979EE17B68658C4C1AB3A8D64B24F263E3B98_gshared
EventHandler_1_Invoke_mBF3979EE17B68658C4C1AB3A8D64B24F263E3B98_gshared
RuntimeInvoker_TrueVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017_RuntimeObject(void (*)(), MethodInfo const*, void*, void**)
il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**)
CRASH 3
std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)
std::_Rb_tree<DelayedCallManager::Callback, DelayedCallManager::Callback, std::_Identity<DelayedCallManager::Callback>, std::less<DelayedCallManager::Callback>, memory_pool<DelayedCallManager::Callback> >::erase[abi:cxx11](std::_Rb_tree_const_iterator<DelayedCallManager::Callback>)
DelayedCallManager::Update(int)
ExecutePlayerLoop(NativePlayerLoopSystem*)
ExecutePlayerLoop(NativePlayerLoopSystem*)
PlayerLoop()
UnityPlayerLoop()
nativeRender(_JNIEnv*, _jobject*)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 47 (7 by maintainers)
@shefich none in our game
Hello there, I had up to 1k+ crash / day on a 100k+ active user base after installing the package. I tried various package and unity versions without success. Removing logic from callbacks or disabling TMP like some people suggested did not seemed to reduce my crash rate at first.
Finally I found out that both of them cause crashes.
So here is my little understanding and workarround for it : Admob’s package for Unity runs on a separated thread than Unity to pause it while executing the Ad. Executing logic while in Admob’s thread can have side effects (I was using UnityEvent and Dotween in the callback). I now set a simple bool is the callbacks when the Ad is done and check it in the Update() loop to execute my logic, to be run by the Unity thread.
Also if you are using Text Mesh Pro, it also seems to crash sometimes when rendering text during the first frame after the Ad. On a slow phone I observed a short lapse of time where Unity rendered a part of the scene before the crash happened, and the part not rendered was the UI with TMP. So I deactivated the UI just before the ad is called and activated back 0.1 sec after and it seems to work.
Hope it helps, cheers.
(2 days after deployment my crash rate finally dropped)
@kasspip From my users’ logs, I can see that some crashes happen during the app startup, that is when I load the ads (both interstitial and rewarded). What you and @oguzhalil might be experiencing is that after you skip or close, the plugin starts to load another ad and then the crash occurs.