firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
216 stars 35 forks source link

[Bug] Windows user containing non-ANSI characters (e.g. ä) causes Unity Editor crash in Firestore #351

Closed Karottenrambo closed 1 year ago

Karottenrambo commented 2 years ago

[REQUIRED] Please describe the issue here:

Accessing the Firestore DB constantly crashes/closes the Unity editor without a freeze or a crashlog. It does not matter if I get a DocumentReference, or try to read or write data. Running the same code on an actual android device works.

Steps to reproduce:

Followed the basic Add Firebase to your Unity Game Firecast:

https://www.youtube.com/watch?v=b5h1bVGhuRk&t=283s

I already tried creating an separate Firestore Instance like so: FirebaseFirestore db = FirebaseFirestore.GetInstance(Firebase.FirebaseApp.Create());

working with the default instance does not work either.

The issue looks similar to this, but I already tried the suggested solutions and it should be fixed in the new SDK version anyways: https://github.com/firebase/quickstart-unity/issues/638

Unity created the "google-services-desktop" config file, but it's identical to the original "google-services" file, should that be the case?

ehsannas commented 2 years ago

Thanks for reporting @Karottenrambo . Would you be able to provide the Unity Editor logs located at %LOCALAPPDATA%\Unity\Editor\Editor.log?

Karottenrambo commented 2 years ago

Sure, but I could not find anything suspicious :/

Editor.log

one thing that I did that was not according to the tutorial was, removing Unity.Compat.dll and Unity.Tasks.dll from the folder Parse/Plugins. With them I got an "Type Task<> exists in both Unity.Tasks and mscorelib" error.

dconeybe commented 2 years ago

Make sure that you are importing the Firebase unitypackage file(s) from the dotnet4 folder. It sounds like you incorrectly imported the unitypackage file(s) from the dotnet3 folder, which contain an implementation of Task that is not required when using newer versions of the Unity Editor (like you are: 2021.3.1f1).

Karottenrambo commented 2 years ago

I imported the package from the dotnet4 Folder. Delteted the 2 DLLs from the Plugins rootfolder and kept the ones from dotnet45 dotnet4

dconeybe commented 2 years ago

You should not have to manually delete Unity.Compat.dll or Unity.Tasks.dll. If you do, then something is going wrong.

Could you try creating a brand new, minimal project that uses Firestore to see if you still get this crash with that new project? If you are able to reproduce, could you post your project in a GitHub repository so that we can observe the crash for ourselves and investigate?

Karottenrambo commented 2 years ago

I reimported the package and commented out the Code that used "Task" so I could build without the Build error. So I have all DLLs in place but I still have the same issue.

I created a minimal version: https://github.com/Karottenrambo/FirebaseCrashTest

But there I get the same issue :/

I guess it might be related to my machine, but how to debug without any kind of logs?

dconeybe commented 2 years ago

That project still looks like it had previously incorrectly imported the unitypackage files from the dotnet3 folder.

Please try the following:

  1. Download the latest Firebase Unity SDK from https://firebase.google.com/download/unity (at the moment the latest version is 9.0.0).
  2. In the Unity Editor, go to Assets -> Import Package -> Custom Package.
  3. Select dotnet4\FirebaseFirestore.unitypackage; accept any prompts that it displays.
  4. Repeat the previous two steps for FirebaseAnalytics.unitypackage.
  5. If prompted to delete "obsolete" files, accept that suggestion.

This should get rid of the previously-imported dotnet3 files. See if it still crashes after that.

Karottenrambo commented 2 years ago

Unfortunately I still experience the same issue, tried updating both, my original project and the minimal build. Also tried completely removing the Firebase 8.10.1 SDK and reimporting the 9.0.0 version.

I updated the repository

where do you see the incorrectly imported files from dotnet3?

I really hope we can find a solution for this, on paper Firestore would fit my game much better than playfab...

dconeybe commented 2 years ago

Hi @Karottenrambo. Unfortunately, I'm not able to assist further in this investigation. The only thing I can recommend is to try creating a brand new Unity project, import the Firestore unitypackage asset, and try and use Firestore. If that works for you then there is possibly something corrupted in your unity project. If that doesn't work for you, then there will be a much smaller reproducible scenario to investigate.

Karottenrambo commented 2 years ago

hey @dconeybe

https://github.com/Karottenrambo/FirebaseCrashTest

is a brand new unity project, as you suggested, on my Windows PC it still has the same crashing behavior as on my original Project.

However, meanwhile, I tried checking out the project on my Mac, there accessing the database works without any issues inside the unity Editor.

So it seems indeed connected to my windows PC.

Might there be any issues with accessing the local path that firststore uses for the offline database support? Or any other ideas to gather more information, the crashing without any kind of logs or pointer where to look for is really the biggest problem...

dconeybe commented 2 years ago

I'm not able to reproduce the crash with your project, even on Windows.

This may be a lot to ask, but would you be able to record a screen capture video of you creating a new project, importing the Firebase unitypackage files, creating a csharp script that uses the Firestore APIs, then crashing? I'm now sure how else to proceed in the absence of logs and reproducibility.

