Skip to content
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

[Bug] Firestore does not allow two instances of project to run at the same time on the same computer #885

Closed
Olof-IL opened this issue Oct 20, 2023 · 4 comments

Comments

@Olof-IL
Copy link

Olof-IL commented Oct 20, 2023

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2021.3.16
  • Firebase Unity SDK version: 11.1
  • Source you installed the SDK: unitypackage (.unitypackage or Unity Package Manager)
  • Problematic Firebase Component: Firestore (Auth, Database, etc.)
  • Other Firebase Components in use: FirebaseAnalytics, FirebaseAuth, FirebaseCrashlytics, FirebaseDatabase, FirebaseFirestore, FirebaseFunctions, FirebaseMessaging, FirebaseRemoteConfig
  • Additional SDKs you are using: play-games-plugin-for-unity-10.14 (Facebook, AdMob, etc.)
  • Platform you are using the Unity editor on: Mac (Mac, Windows, or Linux)
  • Platform you are targeting: iOS, Android, Issue when running in Editor (iOS, Android, and/or desktop)
  • Scripting Runtime: Mono and IL2CPP (Mono, and/or IL2CPP)
  • Pre-built SDK from the website or open-source from this repo: prebuilt

[REQUIRED] Please describe the issue here:

It seems it is impossible to run two instances of the same Unity project that use Firestore, on the same computer

Being able to do this is vital for us for developing and debugging multiplayer.

The problem is both instances try to create local database files at the same location.
The path the files are created at is this:
/Users/[user]/Library/Application Support/firestore/__FIRAPP_DEFAULT/[firebase-project-id]/main/LOCK

Since this file is already created by the first instance, the second instance crashes (and crash entire Unity Editor with it)

It would be much better if these files were created in [Unity-Project-Folder]/Temp instead, then it should work fine to run multiple instances of the project

Steps to reproduce:

  1. Create a simple Unity App using Firebase Unity SDK, using Firestore.

  2. Install ParrelSync in project for easily running multiple copies of the project, or simply copy it to a second folder/check out a second copy.

  3. Try start both at the same time.

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?

Haven't tried but it should have the same issue if it uses Firestore

What's the issue repro rate? (eg 100%, 1/5 etc)

100%

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

When launching player in the second editor instance, Unity crashes. This can be found in log:

libc abi: terminating with uncaught exception of type firebase::firestore::FirestoreInternalError: FIRESTORE INTERNAL ASSERTION FAILED: /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/arm64/bin/external/src/firestore/Firestore/core/src/core/firestore_client.cc(217) void firebase::firestore::core::FirestoreClient::Initialize(const firebase::firestore::credentials::User &, const firebase::firestore::api::Settings &): Failed to open DB: Internal: Failed to open LevelDB database at /Users/olle/Library/Application Support/firestore/__FIRAPP_DEFAULT/touchgrind-x-test/main: LevelDB error: IO error: lock '/Users/olle/Library/Application Support/firestore/__FIRAPP_DEFAULT/touchgrind-x-test/main/LOCK: Resource temporarily unavailable (expected created.ok())

ERROR: FIRESTORE INTERNAL ASSERTION FAILED: /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/arm64/bin/external/src/firestore/Firestore/core/src/core/firestore_client.cc(217) void firebase::firestore::core::FirestoreClient::Initialize(const firebase::firestore::credentials::User &, const firebase::firestore::api::Settings &): Failed to open DB: Internal:

Failed to open LevelDB database at /Users/olle/Library/Application Support/firestore/__FIRAPP_DEFAULT/touchgrind-x-test/main: LevelDB error: IO error: lock /Users/olle/Library/Application Support/firestore/__FIRAPP_DEFAULT/touchgrind-x-test/main/LOCK: Resource temporarily unavailable (expected created.ok())

@paulinon
Copy link
Contributor

Hi @Olof-IL,

Thanks for bringing this to our attention. This behavior you're facing may be similar to this issue in the quickstart repository. In order to confirm this, could you try disabling persistence as a workaround and see if it makes a difference? To do so, you simply declare the following:

db = FirebaseFirestore.DefaultInstance;
db.Settings.PersistenceEnabled = false;

@paulinon paulinon added the needs-info Need information for the developer label Oct 23, 2023
@Olof-IL
Copy link
Author

Olof-IL commented Oct 27, 2023

I can confirm setting this option stops unity from crashing, and enables us to run two instances.

It should be an acceptable workaround for our case, thanks!

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Oct 27, 2023
@paulinon
Copy link
Contributor

Glad to hear this, @Olof-IL. That said, I'll be closing this for now. Let me know if an issue arises.

@paulinon paulinon closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@dconeybe
Copy link
Contributor

Drive-by comment: If you want to use persistence in your production app but don't care about persistence during development, you can put #if UNITY_EDITOR around the call that disables persistence. For example,

db = FirebaseFirestore.DefaultInstance;
#if UNITY_EDITOR
db.Settings.PersistenceEnabled = false;
#endif

@firebase firebase locked and limited conversation to collaborators Nov 27, 2023
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

5 participants