Editor Perf - NetworkManagerHelper.EditorApplication_hierarchyChanged
Description
I'm experiencing some serious slow downs in the editor from the following:
EditorApplication.hierarchyChanged: Unity.Netcode.Editor.NetworkManagerHelper.EditorApplication_hierarchyChanged
I'm seeing on the order of 100ms per frame or more on this call in the editor profiler.
I dug in a bit and it looks like maybe this is the source of perf issues as I have a lot of game objects in my scene? Library\PackageCache\[email protected]\Editor\NetworkManagerHelper.cs Line 113: var allNetworkManagers = Resources.FindObjectsOfTypeAll<NetworkManager>();
Reproduce Steps
- Create or open a unity project with 100K+ game objects in the scene and a NetworkManager in the scene.
- Create a script in your scene that causes EditorApplication.hierarchyChanged to get fired each frame.
- Play the game in editor with the editor profiler enabled.
Actual Outcome
Observe that Unity.Netcode.Editor.NetworkManagerHelper.EditorApplication_hierarchyChanged is taking a very long time, and the vast majority of the frame and editor loop time.
Expected Outcome
Unity.Netcode.Editor.NetworkManagerHelper.EditorApplication_hierarchyChanged would have have negligible impact on editor perf.
Environment
- OS Windows 10 [Specs: Intel i7 @ 3.6GHz, 32 GB RAM, 2080 Ti RTX]
- Netcode Version: [e.g. 1.0.0-pre.6]
- Netcode for GameObjects Version: 1.5.1
- Unity Editor version: 2022.3.4f1
Additional Context
As a workaround to the perf, I tried finding the root cause of EditorApplication.hierarchyChanged getting called every frame, but haven't been able to efficiently debug or identify the cause for that getting invoked yet. Regardless, I would not expect NetworkManagerHelper to have the negative impact on perf that we are seeing.
Hi, just wanted to confirm that I'm encountering this issue as well in a small test scene with less than a hundred gameobjects (including non NetworkObjects). In the screenshot (ignore highlighted) you can see the function takes 59ms.
Windows Version: Windows 11 Build 22H2 Unity Version: 2022.3.20f1 Netcode for Game Objects: 1.8.1
I'm having the same issue. A lot of fps drops. Would be great at least being able to disable this feature.
I'm having this issue too, everytime I activate, deactive, instantiate or destory a gameobject, the fps drops, the more gameobjects on the scene, the more the fps drops, even without initiating anything related to the netcode.
I tried to reproduce this in different scenes, in an empty scene with only a camera and an empty GameObject I experienced a 2%-5% fps drops, in a scene with around 50 GameObjects (all being UI GameObjects) i experienced around 30% fps drops, and in a scene with around 200 GameObjects i experienced around 70% fps drop.
I'm using a Ryzen 5 1600, 16GB of RAM, Radeon RX 580. OS Windows 10 Pro 22H2 Unity Version 2022.3.17f1 NGO Version: 1.8.1 - 1.8.0 - 1.7.1 (haven't tried older versions)
I believe @NoelStephensUnity is already aware of this. Let's hope we can get an update ASAP. Without this, I have like more 15FPS, which make my game run at 20~25fps instead of 5 in the editor.