Closed amakh closed 4 years ago
Thanks for your report!
If you don't mind, I'd like you to help me try to work through some things. First, you can debug Analytics stuff in near real time. You can see this blog post about it, and if the iOS specific instructions are a little confusing (they were for me as a primarily Unity-based developer) I briefly go over it in the middle of this blog post (search for "And on iOS it’s a command line argument you pass to your application:"). You'll likely not need to wait any more than a minute or two to see new events coming in on stream view!
Second, your firebase init looks correct. You can try calling SetAnalyticsCollectionEnabled(true)
as I do here, but you shouldn't have to if you're grabbing a reference to FirebaseApp as you are above. Let us know if that does fix it though.
Finally, if I could ask you to do a couple of things that will be a little time consuming but will help us immensely since you're in a known bad state:
1) Can you reproduce this in the test app with your current setup (Catalina, Unity 2019.3 beta, Firebase 6.6.0)?
2a) if you can reproduce it in the test app, can you reproduce it in the latest 2019.2 stable release (2019.2.10)? My goal would be to isolate the issue to Unity or the system (possibly Catalina, but we'll go from there).
2b) if you can't reproduce it in the test app, can you check to see if there are any garbage collection/cleanup events that might cause FirebaseAuth to get cleaned up in your current game? I think the best way to test this would be to mark whatever script you call CheckAndFixDependenciesAsync
on DontDestroyOnLoad
and cache FirebaseAuth
in it. An example from a project I'm currently working on is this:
using Firebase;
using Firebase.Auth;
using Firebase.Extensions;
using UnityEngine;
using UnityEngine.Events;
public class FirebaseInit : MonoBehaviour
{
public UnityEvent OnFirebaseInitialized = new UnityEvent();
public FirebaseAuth Auth { get; private set; }
private void Start()
{
DontDestroyOnLoad(gameObject);
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
{
if (task.Exception != null)
{
Debug.LogError($"Failed to initialize Firebase with {task.Exception}");
return;
}
Auth = FirebaseAuth.DefaultInstance;
OnFirebaseInitialized.Invoke();
});
}
private void OnDestroy()
{
Auth = null;
}
}
Historically there have been issues with the Firebase singletons getting cleaned up during scene transitions (or, when those get fixed, with the singletons remaining alive between run cycles in Unity). My goal of 2b is to try to determine if that may be happening.
Let me know if any of that helps, or if you're still in a buggy state! --Patrick
First, thanks for your support and your detailed answer.
I managed to try several things but unfortunately i'm still at the same point:
Adding DontDestroyOnLoad(gameObject);
did change the logs in Xcode and now I have this in addition to my previous logs:
[Firebase/Analytics] Uploading data. Host: https://app-measurement.com/a
[Firebase/Analytics] Received SSL challenge for host. Host: https://app-measurement.com/a
[Firebase/Analytics] Successful upload. Got network response. Code, size: 204, -1
Note that I still have the message Google Analytics for Firebase has not been created. Please, configure Firebase by calling [FIRApp configure]
With debug mode on, still nothing appears in Firebase (I do have the log message saying that debug mode is on) [Firebase/Analytics] Debug logging enabled
I tried the analytics/testapp (not the Auth one because I only use Analytics in my project and it's easier not to configure push notifications from Xcode).
The same logs appeared in Xcode and still nothing in Firebase with debug mode on. In the testapp when I touch the Show Analytics Instance ID button, it does show me an ID and when I touch on Log I do have this message in Xcode:
[Firebase/Analytics] Event logged. Event name, event params: app_background (_ab), {
ga_debug (_dbg) = 1;
ga_event_origin (_o) = auto;
ga_realtime (_r) = 1;
ga_screen_class (_sc) = UnityDefaultViewController;
ga_screen_id (_si) = 1305332228125746591;
}
I think this is coming from my setup and maybe from Xcode (v11.1) because again, everything's working with Android. For now I don't have another setup to try. I wanted to build the testapp with Unity 2019.2 but Catalina broke the compatibility with this version (the iOS build is broken).
Do you want me to try other things? I should be able to find another setup for building my app by the end of next week.
@patm1987 I just tried the same project with unity 2019.2 and it worked.
Some stuffs however :
IS_ANALYTICS_ENABLED
to NO (I did set to YES before opening this issue).Do you know what could have gone wrong from 2019.2 to 2019.3 and if I can try to change anything manually in the SDK because I really need to build my project with unity 2019.3?
Hi @amakh. Thanks for the extra info. The team will investigate the differences between .2 and .3 and see if we can work out whats going on.
@amakh the "Firebase has not been created" message is spurious and caused by the way we initialize the iOS SDK from the C++ SDK since the initialization flow is pretty different in Unity / games vs. other iOS applications.
IS_ANALYTICS_ENABLED
in GoogleService.plist
is not used by the current Firebase Analytics iOS SDK. Build time configuration is described in https://firebase.google.com/docs/analytics/configure-data-collection?platform=ios
Hi, do we have any update on this? Actually in unity 2019.2.17f1 nor 2019.3.1 (latest), analytics doesn't show any data on iOS but does with Android. This time I used the latest SDK : 6.10.0 and Xcode 11.3.1
Xcode is showing me this error actually:
[Firebase/Analytics][I-ACS901017] Encounter network error. Code, error: -1004, Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x2829505d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <A51C0EA8-F8E4-4CB8-8B14-29BA77F2EBF1>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <A51C0EA8-F8E4-4CB8-8B14-29BA77F2EBF1>.<2>" ), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://cdp.cloud.unity3d.com/v1/events, NSErrorFailingURLKey=https://cdp.cloud.unity3d.com/v1/events, _kCFStreamErrorDomainKey=1}
PS : Is there any release note for the SDK?
Update: Sorry, it looks like my connection was blocking the request to Firebase. I can tell that everything works fine actually!
Please fill in the following fields:
Unity editor version: 2019.3b Firebase Unity SDK version: 6.6.0 Firebase plugins in use (Auth, Database, etc.): Analytics Additional SDKs you are using (Facebook, AdMob, etc.): None Platform you are using the Unity editor on (Mac, Windows, or Linux): MacOS Catalina Platform you are targeting (iOS, Android, and/or desktop): iOS / Android Scripting Runtime (Mono, and/or IL2CPP):
Please describe the issue here:
I followed this setup : https://firebase.google.com/download/unity On my main scene in unity I added the following setup:
Building on my device with Xcode, I have those logs: Note that the first one is saying that Analytics is enabled right ? I did create the app in Firebase and Analytics with the correct bundle ID and I do have the config files in my project. It does actually work on my Android device.
No data are showing in Firebase (it's been 2 days). What do I miss here please? Looks like #101