Operating system: Nexus 5
Operating system version: Android 6.0.1
What steps will reproduce the problem:
What are the errors unzipping 4.5.2? Perhaps you could try another unpacking tool?
What does "Configure firebase properly" mean? Do you have a code snippet you could share that shows what you're doing?
The problem appears to be associated with Google Play Services (see log snippet below) being out of date on the device, it should typically not crash if you're using CheckAndFixDependenciesAsync()
08-20 19:30:48.407 21446 21481 W GooglePlayServicesUtil: Google Play services out of date. Requires 12211000 but found 8122438
08-20 19:30:48.407 21446 21481 E firebase: Messaging already shut down.
Are you catching the exception in the code that you're using to initialize Firebase?
Hello, Stewart. Thank you for such a quick response.
1) I tried to do this on three different PCs. According to unpacking tool I used three different: standart Windows 10, 7zip and WinRar. All of these can't unzip some files with following errors:firebase_unity_sdk_4.5.2.zip: CRC error firebase_unity_sdk\FirebaseDynamicLinks.unitypackage, file is corruptedfirebase_unity_sdk_4.5.2.zip: CRC error firebase_unity_sdk\FirebaseMessaging.unitypackage, file is corrupted
2) "Configure firebase properly" means that I did all steps according to your instructions https://firebase.google.com/docs/unity/setup Setup for Android
3) Yes, I know that Play services are out of date on mobile phone. When i build apk file with Mono, special window is shown with message to update play services. When I build apk file with il2cpp, game crash without showing window with message to update play services. This problem is similar to the old one https://groups.google.com/forum/#!topic/firebase-talk/rqWZ2frS_VY , but it was fixed according to last 2 messages.
4) As I know, Firebase should be inited when you first time try to log some event( for example FirebaseAnalytics.LogEvent("SomeEvent");) This is what I am doing in my test MonoBehaviour script in Start method
@KaspYar
Regarding unpacking the 4.5.2 zip file, I just tried it on my Windows 10 box and run into now issues. May be worth checking the usual suspects of anti-virus programs etc. You could always download and unpack on a mac and copy to your windows boxes if you still have issues.
Regarding configuring Firebase properly. unfortunately we don't document the process of updating Google Play Services consistently (it's on the list to fix) see https://github.com/firebase/quickstart-unity/blob/master/analytics/testapp/Assets/TestApp/UIHandler.cs#L42 for an example of what you should be doing. You need to upgrade Play Services explicitly before using Firebase APIs otherwise it will throw exceptions. If you're seeing an update dialog with Mono and that works (I assume you tested that works) then I'm not sure why a build with IL2CPP would not work unless code generation is blowing up the logic. Before we dig into this further could you try one of our samples on your device first?
I'll try with CheckAndFixDependencies method and send a response a little later.
I think, this is a way how exceptions are handled in Mono and il2cpp(wrapping with try-catch block works only with Mono)
Yes, sure, please share with me your sample and I'll send you response with logs
@stewartmiles your archive is corrupt. No, this is not an archivator issue and it does not unzip on windows 10.
https://www.dropbox.com/s/clj9pa6pljsgr2k/zipError.jpg?dl=0
No idea how you unziped it on your machine, but default archiver and winRar fail.
@stewartmiles after some more investigation I found out that the problem appears when firebase app try to initialize messaging on device with out of date Play Services. So, CheckAndFixDependencies didn't help me. Please note, that window to update Play Services is working ok in case I try to show leaderboards. I can share with you my apk files, builded with il2cpp and mono
@mmvlad regarding the archive here's what I see on a mac:
$ shasum firebase_unity_sdk_4.5.2.zip
6dc804084b20cb16d712cf5b83297952276ff82e firebase_unity_sdk_4.5.2.zip
$ unzip -lt firebase_unity_sdk_4.5.2.zip
Archive: firebase_unity_sdk_4.5.2.zip
testing: firebase_unity_sdk/ OK
testing: firebase_unity_sdk/FirebaseStorage.unitypackage OK
testing: firebase_unity_sdk/FirebaseAuth.unitypackage OK
testing: firebase_unity_sdk/readme.md OK
testing: firebase_unity_sdk/FirebaseRemoteConfig.unitypackage OK
testing: firebase_unity_sdk/FirebaseDatabase.unitypackage OK
testing: firebase_unity_sdk/NOTICE OK
testing: firebase_unity_sdk/FirebaseInvites.unitypackage OK
testing: firebase_unity_sdk/FirebaseInstanceId.unitypackage OK
testing: firebase_unity_sdk/FirebaseDynamicLinks.unitypackage OK
testing: firebase_unity_sdk/FirebaseMessaging.unitypackage OK
testing: firebase_unity_sdk/FirebaseAnalytics.unitypackage OK
No errors detected in compressed data of firebase_unity_sdk_4.5.2.zip.
On Windows 10 in a Cygwin terminal window
$ shasum firebase_unity_sdk_4.5.2.zip
6dc804084b20cb16d712cf5b83297952276ff82e *firebase_unity_sdk_4.5.2.zip
$ unzip -lt firebase_unity_sdk_4.5.2.zip
Archive: firebase_unity_sdk_4.5.2.zip
testing: firebase_unity_sdk/ OK
testing: firebase_unity_sdk/FirebaseStorage.unitypackage OK
testing: firebase_unity_sdk/FirebaseAuth.unitypackage OK
testing: firebase_unity_sdk/readme.md OK
testing: firebase_unity_sdk/FirebaseRemoteConfig.unitypackage OK
testing: firebase_unity_sdk/FirebaseDatabase.unitypackage OK
testing: firebase_unity_sdk/NOTICE OK
testing: firebase_unity_sdk/FirebaseInvites.unitypackage OK
testing: firebase_unity_sdk/FirebaseInstanceId.unitypackage OK
testing: firebase_unity_sdk/FirebaseDynamicLinks.unitypackage OK
testing: firebase_unity_sdk/FirebaseMessaging.unitypackage OK
testing: firebase_unity_sdk/FirebaseAnalytics.unitypackage OK
No errors detected in compressed data of firebase_unity_sdk_4.5.2.zip.
Unzipping with the explorer integrated archiver works fine as well. Does the SHA1 checksum differ on your machine?
@KaspYar does https://github.com/firebase/quickstart-unity/tree/master/analytics/testapp work for you? If you don't upgrade Google Play Services then continue attempting to use the SDK it will throw exceptions, that's the expected behavior.
@stewartmiles Interesting thing - sha doesn't match if I download from Ukraine (even vpn server in Ukraine), but If I use VPN of any other country - all is good. Do you have any guesses what can be a reason?
Can this be a problem with CDN?
I tried from different regions in Ukraine and its all same wrong.
Hi, I work on the download infrastructure.
@mmvlad can you provide:
1 • the exact steps you are using to get firebase_unity_sdk_4.5.2.zip
2 • whether there are any proxies, VPN software, download accelerators, or similar installed, and if so, how it is configured and whether it is in use
3 • the size and hash of the package you downloaded - a dump of the first and final ten bytes would also be handy
I have a suspected cause but can't repro without more details. :-/
@KaspYar @mmvlad any chance you have additional details for @jpawlicki it would be great to help debug this issue.
@jpawlicki @stewartmiles Sorry for late response, I just downloaded the file and it passes all checks now.
I believe the problem before was not my proxy or vpn as I asked few friends from different regions of Ukraine to download the file and they all had shasum 9691372e603d2b1e73c2d1e7052d95b703d82ffd
@stewartmiles
The same problem "When I build apk file with Mono, special window is shown with message to update play services. When I build apk file with il2cpp, game crash without showing window with message to update play services. " can be reproduced by below step.
Install the apk in Android Device witch device without google play services. The apk contain Firebase Message SDK.
I don't know if it can help you. I can provide more detail if you need.
@keepup we ended up just checking if required play services version exists on user device from C# instead of allowing firebase to do that. Here is basic code
```c#
using Com.Google.Android.Gms.Common;
AndroidJavaClass clazz = new AndroidJavaClass("com.google.android.gms.common.GoogleApiAvailability");
AndroidJavaObject obj = clazz.CallStatic
var androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = androidJC.GetStatic
int status = obj.Call
if (status == ConnectionResult.SUCCESS)
{
Debug.Log("All good");
}
else
{
if(status == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED){
Debug.Log("Update needed");
}
else {
Debug.Log("Instalation needed");
}
}
```
@stewartmiles
According to your message "If you don't upgrade Google Play Services then continue attempting to use the SDK it will throw exceptions, that's the expected behavior." I should ask all Android users to update(or install according to @keepup ) GooglePlayServices on their devices to play game. Do you really think this behavior is expected?
@keepup
According to ConnectionResult some more status codes
0 == success
1 == service_missing
2 == update service required
3 == service disabled
18 == service updating
9 == service invalid
@mmvlad Thanks for your code, I'll try it.
@KaspYar Thanks for your tips too.
@KaspYar if our SDK requires Google Play Services Version N and the user has installed N-1 then, yes they must upgrade to play your game. Typically, Google Play Services is updated transparently for most users so they should not end up out of date in the first place. @mmvlad we already do something similar internally along with the upgrade flow when you call https://firebase.google.com/docs/reference/unity/class/firebase/firebase-app#class_firebase_1_1_firebase_app_1a330d32bf55497c14bb1393a0a8936868
@stewartmiles the difference is that your internal version crashes with il2cpp and custom doesn't and opens Upgrade play services dialog as it should.
@mmvlad what crash were you running into in this case? In the worst case it should just throw an exception.
@stewartmiles Maybe it is not a crash. The app is shut down by Firebase when play services unavailable.
@stewartmiles same issue with quickstart messaging project built in Unity 2017.4.3f1 with IL2CPP on device with outdated Google Services:
logcat before crash:
05-23 12:37:17.376 29252-29421/com.*.* I/firebase: Firebase App initializing app com.*.* (default 1).
05-23 12:37:17.376 29252-29421/com.*.* I/Unity: Firebase App initializing app com.*.* (default 1).
05-23 12:37:17.386 29252-29421/com.*.* I/firebase: Firebase Analytics API Initializing
05-23 12:37:17.386 29252-29421/com.*.* I/Unity: Firebase Analytics API Initializing
05-23 12:37:17.396 29252-29421/com.*.* I/firebase: Firebase Analytics API Initialized
05-23 12:37:17.396 29252-29421/com.*.* I/Unity: Firebase Analytics API Initialized
05-23 12:37:17.406 29252-29421/com.*.* W/GooglePlayServicesUtil: Google Play services out of date. Requires 12211000 but found 11302036
05-23 12:37:17.406 29252-29421/com.*.* E/firebase: Messaging already shut down.
stacktrace from debugger while crashing:
unw_get_proc_info 0x000000007fd5157a
_Unwind_GetLanguageSpecificData 0x000000007fd5131e
__cxxabiv1::scan_eh_tab(__cxxabiv1::(anonymous namespace)::scan_results&, _Unwind_Action, bool, _Unwind_Control_Block*, _Unwind_Context*) 0x000000007fd49304
__gxx_personality_v0 0x000000007fd4917e
__gnu_Unwind_RaiseException 0x000000007a8a8504
___Unwind_RaiseException 0x000000007a8a9058
__cxxabiv1::__cxa_throw(void *, std::type_info *, void (*)(void *)) 0x000000007a881d92
::FirebaseAppUtils_GetLogLevel_m1056612665(FirebaseAppUtils_t2217984158 *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:26944
InterfaceFuncInvoker0<int>::Invoke(unsigned int, Il2CppClass*, Il2CppObject*) Bulk_Firebase.Platform_0.cpp:94
::FirebaseLogger_LogMessage_m2677119794(RuntimeObject *, int32_t, String_t *, const RuntimeMethod *) Bulk_Firebase.Platform_0.cpp:10186
::ReversePInvokeWrapper_FirebaseApp_LogMessage_m439117050(int32_t, char *) Bulk_Firebase.App_0.cpp:21112
firebase::AppLogCallback(firebase::LogLevel, char const*, void*) 0x000000007fcd32ec
firebase::LogMessageWithCallbackV(firebase::LogLevel, char const*, std::__va_list) 0x000000007fcf43cc
firebase::LogError(char const*, ...) 0x000000007fcf443e
firebase::AppCallback::NotifyAllAppDestroyed(firebase::App*) 0x000000007fd00144
firebase::app_common::RemoveApp(firebase::App*) 0x000000007fcfb308
firebase::App::~App() 0x000000007fd22340
firebase::AppCreate(firebase::AppOptions const*, char const*) 0x000000007fcd2574
firebase::AppGetDefaultInstance(firebase::AppOptions const*) 0x000000007fcd231e
::AppUtilPINVOKE_FirebaseApp_CreateInternal__SWIG_0_m111322871(RuntimeObject *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:14295
::FirebaseApp_CreateInternal_m1177889897(RuntimeObject *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:23300
::FirebaseApp_CreateAndTrack_m2466841502(RuntimeObject *, CreateDelegate_t3131870060 *, FirebaseApp_t2526288410 *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:22340
::FirebaseApp_CheckDependenciesInternal_m1404184582(RuntimeObject *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:22789
::U3CCheckDependenciesU3Ec__AnonStorey5_U3CU3Em__0_m3930652477(U3CCheckDependenciesU3Ec__AnonStorey5_t80273224 *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:23847
::FirebaseApp_TranslateDllNotFoundException_m3112929971(RuntimeObject *, Action_t1264377477 *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:21313
::FirebaseApp_CheckDependencies_m376892460(RuntimeObject *, const RuntimeMethod *) Bulk_Firebase.App_0.cpp:22735
::U3CStartNewU3Ec__AnonStorey0_1_U3CU3Em__0_m599013847_gshared(U3CStartNewU3Ec__AnonStorey0_1_t235693833 *, const RuntimeMethod *) Bulk_Generics_3.cpp:11393
RuntimeInvoker_Void_t1185182177_RuntimeObject(void (*)(), MethodInfo const*, void*, void**) Il2CppInvokerTable.cpp:17971
il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) Runtime.cpp:461
il2cpp::vm::ThreadPoolCompartment::WorkerThreadRunLoop() ThreadPool.cpp:838
il2cpp::vm::WorkerThreadEntryPoint(void*) ThreadPool.cpp:900
il2cpp::os::Thread::RunWrapper(void*) Thread.cpp:168
il2cpp::os::ThreadImpl::ThreadStartWrapper(void*) ThreadImpl.cpp:104
__thread_entry 0x00000000400a429c
pthread_create 0x00000000400a4434
probably FirebaseAppUtils_GetLogLevel crashes on call FirebaseApp after App::~App called
We were still unable to reproduce your failure but in 5.0.0 we resolved a few issues with the Google Play services updater, could you give version 5.0.0 a try?
https://firebase.google.com/support/release-notes/unity#5.0.0
@stewartmiles Version 5.0.0 is still the same issues.
It's easy to reproduce this failure for me. Only need to meet two conditions on it:
@artykod if it brings down the app, that definitely looks like a crash to me.
@keepup thanks for the clear repro instructions, we'll take a look.
Ok, I took a look at this today and found the issue. It looks like the bug may be in IL2CPP (not entirely sure on the runtime standard here) since it doesn't propagate exceptions over C++/C# boundaries. When checking dependencies, internally we attempt to create FirebaseApp and if that fails we set an exception to be thrown from C++ then log an error. Unfortunately, the process of logging an error ends up transitioning back to C# to log via Unity's logger and calls back to C++ to get the currently set log level which picks up the pending exception (set when app creation failed) and throws it, this exception propagates up to the C++/C# boundary where the log method occurred and IL2CPP tears down the app at this point since the exception isn't handled by a C# handler in the stack frame below the C++ -> C# call. In the Mono runtime case a C# exception thrown by a method called from C++ appears to propagate back up to the outer most C# context which runs the code in our exception handler to deal with app creation failing.
Long story short, I have a fix which we'll roll into our next build which is ~10 days out.
Workarounds:
Firebase/Plugins/Firebase.App.dll in your project.We have a project on Unity 2018.2, using IL2CPP and .NET 4.6 in order to make use of RestSharp for our own network connections. Currently only creating ARMv7a APKs. Integrating Firebase 5.0 Analytics and Messaging, making sure to remove the old Parse plugins and enable the .NET 4.5 ones, we get the app locking up during (or directly after, before a render update) the splash screen. There is 0 relevant messaging (no exceptions, crash logs or anything else) on my Xperia XZ, and ANR never triggers. If I try to put Debug.Log() messages in my C# code before and after the dependency check code, none of them ever fire.
I have tried uninstalling, reinstalling, removing and moving the plugins and the dependency code. Very rarely the app actually works, but most of the time it locks up at the splash screen. I have the patched DLL from the comment above, and that has not helped the situation in way.
We need an urgent fix for this, and we cannot downgrade due to our requirements for RestSharp.
These problems don't happen on iOS, that works perfectly (also using IL2CPP).
@BenSteenson the patch I posted above was to handle the case where Google Play services is out of date and the SDK takes the user through the update flow using IL2CPP. What you're describing sounds unique to your project, are you able to reproduce the issue with our sample project? If not, I recommend opening a ticket via http://firebase.google.com/support then you can share your project with us and we can take a look into what's going on.
@stewartmiles Thank you for these workarounds.
I'd prefer to use il2cpp in my project, so I tried to build my app with patched Firebase.App.dll and got an error during build
IL2CPP error for type 'Firebase.Platform.FirebaseAppUtils' in assembly '\Temp\StagingArea\assets\bin\Data\Managed\Firebase.App.dll'
Additional information: Build a development build for more information. Interface Firebase.Platform.IFirebaseAppUtils method System.Void Firebase.Platform.IFirebaseAppUtils::OnCreate() not implemented on non-abstract class Firebase.Platform.FirebaseAppUtils
Could you, please, help me to resolve this issue on my current firebase version?
The 5.1.0 release of the Firebase Unity SDK resolves this issue:
Release notes: https://firebase.google.com/support/release-notes/unity#5.1.0
Download: https://firebase.google.com/docs/unity/setup
Most helpful comment
Ok, I took a look at this today and found the issue. It looks like the bug may be in IL2CPP (not entirely sure on the runtime standard here) since it doesn't propagate exceptions over C++/C# boundaries. When checking dependencies, internally we attempt to create FirebaseApp and if that fails we set an exception to be thrown from C++ then log an error. Unfortunately, the process of logging an error ends up transitioning back to C# to log via Unity's logger and calls back to C++ to get the currently set log level which picks up the pending exception (set when app creation failed) and throws it, this exception propagates up to the C++/C# boundary where the log method occurred and IL2CPP tears down the app at this point since the exception isn't handled by a C# handler in the stack frame below the C++ -> C# call. In the Mono runtime case a C# exception thrown by a method called from C++ appears to propagate back up to the outer most C# context which runs the code in our exception handler to deal with app creation failing.
Long story short, I have a fix which we'll roll into our next build which is ~10 days out.
Workarounds:
Firebase/Plugins/Firebase.App.dllin your project.