Browser kernel for threejs

The idea is to create a specialized runtime or scheduler for Three.js that automates web worker management, functioning like an OS kernel for web applications by transparently offloading computationally intensive tasks—such as geometry calculations, physics simulations, or rendering—to background threads without requiring developers to manually set up workers. This “browser kernel” would analyze Three.js API calls or runtime performance to dynamically spawn workers, manage data transfer, and optimize parallelism, aiming to simplify development and boost performance for complex 3D web applications, particularly in games or simulations, while leveraging existing browser features like OffscreenCanvas and libraries like Comlink for seamless integration.

This is one extremely ambitious and extremely challenging idea. If you plan to work on it, consider also offloading work to the GPU, when appropriate.

1 Like

Yeah, thank you for your inputs

I am not going to alter the working of the GPU, I am thinking of distributing the heavy computation (like uncompressing models and texture etc) among the web workers in an optimised way

It sounds interesting, but in practice, I don’t think you have enough introspection abilities to make an automated decision about how/what to offload.. and that’s kinda the hardst part. Once you know what you need to offload, managing a pool of workers and giving them tasks isn’t that difficult.
On the other hand, what you describe sounds a bit like an opinionated game engine.

Another thing to note is that not all those bottlenecks can be workered-around.

Lag from big models is sometimes due to material compilation, texture upload, and geometry upload.. and those can’t be done by a worker.

1 Like