After zooming the canvas, it keeps redrawing every frame, causing severe lags.

NodeCanvas Forums Support After zooming the canvas, it keeps redrawing every frame, causing severe lags.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #16895

    I examined the memory leakage in the editor, and found unusual NodeCanvas behavior.

    After a canvas has been zoomed in or out, if you don’t do anything else with it, it keeps redrawing the canvas after zoom animation is done, even while idle, causing heavy CPU and RAM consumption, and severe lags.

    If you do any other action after that, for example, move the canvas with the middle mouse button, it calms down.

    See attached profiler screenshots. IMG1: normal state. IMG2: zoom in or out was done using mouse wheel, it stays in this state. After moving canvas with MMB, it returns to IMG1 state.

    This can be reproduced in an empty project by importing the plugin, opening a canvas and repeating the steps.

    In a project with a large number of nodes and connection, this effect becomes much worse. Depending on the system, sometimes quickly leading to unresponsiveness of Unity Editor or even the whole OS.

    It also seems that some memory leakage from being in this state accumulates over time, even if you move the canvas to fix it.

    Unity 2020.3.18f1 DX11 Windows11

    NodeCanvas 3.26

    You must be logged in to view attached files.


    – This does not occur after you tried to zoom in or out past the zoom limits.
    – If you close the canvas while it is in a state of constant redrawing, it returns to this buggy state the next time the same dialogue tree is open.
    FlowCanvas 3.26 ALSO AFFECTED


    I pinned it down to UpdateSmoothPan in CanvasCore\Framework\Design\Editor\Windows\GraphEditor.cs

    line 387: ( targetPan – pan ).magnitude < 0.1f never becomes true after zoom, causing continuous Repaint()

    Still haven’t figured out what’s wrong with the math, but I was able to tame it, changing the value to ( targetPan – pan ).magnitude < 1.5f
    But now I am somewhat concerned that is was basically the Repaint() loop that caused such significant issues, as it means that some symptoms can continue to occur simply by working with a canvas for the long enough time, but I have no idea where to look further.




    I can confirm your findings. Repaint is called far more than it should because the pan is never reaching target pan, even though Repaint in the update should only be called for a few frames (while smoothly zooming/panning only). The problematic line of code is #386. It is no longer needed (it used to be), so I removed it. Please remove that line as well so that Repaint stops being called in update more than it should.

    Thank you for letting me know of your findings!

    Join us on Discord:

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.