Open gamma-omg opened 2 months ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hi @gamma-omg, thanks for reaching out. Were you using a previous version of Firebase Analytics before encountering this issue? If so, could you share which version was it? I'm wondering if this was caused by a recent update in our native Firebase Android SDK which was added during the release of version 12.1.0 of Firebase Unity SDK.
Hi @argzdev, thanks for your reply. We were using Firebase 11.9.0 when we first encountered this issue. We had been using this version for quite some time without any problems. However, when we started using the FirebaseAnalytics.SetConsent
API, it began to crash. We tried updating to 12.1.0, but the problem persisted.
Thanks for the extra details, @gamma-omg. Any chance you could share some sample code snippets of your usage with FirebaseAnalytics.SetConsent
so we can narrow down our investigation? Thanks!
@argzdev Hi! Unfortunately, I can't provide you with detailed source code, but here's what we basically do:
Before using any Firebase APIs, we ensure that Firebase is fully initialized by calling our initialization method, which caches the initialization task to prevent redundant calls:
await FirebaseService.Require();
The FirebaseService.Require method works as follows:
public static async Task<bool> Require()
{
if (_initTask != null)
{
return await _initTask == DependencyStatus.Available;
}
_initTask = FirebaseApp.CheckAndFixDependenciesAsync();
var status = await _initTask;
if (status == DependencyStatus.Available)
{
FirebaseApp _ = FirebaseApp.DefaultInstance;
return true;
}
return false;
}
Once Firebase is initialized, we set the user's consent preferences using FirebaseAnalytics.SetConsent. The consent statuses are determined using Google's User Messaging Platform (UMP):
var consentMap = new Dictionary<ConsentType, ConsentStatus>
{
{ ConsentType.AdStorage, GetConsentStatus(ConsentModeService.Purpose.Purpose01) },
{ ConsentType.AnalyticsStorage, GetConsentStatus(ConsentModeService.Purpose.Purpose01) },
{ ConsentType.AdUserData, GetConsentStatus(ConsentModeService.Purpose.Purpose01, ConsentModeService.Purpose.Purpose07) },
{ ConsentType.AdPersonalization, GetConsentStatus(ConsentModeService.Purpose.Purpose03, ConsentModeService.Purpose.Purpose04) }
};
FirebaseAnalytics.SetConsent(consentMap);
If you need any additional information, please let me know. I'll try to help you as much as I can.
We have the same problem. Any updates?
Description
We are experiencing a significant number of crashes related to Firebase Analytics when calling the
FirebaseAnalytics.SetConsent
method, as reported by Google Play Console. Below are the details from the crash logs:Even with invalid parameters passed to
FirebaseAnalytics.SetConsent
, we expect this method to handle errors gracefully by either throwing an exception or logging the error. However, it currently causes the application to crash.Could you please investigate this issue? Ideally, the method should fail gracefully without crashing the app.
Reproducing the issue
We were unable to reproduce the issue locally and have only observed it through crash logs provided by Google Play Console. According to these reports:
Firebase Unity SDK Version
12.1.0
Unity editor version
2022.3.41f1
Installation Method
.unitypackage
Problematic Firebase Component(s)
Analytics
Other Firebase Component(s) in use
Analytics, Crashlytics, Messaging, Remote Config
Additional SDKs you are using
Targeted Platform(s)
Android
Unity editor platform
Mac, Windows
Scripting Runtime
IL2CPP
Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
Relevant Log Output
No response
If using CocoaPods for Apple platforms, the project's Podfile.lock
No response