xyflow: Bad performance in Svelte 5

Describe the Bug

In our product we’re working with svelte-5, and we’re seeing bad performance for svelte-flow.

*forked from the svelte-flow stress test

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Go to stackblitz
  2. Try to play around with the canvas and you can observe the performance lag when compared to official example

Expected behavior

Performance should be identical.

Screenshots or Videos

No response

Platform

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 18 (7 by maintainers)

Most upvoted comments

@tsdexter It is coming along quite nicely. Hard to tell when the first release will be ready, though. Svelte 5 makes us rethink the architecture quite a bit. We also constantly find things where the solutions is kind of ‘meh’ and some good night sleep and pondering is required. Might be anything of the realm of 2-8 weeks honestly. Also it’s hard to test a lot of things because SvelteKit is not even remotely ready for Svelte 5, neither are any linting tools… In the end it might also be the ecosystem delaying the release.

You can follow along the progress for Svelte 5 in https://github.com/sveltejs/svelte/milestone/9, which might or might not be an accurate representation of work left there.

I was very wrong. I think Svelte 5 is still in alpha.

Alpha is probably too pessimistic (although I understand the sentiment based on the amount of breaking changes that the Svelte team is still landing)

Might be anything of the realm of 2-8 weeks honestly

I was very wrong. I think Svelte 5 is still in alpha.

As the performance issues are fixed now, I will close this issue.

I just checked out the new release, and it appears that version 5.0.0-next.264 fixed all performance issues with the current version of Svelte Flow. These were caused by the immutable option not working correctly.

As Svelte 5 is designed to be backwards compatible, you can start hacking away on your projects with the newest Svelte version right away.

The release came out of the blue for me, and I still have a couple of things on my plate for the next 2 weeks. Will start to port the library immediately after, for a second time… Hoping the migration scripts are fixed until then :fingers_crossed:

Please note that for us this also means moving towards the 1.0.0 release, so we’ll have to work on stabilizing a couple of APIs and improving/rewriting some docs. The most significant change will probably be, that we’ll have to make nodes & edges immutable. No more node.selected = true. It was nice while it lasted 🥲

Well I had mine just inline overwrites in vite config, but there is much better solutions out there. i.e. https://github.com/srav001/katai

I have 2 questions/topic: 1/ Can you remove the warning about Svelte 5 on installing the lib? (I think it’s the peerDeps requirement)

yes, you can for most libs by installing with @next but not this one.

2/ Even if stores are not the flagship of Svelte 5, they are still here! So I think that everything should still work as is. Correct? @adminy did you try to mix runes & node stores for example? Or you are staying on stores for now?

I only run with runes mode. used to polyfill stores, but no more.

BTW, I’m using xyflow in www.remult.dev for the admin part for userland 😉 Very cool stuff, keep going, we love it !

looks awesome!

@moklick I understand that performance with many nodes wouldn’t be great with svelte 5, that’s why I was saying it to be treated like a library. Should be updated not on a frame by frame basis, it has to be interfaced as any other library. The node update functions just exposed and then the loop to be user controlled. If you’re going to handle that in the library itself, you’re just going to have to rewrite bits every time there is a framework update.

We will focus on porting Svelte Flow to Svelte 5 soon, you can read more about our plans for the library here https://svelteflow.dev/whats-new/2024-04-05