retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

transformer is called way to often which makes large rete networks unusable slowly #586

Closed pokecheater closed 1 year ago

pokecheater commented 2 years ago

Hey Retejs Team,

thx for your great work :).

I stumbled recently over an problem with the rete js designer. I have a network of retejs nodes which is has 207 connections and the most of them go from one to the next node directly. I have a node which summarize all those nodes but has the possibility to unfold it (which basicly extract the inner network into the outer). For this I create nodes and connect them. All these steps happens in a reasobable time but afterwards during the render process everything gets stucked for a long while. When the ui comes back to life any tiny change on the connections or node positions retrigger this behaviour.

I was able to identify that my connection path plugin transformer is called way to often (in my opinion). I have written a console log inside this function ( see screen shot 1) and now my js debugger tells me that it is called >38.000 times (screen shot 2) (note that this count still increases while i write this xD). A

So I tried to set up a simple network with 2 nodes and one connection. And even here on each change this method is called 20 times (screenshot 3). (please note that I

Screenshot 1

Bildschirmfoto 2022-09-14 um 14 01 39

Screenshot 2

Bildschirmfoto 2022-09-14 um 14 06 07

Screenshot 3

Bildschirmfoto 2022-09-14 um 14 11 22

Can you help me out with this issue? Do you have any information on that?

Greetz

pokecheater commented 2 years ago

Hey I cloned your repository and was able to fix my issue with a custom build:

When I looked into the console.trace() I noticed that requestAnimationFrame was mentioned inside.

So I just commented out the the rendersocket event inside the index.ts and made a custom build. After that my renderning process works as a charm :). No more thousands of rendering processes.

Bildschirmfoto 2022-09-15 um 16 48 13

I am not sure why for each related connection the view.update function is triggered again which results for each connection to be recalcualted and redrawn. But everything still works fine.

Hope this helps anyone else out there :).

barnesew commented 2 years ago

In case it helps, I believe this might be related to v1.4.9. I also utilize rete in an application with hundreds of connections and noticed a significant performance impact when we upgraded from v1.4.8 to v1.4.9. I believe something about the deferred connection rendering that was recently introduced is causing the "Animation Frame Fired" event to be called repeatedly. Below is the call tree after I selected one of the nodes on the screen (v1.4.9).

Screen Shot 2022-10-04 at 11 26 33 AM

Ni55aN commented 1 year ago

@pokecheater @barnesew this issue has been fixed in v1.5.0 (also update vue or react render plugin to the latest version)

rete-js[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.