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

Poor performance when 50 nodes get rendered on the graph #40

Open
yinfeiru opened this issue Apr 9, 2020 · 4 comments
Open

Poor performance when 50 nodes get rendered on the graph #40

yinfeiru opened this issue Apr 9, 2020 · 4 comments

Comments

@yinfeiru
Copy link

yinfeiru commented Apr 9, 2020

Hi there,

Thanks for writing this library. It saved me a lot of time!

I added this lib to our code recently and I'm seeing really poor performance when I have more than 50 nodes on the graph. After some profiling, I found out that the browser spent tons of time on doing https://github.com/kaluginserg/cytoscape-node-html-label/blob/master/src/cytoscape-node-html-label.ts#L311 . I'm wondering if we can do things like debounce to bump the performance up.

I know do you probably did it on purpose. But can you explain why you put a setTimeout here?

@bebeun
Copy link

bebeun commented Apr 15, 2020

Thank U again for this wonderful library which is very helpful !

Nevertheless, I have the same problem. Graph with about 100 nodes gets very slow.

Any idea ?

@josejulio
Copy link
Collaborator

I added this lib to our code recently and I'm seeing really poor performance when I have more than 50 nodes on the graph. After some profiling, I found out that the browser spent tons of time on doing https://github.com/kaluginserg/cytoscape-node-html-label/blob/master/src/cytoscape-node-html-label.ts#L311 . I'm wondering if we can do things like debounce to bump the performance up.

Maybe or set some kind of cache to avoid recomputing it all the time?

@josejulio
Copy link
Collaborator

That function gets called for the element every time there is a style or data update on the element. Do you make such changes by code? If so maybe you could use the batching function to https://js.cytoscape.org/#cy.batch

But yes, maybe a debounce function could help there, PRs are welcome.

@gamespark
Copy link

gamespark commented Oct 29, 2021

Yes, According to the source code in this lib: '_cy.on("style", updateDataOrStyleCyHandler);', 'style' event caused this issue, it always refresh html nodes by this event, if too many nodes, there will be performance issue.
I also tried to listen 'style' event before this lib register, and call event.preventDefault() to stop this event, but not work, event still flow to the listener of this lib.
But I find event.isPreventDegault() changed to false if event.preventDefault() called.
So you can fork and edit the source code to add logic to check if event.isPreventDegault() === true, then just return from func 'updateDataOrStyleCyHandler'
Or add a new parameter like 'notListenStyleEvent' to do this.

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

4 participants