cjcurrie
cjcurrie

Reputation: 624

Unity with Firebase freezes after compile (AssetDatabase.Refresh)

After adding functionality to Listen to Firestore database updates, my Unity-Firebase app crashes whenever the AssetDatabase Refreshes. Looking in the error log I see

0x00007FFD2F8F6D06 (FirebaseCppApp-6_16_1) SWIGRegisterStringCallback_StorageInternal

And some other Firebase access errors. This only happens after adding ListenerRegistration to firestore documents, even though the listener registration is being .Dispose()d.

Upvotes: 2

Views: 353

Answers (1)

cjcurrie
cjcurrie

Reputation: 624

I'm posting this to SO because it took me many days to solve this problem and found no helpful information addressing one fundamental problem source: The Unity Getting Started Docs never inform you to use FirebaseApp.Dispose()

My solution was simple, though discovering it was not:

// During initialization:
firebaseApp = FirebaseApp.DefaultInstance;

// Clean up when quitting app
    private void OnApplicationQuit() {
        listenerRegistration.Dispose();  // Any event listener must be disposed
        firebaseApp.Dispose();  // the base firebase app must be disposed
    }

Upvotes: 1

Related Questions