Forum rules - please read before posting.

Editor performance drop after update

2»

Comments

  • edited February 2021

    While I was experiencing similar slowdown on my end, it went away upon disabling icons. The problem now is that I can't reproduce such behaviour.

    The infrequent spikes may just be a part of Unity's own behaviour. You're getting them even with the old version.

    Comparing your last two screenshots, it looks like Anima2D may not be contributing so much - what other packages did you delete?

    See my post above - it's possible to profile the Editor via the top-left of the Profiler window, which may help pin down the source. Try out the code removal suggestion, too.

  • edited February 2021

    Anima2D is contributing a lot! But only when paired with the new version of AC, that's what is so strange. I don't mind the spikes if they don't go past the 60FPS mark - they still allow me to test things in the editor, and there is no such issue in the actual build.

    If you look at the spikes before the update, the highest peaks stay at around 60fps and don't get worse. After the update, the spikes start out OK, but after 30 seconds (which is when I took the screenshot), the peaks go past 15FPS. Give it about 3 minutes, and the game pretty much freezes. If I delete anima2D, then I'm back to having 60FPS peaks which don't get worse, which is enough for my purposes.

    For the last screenshot, I deleted all of my custom scripts, Dialogue System, Amplify Color, and a couple of others. But I don't need that performance gain in the editor, I just need to stop the AC+Anima2D combination from freezing the game in 3 minutes.

    I will try profiling the Editor and let you know.

  • edited February 2021

    OK, so I profiled the editor. This screenshot was taken when the game had become unplayable (0 FPS). The low activity in the timeline happened when I paused the game, and the high activity when I unpaused it.

    Edit: Could AdventureCreator.Paint be causing the Anima2D editor stuff to go haywire?

  • edited February 2021

    Note that when I first start the scene, Application.UpdateScene is taking most of the resources (and FPS is quite low, but the game is still responding):

    After about 1 minute, HierarchyWindow.Tick has climbed fast and is on its way to overtaking Application.UpdateScene, but it is still falling just short of grinding the game to a halt:

    And then after a couple more minutes, you get a situation like in my previous post, where HierarchyWindow.Tick is out of control and the game no longer responds.

    Edit: commenting out the SceneView.RepaintAll (); statement in SceneManager.cs doesn't seem to make a difference that I can see, sadly.

  • edited February 2021

    OK, so I found the anima2D culprit. I went through the files looking for references to "FindComponentsOfType" and just commented them out of all the files I could find:

            static void HierarchyChanged()
            {
                // s_SpriteMeshInstances = EditorExtra.FindComponentsOfType<SpriteMeshInstance>().ToList();
            }
    
            static void HierarchyChanged()
            {
                //s_Ik2Ds = EditorExtra.FindComponentsOfType<Ik2D>().ToList();
                //s_Bones = EditorExtra.FindComponentsOfType<Bone2D>().ToList();
                //s_Controls = EditorExtra.FindComponentsOfType<Control>().ToList();
            }
    
            static void HierarchyChanged()
            {
                //s_Bones = EditorExtra.FindComponentsOfType<Bone2D>().ToList();
                //s_Controls = EditorExtra.FindComponentsOfType<Control>().ToList();
    
                SceneView.RepaintAll();
            }
    

    This breaks anima2D though, so we need to figure out why AC is interfering with it?

    Edit: I also tried simply commenting out SceneView.RepaintAll(); from the Anima2d code above, and the slowdown did take longer to occur, but after a while the game still became unplayable.

  • Thanks for the analysis, it's much appreciated.

    It looks like it's a case of Unity's OnHierarchyChange event being called, which in turn is causing heavy Anima2D to run, resulting in the slowdown.

    Where and how this event is being called I'm not certain, but I'll investigate. I'm assuming this is all still with AC's hierarchy icons disabled.

    If you're still up for some sleuthing, it'll help to know the result of having your Anima2D object(s) in a bare-bones AC scene, i.e. one with no ActionLists etc, as well as with the AC Game Editor window closed while running.

  • edited February 2021
    Thanks, Chris. Yes, the AC hierarchy icons are disabled. One thing I need to point out is that I tested this in a scene that didn't have any Anima2D objects, and the issue still occurred.

    In fact, when I run a different scene that does contain Anima2D objects with the sections above commented out, the animations themselves still work in-game. Commenting out those lines only appears to break Anima2D inasmuch as I become unable to edit the bones, etc when the game is not running.

    I'll give your suggestions a try tonight.
  • One thing I need to point out is that I tested this in a scene that didn't have any Anima2D objects, and the issue still occurred.

    What was the state of the Overview section of the Profiler in that scenario?

    If this too is down to the HierarchyChanged event, these two pages on the Unity wiki have example scripts to show how many times this event is being triggered (though unfortunately not how):

    https://docs.unity3d.com/ScriptReference/EditorWindow.OnHierarchyChange.html
    https://docs.unity3d.com/ScriptReference/EditorApplication-hierarchyChanged.html

  • edited February 2021

    OK, so I used the scripts above, and I made more discoveries, but I'm really at a loss here.

    First of all, after turning the AC hierarchy icons off, the 2D Demo scene does seem to work fine. I could swear it wasn't working before, but it seems to be working smoothly now. I used the script above to watch Hierarchy and Inspector access, and once I got the game running, the counter wouldn't go up in any significant way, meaning GameObjects were not being changed, added or deleted.

    But my game's scenes are still very bad, and indeed, the counter is going up by 6 per second on average. The curious thing here is that I also added the script to my project before the AC update, and the counter still went up like crazy, and yet the editor performance was fine. Those Anima2D lines were not causing the trouble they are now causing after updating AC.

    The good news is that I've finally tracked down what is triggering the HierarchyChanged event. The bad news is that I have no idea how to fix it.

    I use a colour grading tool called Amplify Color. The best thing about it is that it allows me to mask the colour grading I'm applying to a scene, so I can come up with some really cool effects - for instance, I can apply a really dark shade to the scene to simulate night time, and then use semi-transparent sprites where the effect isn't applied to simulate lamps, bright windows, torches, etc. Basically, it will take all those sprites into account to create a dynamic mask texture, which determines where and how strongly the colour grading effect will be applied on the screen.

    This is a scene without colour grading:

    And this is the same scene with the masked colour grading applied:

    It does this by having a second camera with a Target Texture called AmplifyColorMaskTexture, and this camera is referenced on the Amplify Color Render Mask component I've attached to AC's main camera.

    The render mask component's void Update() function calls UpdateCameraProperties():

    void UpdateCameraProperties()
    {
        maskCamera.CopyFrom( camera );
        maskCamera.targetTexture = maskTexture;
        maskCamera.clearFlags = CameraClearFlags.Nothing;
        maskCamera.renderingPath = RenderingPath.VertexLit;
        maskCamera.pixelRect = new Rect( 0, 0, width, height );
        maskCamera.depthTextureMode = DepthTextureMode.None;
        #if UNITY_5_6_OR_NEWER
            maskCamera.allowHDR = false;
        #else
            maskCamera.hdr = false;
        #endif
        maskCamera.enabled = false;
    }
    

    The very first line, the CopyFrom method, is the source of all HierarchyChanged events. If I comment it out, the counter doesn't go up anymore (and the FPS issues are fixed). The problem is that then the texture mask starts following the main camera instead of being properly applied to the objects in the scene:

    But now I don't know what to do. Despite the flood of HierarchyChanged events, this did not cause a slowdown before the latest AC update. Do you have any idea how I could stop the CopyFrom method from doing this, and why AC could be reacting badly to this (and causing Anima2D to go bonkers!)?

  • It's hard to say where AC lies in all this - it's a custom script that triggers HierarchyChanged, and its Anima2D that reacts to this causing slowdown.

    You mentioned earlier that even removing the Anima2D HierarchyEvent reactions caused slowdown. What does the Profiler reveal in terms of any other sources of slowdown once Anima2D is discounted?

    Camera.CopyFrom is really just shorthand for a long list of statements to copy over transform / FOV etc values from one camera to another. You could try replacing it with statements to only copy the exact data you want.

  • edited February 2021

    Re: Amplify Color, I fixed the flood of Hierarchy Changes events. The problem was that maskCamera was an actual camera in the hierarchy, and when CopyFrom copied all the values from AC's Main Camera to it, it triggered an event. So I unassigned the camera and added this to the script's void OnEnable():

            if (maskCamera == null)
            {
                var go = new GameObject("Mask Camera", typeof(Camera)) { hideFlags = HideFlags.HideAndDontSave };
                go.transform.parent = gameObject.transform;
                maskCamera = go.GetComponent<Camera>();
            }
    

    Seems to do the trick!

    Now everything runs smoothly for the most part, except for a spike/stutter whenever HierarchyChanged is triggered. This seems to happen, for example, when asset-based actionlists are triggered? The number of GameObjects visible in the hierarchy goes up by one, then goes down by one. But I think this behaviour is expected/desirable, it's just the spike itself that is the problem, and not the triggering of HierarchyChanged.

    But yeah, I still have no idea what about AC is making the Anima2D updates so costly. Before the AC update, the profiler hardly ever mentioned the Anima2D processes at all if you sorted them by "Time ms". They were never an issue (so much so that until now I hadn't even realised Amplify Color was triggering so many Hierarchy Changes events).

    This is a spike that happens when a simple asset-based actionlist is triggered:

    Anima2D is responsible for 93.1% of the load. And yet it wasn't before. I'm stumped, lol.

  • edited February 2021

    If this helps at all, the incredibly high Anima2D activity always happens at the same time as the Adventure Creator paint/repaint:

  • edited February 2021

    That's not an internal AC function. If I had to guess, I'd say that's Unity's own call to draw the AC Game Editor window. Is there a difference based on which Manager tab is open?

    When ActionList assets are run, a RuntimeActionList object is spawned in the scene to run it. This can be avoided, however, by using Cutscenes that reference the asset by setting it's Actions Source to Asset File - though that's not always practical for all situations.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.