@threadedstack/wmd-web 0.1.50 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE.json +4 -4
- package/package.json +3 -3
- package/src/boot.js +38 -6
- package/src/edge/pins.gen.js +1 -1
- package/src/host/chan-service.js +4 -2
- package/src/host/stdio.js +4 -0
- package/wmdpack.wasm +0 -0
package/RELEASE.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wmd-web",
|
|
3
3
|
"version": "0.5.1",
|
|
4
|
-
"commit": "
|
|
4
|
+
"commit": "8f7cfff4adf7a48395a945e15a1041b56c81e789",
|
|
5
5
|
"previous": null,
|
|
6
6
|
"decisions": [
|
|
7
7
|
"D-388",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"package.json": "6de9aa9fabdb395651d39997c17e094f01a574f54a36f0af31bd3ffaae53cda1",
|
|
181
181
|
"src/base.js": "982f8e46dbb727ec542a494ebdb884ccd19a31ff4e091425b2d1fc01b0d4754a",
|
|
182
182
|
"src/blob.js": "bb2a2f0d87ce236280a7be2f246c926010dfe07f649c27da5e70d8eb5eaf7061",
|
|
183
|
-
"src/boot.js": "
|
|
183
|
+
"src/boot.js": "d983b2eb5a4faadd0893ce24d3ba27bd20e2bd02a577dcb6658aebb8c94ee491",
|
|
184
184
|
"src/build/builder.js": "c7794ec15b183213228776c8f4fb0950dec7e621f948358da7de8f90ef4f70ec",
|
|
185
185
|
"src/build/context.js": "d38097c61dbdadc4d41290c010425a4422f499aba473fa2b83f2a5c41e543571",
|
|
186
186
|
"src/build/dockerfile.js": "5957fe3d4ac8ff8b312f980ee04bd1d98ad4373a61f9a33e02f1ff1108b6ea53",
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
"src/host/base-io.js": "cdd049875dce9f1417f28b27efa2c6f494cbe2a49851249150d0c1ec871a8b59",
|
|
287
287
|
"src/host/boot-events.js": "a6567c889fa1e95ad7e917107a2593f03d14cc921827616368b3417de96faad2",
|
|
288
288
|
"src/host/chan-service-entry.js": "18f602f9ad72323e930157cb0820568f3ef83ce49b9672443791b01551f0ffd3",
|
|
289
|
-
"src/host/chan-service.js": "
|
|
289
|
+
"src/host/chan-service.js": "d61afdcbe1a6929dd93a2f7e842c8b94c8d742db59359004d08ec3997b154288",
|
|
290
290
|
"src/host/chan-services.js": "e7f52931b6ef76a8b97b793d0a1d86fb35d20dbca3dd333d18cc4ded0806c9f7",
|
|
291
291
|
"src/host/chan.js": "bb9e76890b0efeee7cfbd8481b9fb4620b3b184459d96d62ff68ddcdc8a46f83",
|
|
292
292
|
"src/host/ckpt-file.js": "da7938fa640a062e77bdfb59caad5b3b1fcbf6150e3220de3be23f253f4c4497",
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
"src/host/p9mount.js": "cd27abd769b19ed8b26050ddd8b6d61f81faa5a431924217dd0bf2593258d5b9",
|
|
320
320
|
"src/host/pinned-fetch.js": "873eb804604c150f6c8e488eb6c49fb8dc7a85108e80bf1a831904b9555726eb",
|
|
321
321
|
"src/host/ram-mem.js": "bf4036d5d12be1d5d2f5223e526b0b8e225bc702ae7e60a2a59fdfe9fbbb49e3",
|
|
322
|
-
"src/host/stdio.js": "
|
|
322
|
+
"src/host/stdio.js": "07881f378ac805bfd8e385dd51184fe5f16c67667b775fed28551f66b4100e66",
|
|
323
323
|
"src/host/threads.js": "952381940e7f43114867e9a9714528f2f20c8064b6b0f2018ab075128dc601be",
|
|
324
324
|
"src/host/wasi.js": "fbafa239b8fb4083f7e8c910b1adab38901e8e7cffd247284a9abb2847eaf4bd",
|
|
325
325
|
"src/host/wmd-imports.js": "3a00562f7c9c7787ab3841b14dde5d903a78f43ed19c43a2f5e31fd8a14c09d2",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadedstack/wmd-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/threadedstack/wmd-releases",
|
|
6
6
|
"repository": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "Browser host for wmd's guest vm.wasm (Web Workers + shared memory + WASI preview1)",
|
|
11
11
|
"wmd": {
|
|
12
|
-
"tag": "v0.1.
|
|
13
|
-
"commit": "
|
|
12
|
+
"tag": "v0.1.51",
|
|
13
|
+
"commit": "8f7cfff4adf7a48395a945e15a1041b56c81e789",
|
|
14
14
|
"web": "0.5.1"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
package/src/boot.js
CHANGED
|
@@ -40,7 +40,7 @@ import { bootFileName, cachedFromTiming, createBootEvents, createWorkerList, rea
|
|
|
40
40
|
import { createJitStore, readJitStats, tableMinOf } from './host/jit.js'
|
|
41
41
|
import { createJitCacheHost } from './host/jit-cache.js'
|
|
42
42
|
import { createPanicScanner, createThrottleMeter, createWatchdog, watchdogDefaultMs } from './host/monitor.js'
|
|
43
|
-
import { BOOT_RING, createStdio, stdioReader, stdioText } from './host/stdio.js'
|
|
43
|
+
import { BOOT_RING, MOBILE_RING, createStdio, stdioReader, stdioText } from './host/stdio.js'
|
|
44
44
|
import {
|
|
45
45
|
CONSOLE_IN_LIMIT, chanCounters, chanView, consoleInputGate, createChanBlock, markGuestGone, markServiceDead, ringBell, ringRead,
|
|
46
46
|
} from './host/chan.js'
|
|
@@ -348,6 +348,14 @@ export function heapReserveDefault(nav = globalThis.navigator) {
|
|
|
348
348
|
return !isMobileWebKit(nav)
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
/**
|
|
352
|
+
* IOS-1: bootWmd's stdout/stderr ring per fd when the caller names none. MOBILE_RING (4 MiB) in mobile WebKit, which
|
|
353
|
+
* counts the rings' whole SharedArrayBuffer as the tab's memory at once (D-516); BOOT_RING (32 MiB) elsewhere.
|
|
354
|
+
*/
|
|
355
|
+
export function stdioRingDefault(nav = globalThis.navigator) {
|
|
356
|
+
return isMobileWebKit(nav) ? MOBILE_RING : BOOT_RING
|
|
357
|
+
}
|
|
358
|
+
|
|
351
359
|
/**
|
|
352
360
|
* W34: the bytes of live JIT modules a WebKit page can hold, so that the machine's memory at its
|
|
353
361
|
* maximum + the page's own files + the engine's copies of the modules stay under 5.5 GiB (2.5 GiB
|
|
@@ -838,7 +846,7 @@ export function diskArgs(args, disk) {
|
|
|
838
846
|
* (host/jit-cache.js). Needs sharing. Counters in timings.jit (cacheHits, cacheMisses,
|
|
839
847
|
* translated, ...) and timings.jitCache; the index is put before vm.exited resolves (up to 10 s).
|
|
840
848
|
* @param {number} [o.stdioRingBytes] stdout/stderr ring per fd (power of two; default
|
|
841
|
-
* BOOT_RING, 32 MiB). If the page falls a whole ring behind, the skipped bytes are
|
|
849
|
+
* stdioRingDefault(): BOOT_RING, 32 MiB; MOBILE_RING, 4 MiB, in mobile WebKit). If the page falls a whole ring behind, the skipped bytes are
|
|
842
850
|
* replaced in the delivered text by a "[wmd-web: N bytes of stdout were dropped]" line.
|
|
843
851
|
* @param {number} [o.watchdogMs] end the boot (code -2) when the guest writes nothing and
|
|
844
852
|
* spawns no thread for this long after it starts. 0 = off.
|
|
@@ -1393,7 +1401,7 @@ async function bootMachine(o) {
|
|
|
1393
1401
|
// Firefox past its per-process wasm code limit), or that starts after the log reused the bytes of early
|
|
1394
1402
|
// Modules, compiles its copy from bytes the hub keeps (W31b), so every browser reclaims. o.jitReclaim overrides.
|
|
1395
1403
|
const jitStore = o.jit === false ? null : restoreIn?.jit ? restoreStore(restoreIn.jit, { reclaim: o.jitReclaim ?? true }) : createJitStore({ reclaim: o.jitReclaim ?? true })
|
|
1396
|
-
const stdio = createStdio(o.stdioRingBytes ??
|
|
1404
|
+
const stdio = createStdio(o.stdioRingBytes ?? stdioRingDefault())
|
|
1397
1405
|
let memTook = absMs() - tMem // the memory, the control block, the JIT store and the stdio rings (the channel block is added below)
|
|
1398
1406
|
const out = stdioReader(stdio)
|
|
1399
1407
|
const outText = stdioText(out)
|
|
@@ -1434,6 +1442,7 @@ async function bootMachine(o) {
|
|
|
1434
1442
|
let netWorker = null
|
|
1435
1443
|
let goWorker = null // X6 (default off): the Wasm twin of the guest's Go compiler
|
|
1436
1444
|
let goCspOff = null // takes the document's policy-violation listener of the live twin Worker off again
|
|
1445
|
+
let goPending = null // IOS-1: the twin's end of its channel, held until the channel service asks for the Worker (gowasm-need: the image has a Go tool)
|
|
1437
1446
|
let netStats = null
|
|
1438
1447
|
let netMember = null // W56: this guest on an in-page switch (switch.js attach())
|
|
1439
1448
|
const netWaiters = new Map()
|
|
@@ -1542,10 +1551,25 @@ async function bootMachine(o) {
|
|
|
1542
1551
|
}
|
|
1543
1552
|
else if (m.t === 'gowasm') ev({ t: 'gowasm', ...m.rec })
|
|
1544
1553
|
else if (m.t === 'gowasm-event') ev({ t: m.ev.t, ...m.ev }) // X6: the twin is off for this machine (why)
|
|
1554
|
+
else if (m.t === 'gowasm-need') {
|
|
1555
|
+
// IOS-1: the image has a Go tool the twin stands for: its Worker starts now (it used to start at boot for every image, and fetched and compiled the
|
|
1556
|
+
// Go compiler's module at once, memory a phone does not have for an image that never compiles Go)
|
|
1557
|
+
const p = goPending
|
|
1558
|
+
goPending = null
|
|
1559
|
+
if (p && !goWorker) {
|
|
1560
|
+
try {
|
|
1561
|
+
spawnGoTwin(p)
|
|
1562
|
+
} catch (err) {
|
|
1563
|
+
chanSvc?.postMessage({ t: 'gowasm-died', why: `the twin Worker could not start: ${(err && err.message) || err}` })
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1545
1567
|
else if (m.t === 'gowasm-stop') {
|
|
1546
1568
|
goWorker?.terminate()
|
|
1547
1569
|
goWorker = null
|
|
1548
1570
|
goCspOff?.()
|
|
1571
|
+
goPending?.close() // IOS-1: an image with no Go tool: the twin's Worker was never started
|
|
1572
|
+
goPending = null
|
|
1549
1573
|
}
|
|
1550
1574
|
else if (m.t === 'gowasm-restart') {
|
|
1551
1575
|
// the twin was in the middle of a compile that was cancelled: a Worker cannot be stopped inside one, so it ends and a new one starts
|
|
@@ -1618,8 +1642,9 @@ async function bootMachine(o) {
|
|
|
1618
1642
|
netWorker.postMessage({ t: 'init', port: mc.port2, relay, instance: netInstance, names: [...netNames], switchPort: netMember?.port, config, maxConns: netSvc.maxConns }, transfer)
|
|
1619
1643
|
}
|
|
1620
1644
|
const goSvc = chanSvcs.find(s => s.gowasm)
|
|
1621
|
-
|
|
1622
|
-
|
|
1645
|
+
// IOS-1: `port` is the twin's end of a channel made earlier (the first start, on gowasm-need); a restart makes a new channel and returns its other end
|
|
1646
|
+
const spawnGoTwin = (port = null) => {
|
|
1647
|
+
const mc = port ? { port1: null, port2: port } : new MessageChannel()
|
|
1623
1648
|
const w = (goWorker = new Worker(new URL('./host/gowasm-worker.js', import.meta.url), { type: 'module', name: 'wmd-gowasm' }))
|
|
1624
1649
|
w.onerror = err => chanSvc?.postMessage({ t: 'gowasm-died', why: `the twin Worker failed: ${err.message || err}` })
|
|
1625
1650
|
// fix 10 (F4): a policy violation the document sees is told to the Worker too (the Worker listens for its own); its reason text then says the policy blocked the source
|
|
@@ -1645,9 +1670,14 @@ async function bootMachine(o) {
|
|
|
1645
1670
|
let gowasmPort = null
|
|
1646
1671
|
let gowasmWhy = ''
|
|
1647
1672
|
// part 6: a service whose gowasm field says `off` (a checkpoint taken with the twin, restored in a boot that has the twin off) gets no Worker
|
|
1673
|
+
// IOS-1: the channel is made now and the Worker only when the channel service says the image has a Go tool (gowasm-need); what the service posts to
|
|
1674
|
+
// the twin before that waits in the channel
|
|
1648
1675
|
if (goSvc && !goSvc.gowasm.off) {
|
|
1649
1676
|
try {
|
|
1650
|
-
|
|
1677
|
+
if (typeof Worker !== 'function') throw new Error('this page has no Worker')
|
|
1678
|
+
const mc = new MessageChannel()
|
|
1679
|
+
gowasmPort = mc.port1
|
|
1680
|
+
goPending = mc.port2
|
|
1651
1681
|
} catch (err) {
|
|
1652
1682
|
gowasmWhy = `the twin Worker could not start: ${(err && err.message) || err}`
|
|
1653
1683
|
}
|
|
@@ -1890,6 +1920,8 @@ async function bootMachine(o) {
|
|
|
1890
1920
|
netWorker?.terminate()
|
|
1891
1921
|
goWorker?.terminate()
|
|
1892
1922
|
goCspOff?.()
|
|
1923
|
+
goPending?.close()
|
|
1924
|
+
goPending = null
|
|
1893
1925
|
netMember?.detach() // W56: its peers' streams to it fail; the name keeps its address
|
|
1894
1926
|
if (netWorker) timings.net = netStats
|
|
1895
1927
|
if (chanSab) timings.chan = { ...chanCounters(chanSab), service: chanStats, died: chanDied }
|
package/src/edge/pins.gen.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// The files of node in the sandboxed frame: the path under a source (the option edge: { sources } of bootWmd), the role the frame gives the file, its
|
|
3
3
|
// sha256 and its size. The page accepts a file only when it has exactly this sha256 and size. The notice files travel with the rest.
|
|
4
4
|
// EDGE_PACKAGE is the package that holds these files, for the {name} {version} {file} of a registry source's url (null: none named).
|
|
5
|
-
export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.
|
|
5
|
+
export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.51' }
|
|
6
6
|
export const EDGE_PINS = [
|
|
7
7
|
{ path: 'wmd_browser_bg.wasm', role: 'wasm', sha256: '1e3db7f2c5f4be0ee44e5f2c0205cf8ca11f906d9addd5512915fad4821661c2', size: 6334959 },
|
|
8
8
|
{ path: 'wmd_browser.js', role: 'glue', sha256: 'b389b072096881ba39b22cd705d3a230af02acc5409c61fb4f997d1081c4df6f', size: 75647 },
|
package/src/host/chan-service.js
CHANGED
|
@@ -341,9 +341,11 @@ async function init(m) {
|
|
|
341
341
|
lateFallbackAt: goSvc.gowasm.lateFallbackAt | 0, // test hook, default 0 (off)
|
|
342
342
|
mounts: goSvc.gowasm.mounts || null,
|
|
343
343
|
})
|
|
344
|
-
goEdge.pruneBundle() // an image with no Go compile: its stub mounts go out of the bundle before the guest starts the container
|
|
345
|
-
await goEdge.pruneUnpinned() // a Go release the pins do not name: its stubs go out too (the guest runs it alone), one calm event
|
|
344
|
+
const pb = goEdge.pruneBundle() // an image with no Go compile: its stub mounts go out of the bundle before the guest starts the container
|
|
345
|
+
const pu = await goEdge.pruneUnpinned() // a Go release the pins do not name: its stubs go out too (the guest runs it alone), one calm event
|
|
346
346
|
bindGoPort(m.gowasmPort)
|
|
347
|
+
// IOS-1: the page starts the twin's Worker only for an image that kept a tool the twin stands for; with none it never starts (no Worker, nothing fetched)
|
|
348
|
+
self.postMessage({ t: pb.kept && pu.kept ? 'gowasm-need' : 'gowasm-stop' })
|
|
347
349
|
}
|
|
348
350
|
if (offSvc) {
|
|
349
351
|
twinOffWhy = offSvc.gowasm.off // the stats carry it as gowasmOff, as for noTwin
|
package/src/host/stdio.js
CHANGED
|
@@ -17,6 +17,10 @@ export const RING = 1 << 22 // default bytes per fd for createStdio()
|
|
|
17
17
|
// minutes hidden). It costs 64 MiB of SharedArrayBuffer (pages are touched only as
|
|
18
18
|
// the ring fills), against the guest's 640 MiB shared memory.
|
|
19
19
|
export const BOOT_RING = 1 << 25
|
|
20
|
+
// IOS-1: bootWmd's default in mobile WebKit, which counts every byte of a SharedArrayBuffer the moment it is made
|
|
21
|
+
// (D-516): 2 x 4 MiB instead of 2 x 32 MiB, 56 MiB less on a phone. 4 MiB is about 12 s of console with no page
|
|
22
|
+
// event served; iOS suspends a hidden tab's Workers with the page, so the long hidden-tab gap does not arise there.
|
|
23
|
+
export const MOBILE_RING = RING
|
|
20
24
|
const H_LOCK = 0
|
|
21
25
|
const H_W1 = 1 // bytes ever written to fd 1, mod 2^32
|
|
22
26
|
const H_W2 = 2 // ... fd 2
|
package/wmdpack.wasm
CHANGED
|
Binary file
|