firebase-unity-sdk icon indicating copy to clipboard operation
firebase-unity-sdk copied to clipboard

Editor freezes more than usual when hitting play.

Open axelbau24 opened this issue 4 years ago • 95 comments

Please fill in the following fields:

Unity editor version: 2019.3.7f1 Firebase Unity SDK version: 6.13.0 Source you installed the SDK (.unitypackage or Unity Package Manager): .unitypackage Firebase plugins in use (Auth, Database, etc.): FirebaseMessaging.unitypackage Additional SDKs you are using (Facebook, AdMob, etc.): None Platform you are using the Unity editor on (Mac, Windows, or Linux): Windows 10 Platform you are targeting (iOS, Android, and/or desktop): Android Scripting Runtime (Mono, and/or IL2CPP): Tried both

Please describe the issue here:

(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

Everytime i hit play (even on a empty project), Unity takes too long to build, compared to the usual time, this is not practical for me. Also, when the game starts (the play button becomes blue), the editor completely freezes for a few seconds as if it was compiling the game once again. Am i doing something wrong ?

To easily reproduce this issue:

  • Create a empty 3D project
  • Switch to Android Platform in the build settings
  • Import FirebaseMessaging.unitypackage from Assets -> Import Package
  • After import, a popup shows up to enable Android Auto-Resolution, click "Enable"
  • The Unity Packager Manager Resolver window opens, click "Add selected registries"
  • Wait until all dependencies update.
  • Don't add anything else, and hit "Play"
  • You will notice the editor freezing and taking way too long to build.

This problem happens even if you don't have any base code running. Also, tried adding the google-services.json, but it doesn't do anything in this case.

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? Yes, the exact same thing happens here, and it feels worse.

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

axelbau24 avatar Apr 10 '20 00:04 axelbau24

Hi @axelbau24 ,

Thanks for your report!

You've done everything right so far, but I've been unable to replicate the issue on my end. Can you tell me if you see any windows, dialogs, &c pop up after the first time you hit play (screenshot them if you like/can)? Do you see anything interesting in your Console window/would you mind sharing your Editor log? image

(note that if you don't feel comfortable sharing your Editor log publicly, you can file a bug here and link this issue/say you're trying to add information for this bug).

Is there anything else of interest that you can think of in your setup? Are you using meta files? A version control system other than Git? Is part of your unity project readonly or stored on a synced volume (ex: Dropbox, iCloud, &c)?

I'm checking in with the rest of the team to see if there's anything else we need to verify.

Thanks, --Patrick

patm1987 avatar Apr 14 '20 21:04 patm1987

I have similar experiences with Firebase Core and Analytics. If I remove them from the project then everything goes back to normal. I doubt that this would make any difference, but I used External Dependency Manager for Unity (EDM4U) and Unity Package Manager to install the packages.

Nothing is synced in the background for my project, it is a fairly straightforward setup. Code generation is set to .NET 4.x and IL2CPP, but changing the setting to Mono makes no difference.

A similar delay also happens when I switch from my code IDE (JetBrains Rider) to Unity editor, if there was any change on the source code and it is recompiled in the background Unity editor stops responding for a good 15-20 seconds.

I have tried profiling the editor to figure out what is going on. I am no expert on Unity profiling, but as it seems to me when this delay happens then profiler stops capturing anything until the editor starts working again.

Please let me know if there was any other information I could provide.

almosr avatar Apr 15 '20 08:04 almosr

I have attached the editor log from the moment I press the play button: editor_log.txt

This line looks rather suspicious to me:

Unloading 534 unused Assets to reduce memory usage. Loaded Objects now: 5522.
Total: 15.606300 ms (FindLiveObjects: 0.836300 ms CreateObjectMapping: 0.170500 ms MarkObjects: 13.140400 ms  DeleteObjects: 1.457900 ms)

Edit: nevermind, I just realised it is msecs. :)

almosr avatar Apr 16 '20 07:04 almosr

I might have the same issue. Looking at the editor profiler, there is at least one entry that seems suspicious to me: profiler

Note that I'm running on Windows 10. I can't say for sure if that XCodeProjectPatcher is related to firebase, but looking through some results on google it seems to be the case. But this seems to be a specific thing for IOS, so why is it running on my windows environment? It seems to be responsible for at least 4s of startup time.

I'm using Firebase 6.13, auth, database and analytics. And google admob. Running on SSD.

MateusMP avatar Apr 17 '20 15:04 MateusMP

