firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
821 stars 425 forks source link

[FR] Support to launch two desktop standalone instances using Auth #967

Open HarrisonShort opened 3 years ago

HarrisonShort commented 3 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Having multiple builds on the one Mac with different names causes SaveUserData and DeleteUserData keychain errors. It seems as if the delete error appears once, followed by the adding error, and then the deleting error once more.

Error -25299 adding <app>.firebase.auth/__FIRAPP_DEFAULT: The specified item already exists in the keychain.
Error -25244 deleting <app>.firebase.auth/__FIRAPP_DEFAULT: Invalid attempt to change the owner of this item.

While this appears to mostly only be an issue for our dev team, we just want to find out whether there is anything we can do about it, as theoretically it could happen to end-users. Our builds are distributed through direct website downloads, rather than the Mac App Store, which means in the unlikely event that someone keeps an old build and renames it to something, this may occur.

Steps to reproduce:

  1. Create two versions of application using Firebase Auth for login, with different names (appending "copy" to the end of the name is sufficient).
  2. Clear keychain of anything related to application.
  3. Open primary build instance.
  4. Sign into any account.
  5. Application password is created in keychain.
  6. Open secondary build instance.
  7. Errors will occur.
chkuang-g commented 3 years ago

@HarrisonShort

Just to clarify: Are you trying to build standalone Mac desktop application using Firebase SDK?

I believe this is related to the persistent storage in Auth. On Mac, the login status and tokens are stored in keychain named <your-package-name>.firebase.auth/<name-of-FirebaseApp>

That is, given that your package name and FirebaseApp is not changed for your two versions, they will be stored with the same name in keychain. The second instance will not be able to access the keychain and therefore cause the error.

Unfortunately, this is not a supported scenario for Firebase desktop implementation now. We only expect one instance per desktop, primarily to support running in Unity editor. See also #928. This is a different issue but not supported currently.

May I understand your use case to launch two instances on the same desktop? As I said, as long as either package name or FirebaseApp name is different, Auth API should store the persistent data in different key name.

I will change this to a feature request. Let me know if the workaround works for your case.

Shawn

HarrisonShort commented 3 years ago

@chkuang-g

Yes, we have a companion program to our main Android and iOS app that runs on standalone desktop platforms.

Thanks for getting back to us on this. For more clarification, we are not attempting to run two instances at the same time, but because we provide a direct download to the standalone Mac program it is possible for users to have two different builds of the same app on their computers (especially in the case that we push an update). When one is named differently to the other, the second instance will throw these errors.

All things considered, this is quite a specific edge case and we understand that it is unlikely to receive much attention since it doesn't effectively break anything. I will try the workaround and report back.

Thanks again. (: