Skip to content
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

transferring objects from thread to thread, and/or modifying across threads #124

Open
trusktr opened this issue Apr 9, 2021 · 0 comments

Comments

@trusktr
Copy link
Member

trusktr commented Apr 9, 2021

WebAssembly is unique, and thus so is AssemblyScript.

In plain JavaScript, arbitrary JS objects (except for certain special ones) cannot be transferred between workers.

But in WebAssembly (and hence AssemblyScript), because everything is buffers, we could potentially do special things like pass objects around (transfer an object's actual bits) from worker to worker, and use them in any worker, and/or reference the same object pointers in a shared heap across workers.

In plain JavaScript, it is therefore hard to make a thread/worker task manager like the idea being made in Three.js, but we may be able to do this fairly easily in AssemblyScript.

In particular, a glas user may be able to tell a worker thread to parse a GLTF file, and that worker can send back fully-usable glas objects (f.e. Mesh, Material, etc). That is not possible in JavaScript, so in that Three.js TaskManager attempt, workers will send processed data back to a main worker (f.e. main thread) and the main worker would still need to construct the regular Three.js objects in order to finally render the scene.

But in glas, a task worker will be able to simply send back usable objects (or pointers) and on the main thread we'll be able to simply render the scene without having to create new objects back in the main thread.

We should first make a basic concept of this multi-thread object passing, perhaps make that a separate lib, then use it in glas.

I think the nature of WebAssembly's binary format may give us a big advantage here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant