Poorman's WebWorker

This one is really interesting and you may find a good usage for it in your BabylonJS project as well.



Wow I never heard of that one. Very cool, def going to give it a shot some time


Neither did I but it seems to be a very cool feature :sunglasses:

1 Like

While I have not personally used a web worker for anything, the issue mentioned with web workers in this article does not surprise me. High object count is an issue for all sorts of software. File copy , 3D scenes , GPU’s , databases. etc. I guess the mentioned “transferable arrays” is like batching .

The article about the alternative workaround is interesting but why didnt they mention the results of using a transferable array. They just mentioned it is the advertised solution. but didnt say more about it after that.


Somewhat related, I also tried porting some data processing web worker code to JS coroutines called between render frames i.e. via scene.onBeforeRenderObservable. In testing it performed very well in Chrome/V8 but in Safari/JSC, performance was much worse than the equivalent web worker code.

1 Like

Good point. I did a quick search and it seems this is supported across modern browsers and is very performant.

I recommend https://threads.js.org/ for webworkers. It supports transferring array buffers and other cool features as well, used it many times. I like it’s observable pattern it encourages

1 Like

In some environments it’s not easy to setup WebWorkers so I think this can be a cool addition to them.