Skip to content

feat: JSWorker for all runtimes (not just V8) + Node transfers#211

Merged
Benjamin-Dobell merged 2 commits intogodotjs:mainfrom
Benjamin-Dobell:feat/jsworker-all-platforms
Apr 20, 2026
Merged

feat: JSWorker for all runtimes (not just V8) + Node transfers#211
Benjamin-Dobell merged 2 commits intogodotjs:mainfrom
Benjamin-Dobell:feat/jsworker-all-platforms

Conversation

@Benjamin-Dobell
Copy link
Copy Markdown
Member

@Benjamin-Dobell Benjamin-Dobell commented Apr 17, 2026

  • JSC and QuickJS now implement the V8 Serializer API in order to handle serialization of standard JS types intermingled with Godot variants.

    On the web things are a bit more complex. We try take advantage of the web's built-in postMessage functionality as much as possible. The browser's postMessage handles structured clone for us i.e. will serialize plain old data, as well as more advanced types like Set, Map etc. However, it can't handle Godot types. So before calling postMessage we descend through the message data structure and replace Godot objects with markers which are delivered via the transfer list (WASM side channel). If a message contains no Godot objects then process is particularly performant because neither the sender or the receiver need to cross the WASM bridge at all when sending/receiving the message.

    QuickJS-NG has been updated to the latest version.

  • Implemented a test matrix for each of our runtimes:

    • V8
    • QuickJS (NG)
    • JavaScriptCore
    • Web
    • QuickJS WASM on Web
  • Godot/GodotJS executable can now be executed with --headless --editor --generate-types and it will populate typings/ and gen/ directories with engine and project types. Projects may now optionally omit these directories from their Git repos and then perform a bootstrap process:

    • Build with type checking disabled (tsc --noCheck) to generate .godotjs/ with JavaScript.
    • Execute Godot with --headless --editor --generate-types
      The project will these be ready to build as per usual with full type checking. The GodotJS test project now takes this approach during CI as it makes it easier to run the test project against different Godot engine versions (which have different APIs and therefore different types).

@Benjamin-Dobell Benjamin-Dobell force-pushed the feat/jsworker-all-platforms branch 3 times, most recently from 147aa88 to 1f916e5 Compare April 17, 2026 16:32
@Benjamin-Dobell Benjamin-Dobell marked this pull request as ready for review April 17, 2026 16:42
@Benjamin-Dobell Benjamin-Dobell force-pushed the feat/jsworker-all-platforms branch 12 times, most recently from 325cd1e to 30b4853 Compare April 19, 2026 18:04
JSC and QuickJS now implement the V8 Serializer API in order
to handle serialization of standard JS types intermingled with
Godot variants.

On the web things are a bit more complex. We try take advantage of
the web's built-in postMessage functionality as much as possible.
The browser's postMessage handles structured clone for us i.e. will
serialize plain old data, as well as more advanced types like Set,
Map etc. However, it can't handle Godot types. So before calling
postMessage we descend through the message data structure and
replace Godot objects with markers which are delivered via the
transfer list (WASM side channel). If a message contains no
Godot objects then process is particularly performant because
neither the sender or the receiver need to cross the WASM bridge
at all when sending/receiving the message.

QuickJS-NG has been updated to the latest version.

Also, implemented a test matrix for each of our runtimes:

- V8
- QuickJS (NG)
- JavaScriptCore
- Web
- QuickJS WASM on Web
@Benjamin-Dobell Benjamin-Dobell force-pushed the feat/jsworker-all-platforms branch 6 times, most recently from 40ff6e6 to 7f73626 Compare April 20, 2026 04:30
Also:

- Cleaned up "jsb.editor.codegen" APIs slightly.
- Web build fixes. in particular addresses closure compiler (release) web build issues.
@Benjamin-Dobell Benjamin-Dobell force-pushed the feat/jsworker-all-platforms branch from 7f73626 to f02ae77 Compare April 20, 2026 04:42
@Benjamin-Dobell Benjamin-Dobell merged commit a01cc6d into godotjs:main Apr 20, 2026
28 checks passed
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

Successfully merging this pull request may close these issues.

1 participant