lume / lume/glas

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

Open
#124 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
942
Forks
45
PR merge metrics
No merged PRs in 30d

Description

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...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files, tests, or entry points are named; start by researching the proposed WebAssembly/AssemblyScript worker object-transfer concept and the linked Three.js TaskManager discussion. Define a separate library's scope and a minimal transfer or shared-pointer proof of concept, then verify that a worker can return usable GLTF-related objects without reconstruction.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
distributed-systems, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.