Karottenrambo commented 2 years ago

I fear that you won't see a lot of useful info in there, but if it helps:

https://www.youtube.com/watch?v=blhs_G9yQgA

dconeybe commented 2 years ago

That video was actually incredibly helpful! I noticed something subtle. I believe you are experiencing https://github.com/firebase/firebase-cpp-sdk/issues/728. Basically, if the path to your %USERPROFILE% folder contains non-ANSI characters (e.g. ä) then this causes a crash on Windows. If you're able, could you try creating a user with only plain ANSI characters and try the same steps when logging in as that user?

Karottenrambo commented 2 years ago

This really was the issue, thanks!

But I really hope that this gets fixed in the future, outside of the anglo American language are many names with special characters, all those users are affected by this bug.

There is no easy workaround for this, renaming the user folder, even with changing the registry, breaks other software, and constantly switching user accounts is really annoying.

Is there a way to manually set the path?

dconeybe commented 2 years ago

I'm glad we've found the root cause and a workaround, albeit an annoying workaround.

I'm going to transfer this issue to https://github.com/firebase/firebase-unity-sdk so that we can keep track of it and hopefully fix it in the future. I cannot provide any timeline for the fix, but it will likely be a while due to other priorities.

deveshbeniwal commented 2 years ago

The same thing happening with me too! image This is my crash log . . Unity - 2021.3.5 Firebase Firestone sdk - 9.1.0 . I tried in new project and still have issue! Tried downgrading the sdk version but still not working.

Wherever the write "CollectionReference usersRef = db.Collection("users");" Editor get crashed. Please give solution asap. i have to deliver the project

deveshbeniwal commented 2 years ago

I don;t even have ANSI Characters but still crashing the same way as @Karottenrambo

dconeybe commented 2 years ago

@deveshbeniwal Could you open a new issue and paste your stack trace? Perhaps there is something subtly different in your case and we can take a look.

deveshbeniwal commented 2 years ago

@dconeybe Already posted as a new bug which you closed Here it is! Please check - https://github.com/firebase/firebase-unity-sdk/issues/381

dconeybe commented 2 years ago

For the record, I closed it as a duplicate.

Here is the canonical issue for your problem: https://github.com/firebase/quickstart-unity/issues/1284

deveshbeniwal commented 2 years ago

@dconeybe then what should i do now? Should i make a new bug or you'll reopen this? Or working on this one only?

dconeybe commented 2 years ago

@deveshbeniwal You should just follow https://github.com/firebase/quickstart-unity/issues/1284. If you have follow up questions or want to otherwise continue discussion please do so on that issue. But for now, there is no fix or known workaround.

deveshbeniwal commented 2 years ago

@dconeybe Got the solution! Unity project is making multiple instances for firestore or realtime database so we have to make it persistant after taking instance. You can declare instance like below -

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

NOTE : PersistenceEnabled must be false. Also this error might thorugh from firebase while we initialize instance. HOPE this will be get solved in next updates

avodhel commented 2 years ago

That video was actually incredibly helpful! I noticed something subtle. I believe you are experiencing firebase/firebase-cpp-sdk#728. Basically, if the path to your %USERPROFILE% folder contains non-ANSI characters (e.g. ä) then this causes a crash on Windows. If you're able, could you try creating a user with only plain ANSI characters and try the same steps when logging in as that user?

Is there any progress about this issue?

dconeybe commented 2 years ago

@avodhel Apologies, but no, there has been no progress on a fix for this issue.

AlejandroGUnity commented 2 years ago

@dconeybe Hi! Is there any update on this bug? My team and I are working for Asian companies and clients whom are very likely to have non-ANSI character in their computers and can't create new users.

Is there any ETA? We are currently using the Firebase SDK 9.4.0 in Unity 2022.1.14f1 and still experiencing this issue.

If not, is there any way we could try and solve this ourselves?

dconeybe commented 2 years ago

Unfortunately, no, there is no update on this bug and no ETA. The Firestore team, unfortunately, is not able to prioritize working on this bug at this time.

Back when I was investigating this issue, the place where I got stuck was figuring out how to get leveldb (https://github.com/google/leveldb) to open a database at a path that contains non-ANSI characters on Windows. I just couldn't figure out how to do it, and that is why Unity is crashing when there are non-ANSI characters in the path. Apparently Chromium (https://github.com/chromium/chromium) has no issue with this so I was trying to figure out how that project worked around this issue. But I was never able to find a solution, and my priorities have since shifted.

If anyone is ambitious and can figure out how to get leveldb to open a database on Windows at a path containing non-ANSI characters that would be incredibly helpful. I know I could figure it out given enough time, but I just don't have the time right now.

yubingxdc commented 1 year ago

any update for this issue?

dconeybe commented 1 year ago

This issue is fixed in v11.1.0 (https://firebase.google.com/support/release-notes/unity#version_1110_-_june_01_2023). Please try it out!