How can two instances of firebase run on a single machine for testing multiplayer builds in Unity?

Viewed 330

I'm getting really frustrated with Firebase devs who close my questions just because they don't contain minimum reproducible code. This is a valid question and there are useful answers out there.

My Firebase app works in the editor, and it works in build, but when I try to run both at the same time, the second instance crashes once the first Firebase command is invoked (firestore snapshot).

I suspect that I may need to create a firebase instance with a different name, but I'm not sure how. Right now the two instances both use Firebase.DefaultInstance.

The crash gives no errors, and the editor logs show everything runs fine until

Query q = db.Collection("matches").OrderByDescending("players");
QuerySnapshot snapSht = await q.GetSnapshotAsync();

How do I run a second Unity-Firebase instance on a single local machine for multiplayer testing?

Steps to reproduce problem:

  1. Install and set up firebase in Unity per the documentation
  2. Initialize the app and fetch a snapshot from Firestore
  3. Build and run the app
  4. While build is running, press play in Unity Editor. Once the snapshot code runs, Unity will crash.
  5. If Editor is run first, the build will be the one to crash
1 Answers
Related