Skip to content

Firebase Crashlytics unusable after FirebaseApp.delete() #6130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cooksimo opened this issue Jul 27, 2020 · 7 comments
Closed

Firebase Crashlytics unusable after FirebaseApp.delete() #6130

cooksimo opened this issue Jul 27, 2020 · 7 comments
Assignees

Comments

@cooksimo
Copy link

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 11.5
  • Firebase SDK version: 6.20.0
  • Firebase Component: Crashlytics
  • Component version: 4.0.0
  • Installation method: CocoaPods

Step 2: Describe the problem

This is a very similar problem to #3411. We allow the Firebase project in use to be changed at runtime, so we can switch between production, staging and sandbox environments. In trying to migrate to the Firebase Crashlytics SDK (from Fabric) we have run in to this issue, where recreating the Firebase app results in an error from Crashlytics: "Cannot instantiate more than one instance of Crashlytics."

Steps to reproduce:

  • Initialise Firebase as usual (with Crashlytics present)
  • Delete the app with FirebaseApp.delete
  • Configure the app again
  • See the error in the logs

Relevant Code:

This is caused by the following code in FIRCrashlytics.m

    if (!atomic_compare_exchange_strong(&_hasInitializedInstance, &expectedCalled, YES)) {
      FIRCLSErrorLog(@"Cannot instantiate more than one instance of Crashlytics.");
      return nil;
    }

Commenting this code out (obviously) fixes the issue, but I'm not sure what other implications it may have.

@Olegkodysh
Copy link

Thanks for the report. Could you please let me know how it is you're instantiating Firebase, and whether you're using different GoogleService files?

@demonar
Copy link

demonar commented Aug 7, 2020

I'm experiencing the same issue, using the same GoogleService files, the only thing needed is to do

FirebaseApp.app().delete { _ in FirebaseApp.configure() }

@demonar
Copy link

demonar commented Aug 7, 2020

here's my console message:

6.29.0 - [Firebase/Crashlytics][I-CLS000000] Cannot instantiate more than one instance of Crashlytics.

In my case we are using 6.29.0

@Olegkodysh
Copy link

Are you trying to delete this instance of the Firebase app when calling the .delete function, and then trying to configure it again? Does the error occur then?

@demonar
Copy link

demonar commented Aug 18, 2020

Are you trying to delete this instance of the Firebase app when calling the .delete function, and then trying to configure it again? Does the error occur then?

exactly

@anphanngocvn
Copy link

I am experiencing this issue. What was a solution for you @demonar ?

@elenadoty elenadoty self-assigned this Feb 9, 2021
@elenadoty
Copy link
Contributor

Hi @anphanngocvn @demonar ,
I believe that this is an internal bug with FirebaseApp (see also #4072). A work around (albeit, not ideal and a bit hacky) is to use the configure(name:options:) method for the second configuration:

FirebaseApp.configure(name: "newapp", options: FirebaseApp.app()!.options)

I'll update this ticket if there are any fixes to report.

@firebase firebase locked and limited conversation to collaborators Apr 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants