question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance drop when panning or zooming

See original GitHub issue

We have a graph with over 600 elements and when panning and/or zooming there seems to be performance drop and the movement gets laggy. This can also be experienced in https://reactflow.dev/examples/stress example after randomizing positions and panning around - especially when nodes get outside of visible area.

After some investigation it seems that in case nodes getting outside/inside of visible area the internal state nodes (useStoreState(store => store.nodes) change - which can be improved by setting onlyRenderVisibleElements={false} prop on ReactFlow component (which removes some of the lags for our case).

But there is also re-render of Edge due to transform prop change, however I am not sure that this is the main cause of the issue.

I wonder if changing transform should automatically trigger re-render of Edge, especially when re-render of Nodes is not triggered in such case.

Thank you.

PS: the library is great, thanks for your hard work, BTW 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
moklickcommented, Mar 15, 2021

Hey @Xalsar

react-flow is not made for flows with more than 1000+ nodes. I am not sure if a DOM based renderer can satisfy your requirements here. I would check out a canvas based solution in your case.

2reactions
moklickcommented, Mar 5, 2021

Hey @wladimiiir

since react flow is DOM based we have some limitations. I would say that ~1000 nodes is the limit depending on the complexity of the nodes.

The onlyRenderVisibleElements was supposed to speed up the flows but at the moment it does the opposite 😦 When nodes reenter the view they have to be expensively reinitialized. The Edge component needs the current transform value only to check if it’s inside the viewport (when onlyRenderVisibleElements=true)… So for nodes and edges onlyRenderVisibleElements=true is actually bad right now.

I am aware of this and I will try to improve this over the next weeks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poor performance when zooming or panning in AutoCAD
When zooming or panning a drawing in AutoCAD, the movement is slow, stutters, jumps, or is otherwise not smooth and fluid.
Read more >
Zoomed panning extremely slow / choppy moving arou...
Since I updated to 22.3, panning around and especially zooming has a severe lag attached to it; it sometimes takes multiple seconds to...
Read more >
Proposals/Performance in panning & zooming - SVG
We examined the performance of transformation in panning & zooming with "3d transform" such as ... However, there would still remain issues for...
Read more >
FPS drop while camera zoom pan with object count 10k with ...
there is a significant drop in FPS (it gets to 30-35 fps) while continuous zoom and pan. Any workaround for the same and...
Read more >
Sudden fps drop when pan and move the camera.
... I try to pan or zoom the view inside the cockpit or outside the airplane (below 20fps) I am not struggling for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found