Getting Aurelia up to speed for <canvas> animation

I wanted to check if Aurelia doesn’t ‘get in your way’ when speed is needed. Conclusion: it doesn’t :slight_smile:
Here http://ashware.nl/fast-life/ I’ve built a Cellular Automata playground which became quite fast. I’m delegating the heavy computing - evaluating thousands of cells many times per second - to a web-worker to keep the application being responsive.

3 Likes

Oh great.
You polished it a lot… since last time (-:

Might I ask you to write a short story about your journey?
what were the roadblocks.
A-ha moments…
It is very valuable

1 Like

Thank you @Alexander-Taran,

It started when I was building this pentomino puzzle with solver in Aurelia a couple of months ago.
The recursion/backtracking solver service I’d written was so busy calculating solutions that Aurelia did not get time to update the DOM with the solutions found by it. This wasn’t Aurelia’s fault though… it is the single threaded nature of javascript that kept my application from being responsive.
After posting a question about this problem on Stack Overflow, someone suggested to use a server-side solver, and that triggered my idea to do it with a web-worker to escape the single threaded-ness. I had to do it this way because the backtracking algorithm couldn’t easily be cut into pieces nor be made asynchronous.
(Funny to mention: I asked: ‘How can I force Aurelia to update the DOM?’. First answer was: ‘I wouldn’t force her to do anything!’ :smiley: Very funny but accurate as well)
After having moved the heavy lifting to a web-worker, I was blown away by the speed achieved doing so! All of the 40k + solutions were found and - more important to me - shown on the screen, within 5 to 10 minutes! Without the app becoming unresponsive.
(For people who are checking the link above, the solver / spoiler doesn’t come available before you find a few solutions yourself :slight_smile:
Later I applied a web-worker in this maze game too, to have it find the shortest route to other elements in the maze using a Breadth First Tree Traversal algorithm.
Now in the Cellular Automata playground, the most important thing I learnt is that the principle of Single Responsibility is very important to keep your code more comprehensible and easier to debug. Some of you will ‘duhh’ now, but for me its was a good lesson to prevent struggle with code.

2 Likes