Exact same issue mentioned by MateusMP. It takes almost 4-5 seconds to enter play mode in the empty project with just Firebase core installed from package manager.

daksheshpatel avatar Apr 17 '20 21:04 daksheshpatel

I am running Unity on Windows too, maybe this is an important piece of information.

almosr avatar Apr 17 '20 21:04 almosr

Thank you for your answer @patm1987

Here's my Editor Log Editor.log

Also, noticed some iOS stuff happening, even though i'm just compiling for Android, just like @MateusMP did, In my case i don't see anything related to XCode, just the iOS resolver (which i don't think it should be there and also taking a long time to compile.

profilerUnity

Is there any way to disable this iOS resolver?

EDIT: This was a completely empty project stored on my PC, no version control or cloud were used.

axelbau24 avatar Apr 18 '20 19:04 axelbau24

I'm having a similar symptom (8 second slowdown right after entering playmode). Platform is set to Android. Same Unity and SDK version as original poster. I have also tried disabling all auto-resolve functions in the package, but this seems to get called no matter what. This is a critical issue.

image

Using Google Analytics for Firebase, Firebase Core, and Firebase Cloud Messaging.

GorillaOne avatar Apr 21 '20 23:04 GorillaOne

I have the same issue. Freezes at 10-15 seconds on press play button.

Unity 2019.2.21, Firebase 6.12.0 and 6.13.0

leni8ec avatar Apr 22 '20 08:04 leni8ec

The majority of this slowdown appears to be due to the Google Play Resolver / External Dependency Manager. When removed, the slowdown goes away. Of course, Firebase won't load so you'll need to add it in again before you build - and this option only works when using the manual install because if you're using Firebase unity packages it will not let you uninstall the EDM because the firebase libraries rely on them.

GorillaOne avatar Apr 22 '20 23:04 GorillaOne

@GorillaOne How do I remove that? Thanks!

godiemp avatar Apr 23 '20 01:04 godiemp

I have the same issue. Freezes at 10-15 seconds on press play button.

Hauki avatar Apr 23 '20 07:04 Hauki

I’m having the same issue, but on top of this the editor freezing for 20seconds after each code save. It’s getting unbearable. What would normally take me 2 mins to do, takes 3-4x as long.

I also tried a vanilla build using a brand new project and only adding firebase - same issue.

Anyone else experiencing delays between code changes and then switching over to the editor (even with out play)?

kirilogan avatar Apr 24 '20 07:04 kirilogan

I believe this is the same issue as in firebase/quickstart-unity#644

L4fter avatar Apr 24 '20 14:04 L4fter

I believe this is the same issue as in firebase/quickstart-unity#644

I think you are right - I was looking at firebase/quickstart-unity#644 earlier and sounds very similar.

kirilogan avatar Apr 24 '20 16:04 kirilogan

The issue is still present in 6.14.0, EDM version 1.2.153.

As a workaround for those using the Package Manager versions, you can simply delete the Editor folder and Editor.meta file within Library/PackageCache/[email protected]/ExternalDependencyManager. You may have to do it every time you start Unity.

You'll sometimes get an error message about failing to load Firebase.Editor.dll, but it seems you can safely ignore it.

ideka avatar Apr 30 '20 14:04 ideka

The issue is still present in 6.14.0, EDM version 1.2.153.

As a workaround for those using the Package Manager versions, you can simply delete the Editor folder and Editor.meta file within Library/PackageCache/[email protected]/ExternalDependencyManager. You may have to do it every time you start Unity.

You'll sometimes get an error message about failing to load Firebase.Editor.dll, but it seems you can safely ignore it.

The issue is still present in 6.14.0, EDM version 1.2.153.

As a workaround for those using the Package Manager versions, you can simply delete the Editor folder and Editor.meta file within Library/PackageCache/[email protected]/ExternalDependencyManager. You may have to do it every time you start Unity.

You'll sometimes get an error message about failing to load Firebase.Editor.dll, but it seems you can safely ignore it

What would be the downside of this? Would it be that you can’t add any new firebase packages or does the dependency manager get re-added (and that’s why we need to remove each time?)

kirilogan avatar Apr 30 '20 17:04 kirilogan

What would be the downside of this? Would it be that you can’t add any new firebase packages or does the dependency manager get re-added (and that’s why we need to remove each time?)

You lose all firebase editor-specific functionality, but you can restore the folder when you actually need the functionality, and keep it removed when you don't. I assume you need it for building, resolving dependencies, probably for installing or removing packages too.

Obviously not ideal but I think it's a serviceable workaround for now, until this issue is fixed.

ideka avatar Apr 30 '20 18:04 ideka

Same issue here! When I play a scene, music starts to play but all graphics and the unity editor are frozen for a couple of seconds. I can confirm this happened only after adding Firebase Analytics (Android + iOS) to my project.

Unity 2019.3.10f1, Firebase 6.14.0

brunoschalch avatar May 01 '20 00:05 brunoschalch

Deleting this folder: Library/PackageCache/[email protected]/ExternalDependencyManager does NOT solve the issue. It is a problem with Firebase and not EDM.

The only workaround I was able to figure out is to remove Firebase from the project while I edit it and put it back when I create a new build.

almosr avatar May 01 '20 07:05 almosr

@almosr The workaround I posted definitely solves it for me. Maybe it's two different issues, or our environments are different somehow.

A reminder just in case, Unity restores the folder when you open the project, so you have to delete it when the project is already open.

ideka avatar May 01 '20 08:05 ideka

@ideka When I deleted that aforementioned folder while Unity is open then the issue disappears, because Firebase fails to initialize. Unity keeps throwing various errors, I would rather recommend to remove Firebase from the dependencies, that is a cleaner way to workaround the issue.

almosr avatar May 01 '20 08:05 almosr

@ideka Thanks! I can confirm that this works for me (and yes, it shows the Editor error), but everything else seems to work fine (fireauth, firestore, cloud functions). I can live with this hack for now :D

@almosr I could, but I'm already fairly far along with firebase

kirilogan avatar May 01 '20 16:05 kirilogan

@almosr Removing EDM while working in the project works for me as well. As mentioned above, Unity regenerates the EDM when you open the project and when you open the Package Manager.

If you don't need firebase, then removing firebase is an excellent option. However, I'm assuming that the folks here, like myself, who have this problem need firebase. Removing the EDM when you open the application prevents the slowdown because it prevents the Firebase editor scripts from running, which is where I believe the issue is located. It's not great, but its just a workaround until they fix it.

GorillaOne avatar May 01 '20 22:05 GorillaOne

Not sure if it's already been made explicit or not, but I've been working on the same project in the Windows 10, OS X, and Linux versions of Unity, several different versions, and this only seems to happen on Windows (all 2019 versions I've tried), so you'll have trouble reproing on GLinux or Mac.

My workaround is to locally delete Firebase.Editor.dll and its meta file, and the issue goes away (but I don't commit or it breaks our game in CI builds), but if that dll is anywhere in even an otherwise empty project, things get slow. This has been happening since at least January, and in particular before the migration to the Unity package manager install, so it's not a particularly new change that's caused it.

ewjordan avatar May 02 '20 08:05 ewjordan

For me it's also crippling slow with Unity 2019 and Windows10. However it seems like deleting the editor.dll doesn't bring any noteworthy improvement. Startup times are around 20 seconds and also freezes if I change anything in vs code and come back to unity.

Basically impossible to work like this.

MWFIAE avatar May 02 '20 12:05 MWFIAE

Seems firebase/quickstart-unity#667 is duplicate of this one. The problem seems very straight forward:

  1. GenerateXmlFromGoogleServicesJson class has a [InitializeOnLoad] attribute so Unity will load it and execute its static constructor after each recompile and when entering play mode.
  2. Static constructor will schedule CheckConfiguration() to be called on first next Update,
  3. which will then call UpdateConfigFileDirectory()
  4. which will for every "google-services.json" and "GoogleService-Info.plist" file in project call ReadBundleIds(file)
  5. which will run "generate_xml_from_google_services_json.exe" on Windows and "python generate_xml_from_google_services_json.py" on other platforms and each invocation of that takes more than 5 seconds, keeping the Editor frozen.

Surely Firebase doesn't need to do all this on each load so please just cache it somehow or something so we can continue making games :)

igor84 avatar May 05 '20 17:05 igor84

You can speedup recompile time by removing 'generate_xml_from_google_services_json.py'. After that you will see error message on each recompile. But that's ok. Also you have to restore this file before 'platform build'.

aleksandrdolbilov avatar May 08 '20 11:05 aleksandrdolbilov

You can speedup recompile time by removing 'generate_xml_from_google_services_json.py'.

I've tried that but Unity will restore it pretty quickly in my case.

miv avatar May 08 '20 11:05 miv

I think it restores 'generate_xml_from_google_services_json.py' on Unity restart. Can be solved with simple Unity script which only responsibility is to delete it.

aleksandrdolbilov avatar May 08 '20 11:05 aleksandrdolbilov