Worker imports & memory sharing

オープン
#112 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, wasm
領域
web-dev

調査の方向性

Start by reading the linked discussion in issue 14 and the ESM Phase Imports proposal in pull request 106, then compare the worker and dynamic import scenarios described here. Determine whether passing imports to new Worker() should be specified and how that interacts with module import resolution. Done means a concrete, agreed proposal or specification change with its ergonomics and compatibility implications resolved.

索引モデルが issue の本文から書いたものです。

説明

As brought up in https://github.com/WebAssembly/esm-integration/issues/14#issuecomment-2931717336, one problem with the ESM integration instance import model is that for multi-threading scenarios the memory import needs to be available at startup.

The ESM Phase Imports proposal also enables the ability for new Worker(wasmModule) to create a worker from a WebAssembly module which is currently specified in https://github.com/WebAssembly/esm-integration/pull/106.

Delaying instantiation via dynamic import provides one route, but it might be worth considering the ergonomics more carefully here.

One idea might be to allow passing module imports to the new Worker() constructor when using the new source form:

import source mod from './mod.wasm';
const memory = new WebAssembly.Memory(...);
const worker = new Worker(source, {
  imports: {
    'memory': memory
  }
});

Normally for dynamic import() this sort of resolution override is dangerous due to mismatch with existing imports, but as the creator of the module environment it could be framed as a sort of top-level-only import map, so that setting imports for context creation can certainly work actually.

@sbc100 let me know if I'm summarizing the issue correctly or missing anything here too.

主要言語
WebAssembly
スター
458
フォーク
40
平均マージ
10日 37分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WebAssembly/esm-integration のほかの issue

WebAssembly/esm-integration の issue をすべて見る

似ている issue

Web Dev の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。