Skip to content

Port dedicated Web Workers and worker-realm polyfills - #29

Draft
matthargett wants to merge 4 commits into
port/napi-v7from
port/dedicated-workers
Draft

matthargett wants to merge 4 commits into
port/napi-v7from
port/dedicated-workers

Conversation

@matthargett

@matthargett matthargett commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Ports BabylonJS/JsRuntimeHost#258 onto the monorepo Node-API v7 branch. The diff excludes the conformance and v7 layers as well as all NativeXr and renderer changes.

Adds dedicated worker realms, structured clone and ArrayBuffer transfer lists, worker lifecycle and messaging, and the Streams, Fetch/Response, Compression, Blob/File and IndexedDB functionality used by the application-derived worker fixture. Runtime dispatch preserves the upstream Apple and Linux JSC run loops. Shutdown wakes the active loop and late worker deliveries use a lifetime-safe parent scheduler.

The application-facing constructor is the browser form: new Worker(new URL(...), { type: "module" }). The embedder enables JSRUNTIMEHOST_POLYFILL_WORKER, links Worker, and initializes it with a bundle root or asset resolver before evaluating application code. Module workers must be bundled into self-contained script-compatible chunks. IndexedDB is in-memory and per realm; nested workers, transferable MessagePorts and SharedArrayBuffer are out of scope. Apple distribution builds do not use private watchdog SPI: non-yielding code cannot be forcibly interrupted there.

macOS Release validation: public JavaScriptCore (67 native tests, 351 JS cases) and QuickJS (52 native tests, 348 JS cases). Includes queued messages and teardown, the WPT-derived worker regressions, and a visualization worker fetching compressed data into IndexedDB. The full production Factotum bundle and physical devices have not been run. No application, WebXR or renderer changes are included.

Implementation and device TODOs

  • Implementation: Supply and pin a default APK asset path for app:/// entry and relative importScripts; compare same-realm structuredClone with the fork. Preserve parent-realm FIFO shutdown/error delivery.
  • On device: Without an injected resolver, load nested APK scripts, measure archive-sized transfers and peak memory (the portable path snapshots, then copies into a vector and into the receiving realm), terminate during delivery, and replay education then react-native.

AGENTS.md · Qualification and PR index. Upstream-shared head; fork-only instructions are in the linked handoff.

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