-
Notifications
You must be signed in to change notification settings - Fork 131
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
Move layout functions to Web Worker for pixi.js examples #20
Comments
Very interesting! Do you have an example to share? |
Yes. Actually I tweaked it some more and it's up to 100 layout cycles per Thank you so much for your work on this. The modularity and speed are a I'm very excited about the potential of ngraph plus pixi!
|
Here's the example: |
Thanks for the demo! I forked you repository and extracted web worker code into plain javascript file to compare FPS of the two approaches. To get accurate FPS measures I'm using built-in tool inside Chrome: Dev tools -> then press ESC key to bring up a drawer from the bottom and -> Click Rendering tab and select "Show FPS meter": https://anvaka.github.io/pixi-ngraph/index.html - this is unmodified version with layout inside web workers I couldn't see much difference between them, but maybe I'm missing something. Do you get better results on your end? |
Thanks for putting those comparisons together. Yes I see a huge difference! In the second example, it takes a full minute for the layout to fully resolve (1000 cycles). In the first example it takes less than 8 seconds! In both cases the FPS will be about the same because that's just measuring the render cycles. The problem I'm trying to solve is that I want my users to be able to see (and start interacting with) the final layout a lot more quickly. I don't want them waiting a full minute for it to get to that point while they watch things slowly laying out. |
Fwiw the layout with web workers is much smoother and seems faster on iPhone safari --S
|
Thanks Steven. I hadn't thought to try it on mobile. FWIW I just tried on my old HTC and it renders at around 4fps, but lays out at around 20 loops per second. It's not fast by any measure, but the difference between the 2 methods is accentuated. |
Ah, thanks for the clarification. I see a lot of value in your use case. I'm going to create a force layout wrapper to perform computation in the web worker if possible. PS: Regarding
I was trying to optimize FPS, not number of iterations, when I made this experiment 6 months ago. But your idea makes much more sense! |
Thanks Andrei. |
https://github.com/anvaka/ngraph.asyncforce here is a first draft. Please take a look. Not sure if I like the API... |
This looks great. I like that you've included ways to communicate pinning and other options across to the layout worker. One thing I don't really understand is why you are calling layout.step(); within the render loop. Why is this necessary? Can the layout not just keep looping of its own accord? Thanks for all your work on this. |
There are couple reasons:
If you don't like this behavior but prefer to compute N iterations of layout, you can tweak |
I saw you mentioned in another issue that you were planning to move some functions to web workers in one of the other threads. This seems especially important for the pixi.js examples where layout is currently being done in the render loop.
I don't know if you've tried this yet, but I did a quick test of putting the layout function in a web worker. I don't have any performance comparisons, but I'm doing some more graphically intensive stuff in Pixi.js so I'm getting about 18 fps on the render loop. The layout loop on the worker is running at around 40fps. This ensures a much quicker (and consistent) layout resolution time while still keeping a reasonably smooth graphics performance. Its working well enough that I thought it was worth posting an issue here. I can extract and share the relevant code if that's helpful.
The text was updated successfully, but these errors were encountered: