Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU usage still high even with paused animations or disabled event listeners #169

Closed
bashovski opened this issue Feb 5, 2021 · 1 comment

Comments

@bashovski
Copy link

Describe the bug

Hello, again. So basically, we are experiencing high CPU usage even with a low amount of nodes/edges in the graph.
The graph is unloaded by clearing the graph data:

        this.graphInstance.pauseAnimation();
        this.graphInstance.graphData({
          nodes : [],
          links : []
        });

I've tried resuming the animation and populating the data once a graph should be reloaded, but the result is the same.
We are also requiring the graph to emit those events:

onBackgroundClick
onNodeClick
onLinkClick

We have also applied custom link curvature and we also apply custom canvas objects where needed (only 5-10 have a canvas object which is a basic non-solid text).

Expected behavior
Basically, the graph shouldn't cause high CPU usage since it shouldn't be doing anything unless user interacts with it.

Screenshots
An example of how the graph implementation looks like:
force-graph loading 113 nodes 809 links
image

Here's the performance monitor (avg. CPU usage without having the graph opened is between 2.5 and 5%):
image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version Version 88.0.4324.150 (Official Build) (x86_64)

(also happens on other browsers)

Additional context
I've also posted another issue last year which could be related to this one: issue

Looking forward to hearing from you!

@vasturiano
Copy link
Owner

@bashovski thanks for your report.

I've added some performance improvements to the rendering cycle that automatically pauses redraws when the force simulation engine is halted. This should bring the cpu usage of the module to a minimum after the cooldown phase.
The default cooldown phase lasts for 15s, if that is too long for your case you can reduce this period via either cooldownTime or cooldownTicks.

Keep in mind the redrawing is only paused if there's no need to visual changes needed in the canvas. For cases which the canvas needs updating, for instance when there are directional particle animations, the redrawing remains active.

It's also possible to bypass this automation altogether, for some custom cases which require continuous redrawing of the canvas, like so:

myGraph.autoPauseRedraw(false)

Let me know if you observe an improvement with this new functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants