Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Editor become very slow when Cinemachine panel is opened

Discussion in 'Cinemachine' started by Necka_, Sep 9, 2018.

  1. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Hello,

    For a long time now (issue persist since Unity 2017.4 until 2018.2 on different projects) I have the whole editor to become very laggy and unusable when Cinemachine panel is opened.

    Let say I navigate through my scene, click on an object here and there: no issue.
    I click on a Virtual Camera, it start to become laggy. In Playmode it's worse, the whole game drop by more than 50% of regular performances.

    Scrolling down the Virtual camera options is very slow too as well as changing options.

    My hierarchy is normally ok, I didn't parent the vcam to the camera:
    upload_2018-9-9_9-30-17.png

    As soon as I click another object that isn't a vcam, performances are fine again

    Any idea what could cause that?

    Cinemachine 2.2.7
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    That's not normal. Can you show your vcam inspector?
     
  3. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Here is one of my vcam but the issue is there on any vcam even a fresh one with no settings other than the default ones
    upload_2018-9-9_10-13-44.png
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Well, that's very strange. I'm not aware of this happening in other projects. Could be some kind of unusual interaction with your content. Can you try it in an empty scene? Do you have any unusual editor extensions?

    Another thing you could try is to bring up the profiler window while the vcam inspector is up. Maybe that will give a clue.
     
  5. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    The profiler clearly shows that something is wrong, but I'll admit I don't have the knowledge to know what to look for here

    upload_2018-9-9_11-2-39.png

    Memory spikes too

    Issue is similar in an empty scene
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Interesting. Do you also get this in a new project?
    Can you tell me something about your project, like if it has Collaborate, or source control, or anything else along those lines?
     
    Last edited: Sep 9, 2018
  7. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    I do not have the issue on a clean project :(

    My project do not have any services active like Collaborate/Source Control or similar, no
     
  8. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    309
    Hey @Necka_ , you have a lot of add-ons to your camera, try disabling them to see if that fixes it and then enable one by one.

    Our guess is that there's some bad combo with one of those add-ons and CM. Let's track that down.
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Also, are you getting any messages on the console?
     
  10. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    In a clean scene I have the same issues @Adam_Myhill but I did disable all those addons and the issue is the same

    upload_2018-9-9_12-10-32.png

    No, no console message at all, no errors or warning whatsoever. Only Cinemachine editor lags which is what is strange to me..
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Not happening in empty project suggests that it's some kind of interaction with other stuff in your project. I would look first at editor-specific add-ons. For example, where do these icons come from?

    upload_2018-9-9_13-54-6.png
    If you start with an empty project and an empty scene with a vcam, and gradually add the 3rd-party stuff from your other project until it gets slow, we can narrow this down.
     
  12. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    This is Hierarchy+ that set icons/colors in Hierarchy. I've had the Cinemachine issue way long before using this asset. I first thought it was a bug on Cinemachine in 2017 and just let it go. But now I'm bothered by it as I'm working on a cinematic with Timeline and Cinemachine and setting the cameras has never been more a choir than today.

    I'll do that, I'll create an empty project and add the assets I'm using one by one and see, I totally believe that it is a conflict somewhere. I'll give my findings later in case you have an idea about it
     
  13. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    I'm sorry I made a wrong statement before regarding since when I've had this issue. It started in Unity 2018 beta. And I remember I did not care because I thought it was just the beta of Cinemachine in 2018+ environement... Because I just checked the old 2017 version of my project and I do not have the issue despite using the same assets.

    I imported assets one by one in 2018.2 on a clean project and could not really pin down where the issue come from.. eventually it became slower and slower, it's just weird. I mostly use 4 major assets: Bolt, Gaia, CTS and Vegetation Studio, The other assets are mostly models and I don't even import demo scenes or their additional scripts.

    I have no idea how to troubleshot that... I mean the profiler shows that something is wrong by just opening the Cinemachine panel and I can make it worse by just scrolling up and down within that panel, there you have huge spikes. I wish the profiler could be more specific on what's going on.

    Edit: I'll now duplicate the project where it's worse and do the opposite, removing assets one by one.. and see what this gives
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Your profiler snapshot shows heavy activity in the vcam inspector's OnEnable(). This is expected on the first call to OnEnable, because it builds a bunch of static data that sticks around. Subsequent calls should skip all that. So 2 things are puzzling me:
    1. Why is the inspector's OnEnable() being called multiple times while the inspector is up?
    2. Why is the OnEnable() re-doing the heavy work that should only be done once?
    One possibility is that you're showing me the very first heavy frame in the snapshot. Can you show me a heavy frame in the middle, so we can perhaps rule out the things that are puzzling me?
     
  15. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    I'm not super used to the Profiler I'm sorry, I recorded for a few seconds the editor. All I did in those few seconds is to scroll up and down multiple time in my Vcam panel. You can see all the spikes on the CPU profiler which are basically the scrolling, and I screenshoted 2 of those spikes

    I also exported the Binary, I have no idea if you can grab anything from that file though : https://1drv.ms/u/s!AtS-IyFcKodrhpNtTawocPs5FQ8LaQ

    As the image are quite long (took a scrolling screenshot) I've put them on Imgur in case it doesn't show up properly here

    https://imgur.com/a/s2Q8fLd

    If you need anything else of course I'll provide

    thank you for trying to solve that with me, I appreciate the support
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    I tried it in 2018.2.5f1 and there is no problem at all with the vcam inspector:

    upload_2018-9-10_16-0-24.png

    I'm pretty sure it's some combination of things in your project. If you can isolate it that would help a lot.

    Here is something you can try. In the latest CM (2.2.8 - available in preview on the staging repository) we made some optimizations to how the CM vcam inspector searches for class definitions. Can you try that in your project, just as an experiment? If it lessens the problem then that would be a clue.
     
  17. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Sure, can you just point me to where I can find how to install CM in preview mode? I can't find it in the package manager, I believe it's another way of getting it?
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    With a text editor edit your project's Packages/manifest.json file and add this line:
    "registry": "https://staging-packages.unity.com",
    immediately before the "dependencies" line. Then open Package Manager, and you will see the experimental and unpublished content in addition to full-fledged releases. Use at your own risk.
     
    Necka_ likes this.
  19. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Well... I don't know what to do anymore. the preview package doesn't change anything
    I tried on my duplicated project to remove one asset after the other and I just noticed that it became "smoother" and "smoother" over time and now in project now empty the performance looks good. So it's not like one specific asset is creating the issue.
    It wasn't like that in 2017 which is strange to me.

    The thing is obvious and make the vCams hard to config in play mode where it's the worst possible. Game is running around 60fps in play mode, I click on the vCam and it drops at 15-20fps making it almost impossible to change a value and see the result. Combined with Timeline tunning for a cinematic and it's just horrible.

    I could give you access to a duplicated project via Collaborate (I have one seat left for Teams) but I'm not sure it's "legal" to do so and I think you also have better things to do.

    I was checking to go back to Unity 2017 but Cinemachine doesn't have Impulse mode and I think some camera settings I'm using now do not exist back there.

    Damn it..
     
  20. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    I would like to take a closer look at this, it's very strange and we need to find out what's going on. I'll have a little time next week to devote to it.

    In the meantime, you can indeed use the latest Cinemachine with 2017. Just copy the folder from the package manager cache and paste it into your 2017 project assets.
     
  21. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Going back to 2017 with my current project I'm not sure if I want to try the downgrade here.. worse case if we can't figure out the issue I will.

    But wait, get this: it's a long shot but I narrowed down some part of the issue I think.

    I was wondering why on my duplicated project with no more assets or else, I was still having this performance issue compared to a blank project.

    The difference are the project settings. My project is set on Deferred/Linear and Net 4.X. A new project is on Net 3.5 gamma and Forward rendering.

    Linear/Gamma doesn't change a thing. I don't think Deferred does either.

    But Between Net 3 and Net 4 on a blank project, damn yes there is a difference.

    As the simplest test:

    Add a cube
    Add a freelook camera
    Set follow/look to the cube
    Go in game view with the windows guide set click on the Cinemachine yellow box in the middle and drag it around: smooth

    Now switch the project to Net 4.X and restart

    Move the yellow dot in the same way: Not smooth at all, lots of hiccups

    When I moved to Unity 2018.1 (and .2 later) I also switched to Net 4.X because I needed some features from two assets that were available only with Net 4. That's maybe why I noticed the Cinemachine straight away and thought it was because of Unity version.

    Here is a video showing the issue:


    The first part is to show in my full project how bad it is. I know the video recording adds up, but you can clearly see that it's just a mess of hiccups.

    The second part is a new project in Net 3.5: No issue at all

    The third part is also a new project but in Net 4: hiccups

    I hope that helps and that give you some hints
     
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Oh yes that's a big help. Thank you for tracking that down! I'll keep you posted with our progress on this (won't be before next week, though).
     
    Last edited: Sep 11, 2018
  23. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Ok, thank you. I'll wait for your findings
     
  24. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    So, a small update just to give as much info as I can find:

    I decided to create a blank Unity 2017 project and imported from scratch all the assets I use/will use into it (so it's stuffed)

    I then imported Cinemachine from the store (v 2.1.10 I believe as it is prior to Unity 2018 version)

    -Created a vCam: super mega smooth. really great.
    -Deleted Cinemachine 2.1.10

    -Imported Cinemachine 2.2.7 copied from the package manager cache folder
    -Created a vCam: Super slow. Huge spikes in the profiler every time I scroll in the inspector panel and so on.

    So of course I don't know what changed deeply in Cinemachine core between 2.1 and 2.2, but clearly I have a black and white example with those two version

    I tried to switch the project between .Net3 and .Net4. While I have improvement in .Net3 (like 25% less slowdown) the root issue is elsewhere.
     
  25. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Can you zip up and send me that project?
     
  26. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    I doubt it, it's too big with the assets even without the library folder included.

    I could do a collaboration access, I have one seat free for Teams so you can just get it from the cloud
     
  27. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    Ok that became weirder than ever but at least it looks fixed so far with my extensive tests.

    (All this in 2018.2.6f1)

    -To try to pin point the CM version that cause the issue I deleted CM completely
    -Re-Installed directly CM 2.2.7: Same issue
    -Deleted again completely CM
    -Install from Package manager to CM 2.1.13: No issue
    -Upgrade to 2.2.7: Same issue
    -Downgrade from 2.2.7 to 2.1.13 via Package Manager: No issue
    -Upgrade to 2.2.0 - Preview 1: No issue
    -Upgrade through 2.2.0 Preview 1 to Preview 8 and then Final: No issue
    -Upgrade from 2.2.0 to 2.2.7: No issue
    -Deleted Cinemachine and Reinstalled 2.2.7: No issue
    -Restarted Unity to check sustainability: Sutainable. No issue

    So I have absolutely no idea if you can make anything from that.

    I've never ever had Cinemachine to be smooth in Unity 2018+ and now it works with the tests I've just made.

    I'm super happy but at the same time it feels strange the way it got fixed... it doesn't make any sense to me right now

    Here are the issues that I was having and are now inexistant:
    • Scrolling the inspector panel of a vCam caused major hiccups/slowdown
    • Moving the dead zone, Screen Y/X, changing values in the inspector in Editor mode cause major hiccups/slowdown
    • Same as above but in Play Mode
    • Getting 50% FPS drop by just having a vCam inspector opened in Play mode
    I hope you can figure something out of this, but honestly in the wose case if it happens again I'll just do the downgrade/upgrade process again (and maybe be able to pin point even more)

    I'll try now to upgrade to .Net4 this project as I need it for some of my scripts but it's like I don't really care anymore, I just got back the Cinemachine I've had like it was 6 monts ago
     
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,533
    Thank you so much for your investigation work and detailed reporting. It's very helpful. I'm traveling this week so haven't been able to devote time to it, but will be sure to look into it next week when I'm back. Thanks again for your patience and your help.
     
    Necka_ likes this.
  29. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    It's absolutely no problem, actually discussing the issue with you even without finding clear problem source gave me ideas on how to troubleshoot and I now have a work-around that is stable and I can work with Cinemachine in my project again, so I'm quite happy :)
     
  30. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    216
    An update: After upgrading to Unity 2018.2.8 (from .6) the issue came back.

    I did again downgrade CM to 2.1.3 -> 2.2 -> 2.2.7 and it fixed the problem again
     
  31. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    722
    Hey @Gregoryl since updating to 2.2 I'm getting some serious lag when ongui gets called in various cinemachine inspectors. Hopefully I can help shed some light on what's going on. It seems to be happening when the inspector expects to find some kind of asset when one doesn't actually exist.

    For example profiling the virtual camera I can see that onGUi takes 148ms calling CinemachineLensPresets.get_InstanceIfExists(). Currenly this project has no lens presets asset but once I create one the inspector behaves as normal.

    A similar thing occurs with the Impulse Listener inspector only with the CinemachineImpulseChannels asset instead
     
  32. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    722
    Dug a tad into the source code and it is indeed the CinemachineLensPresets InstanceIfExists (and I imagine other funcitons like it) causing the problem. Adding in a boolean for "alreadySearched" prevents it from checking the asset database every frame in vain.
    Code (CSharp):
    1.         private static bool alreadySearched = false;
    2.  
    3.         /// <summary>Get the singleton instance of this object, or null if it doesn't exist</summary>
    4.         public static CinemachineLensPresets InstanceIfExists
    5.         {
    6.             get
    7.             {
    8.                 if (sInstance == null && !alreadySearched)
    9.                 {
    10.                     var guids = AssetDatabase.FindAssets("t:CinemachineLensPresets");
    11.                     for (int i = 0; i < guids.Length && sInstance == null; ++i)
    12.                         sInstance = AssetDatabase.LoadAssetAtPath<CinemachineLensPresets>(
    13.                             AssetDatabase.GUIDToAssetPath(guids[i]));
    14.                     alreadySearched = true;
    15.                 }
    16.                 return sInstance;
    17.             }
    18.         }
    Edit: seems the only other affected file is CinemachineImpulseChannel.cs