@usemosio/cli-linux-x64 1.0.0-next.1 → 1.0.0-next.2
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/THIRD_PARTY_NOTICES.md +22 -0
- package/apps/studio/dist/assets/Workspace-DsbQ04kb.js +34 -0
- package/apps/studio/dist/assets/{agent-panel-CqJuv5Sn.js → agent-panel-DUWPbpew.js} +5 -5
- package/apps/studio/dist/assets/{boundary-bK2S8z05.js → boundary-DuK3AiqM.js} +1 -1
- package/apps/studio/dist/assets/{feedback-BqzXUdVd.js → feedback-x6ZumR_x.js} +1 -1
- package/apps/studio/dist/assets/index-CjDBKmB_.css +2 -0
- package/apps/studio/dist/assets/index-DPLtb0kT.js +1905 -0
- package/apps/studio/dist/assets/inspector3d-B8pkZTye.js +1 -0
- package/apps/studio/dist/index.html +4 -3
- package/apps/studio/dist-host/studio-host.mjs +262 -3
- package/bin/mosio +0 -0
- package/bin/mosio-agent +0 -0
- package/crates/mosio/src/adapters/mosio-three.js +111 -7
- package/crates/mosio/src/adapters/room-env-pmrem.json +1 -0
- package/crates/mosio/src/runtime.js +126 -6
- package/fixtures/camera-inspect/mosio.json +56 -0
- package/fixtures/camera-inspect/scenes/behind.html +22 -0
- package/fixtures/camera-inspect/scenes/cut.html +18 -0
- package/fixtures/camera-inspect/scenes/edges.html +18 -0
- package/fixtures/camera-inspect/scenes/good.html +23 -0
- package/fixtures/camera-inspect/scenes/read.html +22 -0
- package/fixtures/camera-inspect/scenes/shake.html +23 -0
- package/fixtures/camera-inspect/scenes/speed.html +18 -0
- package/fixtures/camera-inspect-vertical/mosio.json +31 -0
- package/fixtures/camera-inspect-vertical/scenes/good.html +20 -0
- package/fixtures/camera-inspect-vertical/scenes/safe.html +18 -0
- package/fixtures/inspect-physics/expect.json +18 -0
- package/fixtures/inspect-physics/mosio.json +29 -0
- package/fixtures/inspect-physics/scenes/calm.html +46 -0
- package/fixtures/inspect-physics/scenes/physics.html +47 -0
- package/package.json +1 -1
- package/primitives/README.md +23 -2
- package/primitives/example/shared/mosio-prims.js +349 -1
- package/primitives/impact-burst/golden/f030.png +0 -0
- package/primitives/impact-burst/golden/f032.png +0 -0
- package/primitives/impact-burst/golden/f036.png +0 -0
- package/primitives/impact-burst/impact-burst.js +51 -0
- package/primitives/impact-burst/primitive.json +130 -0
- package/primitives/impact-burst/scene.html +24 -0
- package/primitives/stick-figure/golden/f030.png +0 -0
- package/primitives/stick-figure/golden/f092.png +0 -0
- package/primitives/stick-figure/golden/f140.png +0 -0
- package/primitives/stick-figure/primitive.json +179 -0
- package/primitives/stick-figure/scene.html +40 -0
- package/primitives/stick-figure/stick-figure.js +297 -0
- package/primitives/zoom-through/primitive.json +7 -2
- package/primitives/zoom-through/zoom-through.js +6 -5
- package/scripts/3d-acceptance.sh +8 -1
- package/scripts/3d-attach-bench.mjs +119 -0
- package/scripts/3d-bake-room-env.mjs +74 -0
- package/scripts/3d-e2b-job.sh +1 -0
- package/scripts/3d-gen-heavy-fixture.py +65 -0
- package/scripts/3d-trace-summary.py +14 -0
- package/scripts/acceptance/camera-inspect.sh +49 -0
- package/scripts/acceptance/export.sh +5 -3
- package/scripts/acceptance/hardening.sh +37 -6
- package/scripts/acceptance/hub.sh +208 -0
- package/scripts/acceptance/inspect.sh +21 -2
- package/scripts/acceptance/revisions-git.sh +137 -0
- package/scripts/acceptance/revisions-sync.sh +323 -0
- package/scripts/acceptance/revisions.sh +118 -4
- package/scripts/acceptance/segcache.sh +100 -0
- package/scripts/acceptance/split.sh +78 -0
- package/scripts/bootstrap.sh +20 -1
- package/scripts/check-error-codes.py +8 -0
- package/scripts/check-file-size.sh +49 -0
- package/scripts/ci.sh +4 -4
- package/scripts/dedupe-report.sh +47 -0
- package/scripts/e2b/template/provision.sh +1 -1
- package/scripts/fastpath/cdp.mjs +25 -0
- package/scripts/fastpath/dbg.mjs +11 -0
- package/scripts/fastpath/e2b.mjs +40 -0
- package/scripts/fastpath/features/gen.py +109 -0
- package/scripts/fastpath/features/mosio.json +100 -0
- package/scripts/fastpath/features/scenes/backdrop.html +11 -0
- package/scripts/fastpath/features/scenes/blend.html +11 -0
- package/scripts/fastpath/features/scenes/canvas2d.html +11 -0
- package/scripts/fastpath/features/scenes/filter.html +11 -0
- package/scripts/fastpath/features/scenes/gradient.html +11 -0
- package/scripts/fastpath/features/scenes/iframe.html +11 -0
- package/scripts/fastpath/features/scenes/image.html +11 -0
- package/scripts/fastpath/features/scenes/svg.html +11 -0
- package/scripts/fastpath/features/scenes/text.html +11 -0
- package/scripts/fastpath/features/scenes/typo.html +11 -0
- package/scripts/fastpath/features/scenes/video.html +11 -0
- package/scripts/fastpath/features/scenes/video2.html +11 -0
- package/scripts/fastpath/features-xfade/mosio.json +49 -0
- package/scripts/fastpath/features-xfade/scenes/image.html +11 -0
- package/scripts/fastpath/features-xfade/scenes/video.html +11 -0
- package/scripts/fastpath/fixtures/gen_layout.py +80 -0
- package/scripts/fastpath/fixtures/l12-no-reset/assets/img/photo-1015.jpg +0 -0
- package/scripts/fastpath/fixtures/l12-no-reset/mosio.json +34 -0
- package/scripts/fastpath/fixtures/l12-no-reset/scenes/main.html +20 -0
- package/scripts/fastpath/fp.mjs +91 -0
- package/scripts/fastpath/inpage.js +68 -0
- package/scripts/fastpath/recipes.py +49 -0
- package/scripts/fastpath/sandbox.sh +68 -0
- package/scripts/fastpath/sandbox10.sh +57 -0
- package/scripts/fastpath/sandbox11.sh +18 -0
- package/scripts/fastpath/sandbox12.sh +30 -0
- package/scripts/fastpath/sandbox13.sh +16 -0
- package/scripts/fastpath/sandbox14.sh +28 -0
- package/scripts/fastpath/sandbox15.sh +36 -0
- package/scripts/fastpath/sandbox16.sh +60 -0
- package/scripts/fastpath/sandbox17.sh +34 -0
- package/scripts/fastpath/sandbox18.sh +59 -0
- package/scripts/fastpath/sandbox19.sh +67 -0
- package/scripts/fastpath/sandbox2.sh +41 -0
- package/scripts/fastpath/sandbox20.sh +34 -0
- package/scripts/fastpath/sandbox21.sh +22 -0
- package/scripts/fastpath/sandbox22.sh +22 -0
- package/scripts/fastpath/sandbox23.sh +21 -0
- package/scripts/fastpath/sandbox3.sh +151 -0
- package/scripts/fastpath/sandbox4.sh +161 -0
- package/scripts/fastpath/sandbox5.sh +69 -0
- package/scripts/fastpath/sandbox6.sh +85 -0
- package/scripts/fastpath/sandbox7.sh +81 -0
- package/scripts/fastpath/sandbox8.sh +62 -0
- package/scripts/fastpath/sandbox9.sh +130 -0
- package/scripts/fastpath/srv.mjs +15 -0
- package/scripts/fastpath/www/probe.html +1 -0
- package/scripts/hpbench/make-bench-fixtures.sh +43 -0
- package/scripts/hpbench/render-cgroup.sh +56 -0
- package/scripts/install.sh +2 -1
- package/scripts/npm-clean-install-proof-win.sh +64 -0
- package/scripts/platform-smoke.sh +67 -0
- package/scripts/prim.mjs +31 -13
- package/skills/mosio-3d/SKILL.md +1 -1
- package/skills/mosio-brief/SKILL.md +80 -0
- package/skills/mosio-brief/references/brief.md +141 -0
- package/skills/mosio-brief/references/copy.md +99 -0
- package/skills/mosio-brief/references/narration.md +61 -0
- package/skills/mosio-brief/references/storyboard.md +98 -0
- package/skills/mosio-collab/SKILL.md +104 -0
- package/skills/mosio-collab/references/hub.md +62 -0
- package/skills/mosio-engine/SKILL.md +44 -13
- package/skills/mosio-engine/references/camera.md +12 -2
- package/skills/mosio-engine/references/character.md +88 -0
- package/skills/mosio-engine/references/checks.md +10 -3
- package/skills/mosio-engine/references/delivery.md +29 -2
- package/skills/mosio-engine/references/kit-primitives.md +8 -4
- package/skills/mosio-engine/references/layout.md +8 -0
- package/skills/mosio-engine/references/plan.md +3 -1
- package/skills/mosio-engine/references/project.md +3 -3
- package/skills/mosio-engine/references/publish.md +79 -0
- package/skills/mosio-engine/references/registry.md +27 -15
- package/skills/mosio-engine/references/timeline.md +18 -0
- package/skills/mosio-engine/references/timing.md +2 -1
- package/skills/mosio-import/SKILL.md +1 -1
- package/skills/mosio-import/references/from-hyperframes.md +1 -1
- package/skills/mosio-import/references/from-remotion.md +1 -1
- package/skills/mosio-media/SKILL.md +16 -4
- package/skills/mosio-media/references/audio.md +29 -11
- package/skills/mosio-media/references/captions.md +22 -4
- package/skills/mosio-media/references/editing.md +70 -0
- package/skills/mosio-media/references/footage.md +40 -8
- package/skills/mosio-media/references/voice.md +52 -7
- package/skills/mosio-replicate/references/mosio.md +1 -1
- package/toolchain.lock.json +151 -4
- package/apps/studio/dist/assets/Workspace-KSOFeEgc.js +0 -32
- package/apps/studio/dist/assets/index-B-uuTqe9.js +0 -1785
- package/apps/studio/dist/assets/index-CajSh04l.css +0 -2
- package/apps/studio/dist/assets/inspector3d-vDz97X99.js +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// First-attach timing of a 3D scene on the CPU (SwiftShader) profile, through the real PreviewOrigin
|
|
2
|
+
// (the same documents, importmap, /_lib and CSP the Studio preview gets) in the pinned headless Chromium.
|
|
3
|
+
// node --conditions=source scripts/3d-attach-bench.mjs --project fixtures/3d/t1-turntable [--scene id] [--runs 3] [--out f.json]
|
|
4
|
+
// Env: MOSIO_CHROME (chrome-headless-shell), MOSIO_HOME (for /_lib). Needs playwright-core (npm ci). Sandbox only.
|
|
5
|
+
// --texmax N open the preview with mosio_texmax=N NO_ROOM_ENV_FILE=1 do not serve the baked room environment
|
|
6
|
+
// BENCH_PROFILE=1 V8 self-time and native-time owners of the cold run BENCH_TRACE=f.json Chromium trace (summarise: scripts/3d-trace-summary.py)
|
|
7
|
+
// Per run: a COLD attach (fresh browser profile = empty HTTP cache and no V8 code cache), then WARM attaches
|
|
8
|
+
// (same browser: a second and third page of the same project). Phases come from `performance.mark` calls in
|
|
9
|
+
// mosio-three (mosio3d:*) plus resource timing and the first exact seek.
|
|
10
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import { PreviewOrigin } from "../packages/runtime/src/node/preview-origin.ts";
|
|
14
|
+
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const { chromium } = require("playwright-core");
|
|
17
|
+
const arg = (k, d) => { const i = process.argv.indexOf(`--${k}`); return i > 0 ? process.argv[i + 1] : d; };
|
|
18
|
+
const project = resolve(arg("project", ""));
|
|
19
|
+
const runs = Number(arg("runs", "3"));
|
|
20
|
+
const home = process.env.MOSIO_HOME || "/opt/mosio";
|
|
21
|
+
const chrome = process.env.MOSIO_CHROME || require("node:child_process").execSync(`ls -d ${home}/browsers/chrome-headless-shell-*/chrome-headless-shell-*/chrome-headless-shell 2>/dev/null | head -1`).toString().trim();
|
|
22
|
+
const manifest = JSON.parse(readFileSync(join(project, "mosio.json"), "utf8"));
|
|
23
|
+
const scene = (manifest.scenes || []).find((s) => s.id === arg("scene", "")) || manifest.scenes[0];
|
|
24
|
+
const repo = resolve(new URL("..", import.meta.url).pathname);
|
|
25
|
+
const runtimeJs = readFileSync(join(repo, "crates/mosio/src/runtime.js"), "utf8");
|
|
26
|
+
const embedded = new Map(["mosio-three.js", "room-env-pmrem.json"].filter((f) => (f !== "room-env-pmrem.json" || process.env.NO_ROOM_ENV_FILE !== "1") && existsSync(join(repo, "crates/mosio/src/adapters", f))).map((f) => [`mosio-three@0.1.0/${f}`, readFileSync(join(repo, "crates/mosio/src/adapters", f), "utf8")]));
|
|
27
|
+
const FLAGS = ["--no-sandbox", "--disable-gpu", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--use-gl=angle", "--ignore-gpu-blocklist"];
|
|
28
|
+
|
|
29
|
+
const po = new PreviewOrigin({ dir: project, runtimeJs, libDir: join(home, "lib"), embeddedLibs: embedded, timeoutMs: 120000, inlineProxy: false });
|
|
30
|
+
await po.start();
|
|
31
|
+
const med = (a) => { const s = [...a].sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : null; };
|
|
32
|
+
|
|
33
|
+
async function attach(ctx, n) {
|
|
34
|
+
const page = await ctx.newPage();
|
|
35
|
+
const logs = [];
|
|
36
|
+
page.on("console", (m) => { if (m.type() === "error") logs.push(m.text()); });
|
|
37
|
+
page.on("pageerror", (e) => logs.push(String(e)));
|
|
38
|
+
const url = `${po.documentOrigin()}/${scene.src}?mosio_scene=${scene.id}&mosio_nonce=benchnonce${n}${arg("texmax", "") ? `&mosio_texmax=${arg("texmax", "")}` : ""}`;
|
|
39
|
+
let trace = null;
|
|
40
|
+
if (process.env.BENCH_TRACE && n.endsWith("c")) {
|
|
41
|
+
const b = ctx.browser(); trace = await b.newBrowserCDPSession();
|
|
42
|
+
await trace.send("Tracing.start", { traceConfig: { includedCategories: ["toplevel", "gpu", "viz", "v8", "devtools.timeline", "disabled-by-default-gpu.service", "disabled-by-default-gpu.angle", "gpu.angle", "disabled-by-default-gpu.debug", "gpu.angle.renderdoc", "disabled-by-default-gpu.decoder", "blink", "cc", "loading"], recordMode: "recordAsMuchAsPossible" }, transferMode: "ReturnAsStream" });
|
|
43
|
+
}
|
|
44
|
+
let prof = null;
|
|
45
|
+
if (process.env.BENCH_PROFILE && n.endsWith("c")) { prof = await ctx.newCDPSession(page); await prof.send("Profiler.enable"); await prof.send("Profiler.setSamplingInterval", { interval: 500 }); await prof.send("Profiler.start"); }
|
|
46
|
+
const t0 = Date.now();
|
|
47
|
+
const resp = await page.goto(url, { waitUntil: "commit" });
|
|
48
|
+
const tCommit = Date.now() - t0;
|
|
49
|
+
if (process.env.BENCH_DEBUG) console.error(url, resp.status(), await resp.text().then((t) => t.slice(0, 300)).catch(() => ""));
|
|
50
|
+
// poll from Node: the Core runtime virtualises the page's own timers
|
|
51
|
+
for (let i = 0; i < 2000 && !(await page.evaluate(() => !!window.__mosio).catch(() => false)); i++) await new Promise((r) => setTimeout(r, 5));
|
|
52
|
+
const ready = await page.evaluate(async () => { performance.mark("mosio3d:bench:ready-call"); const r = await window.__mosio._ready(); performance.mark("mosio3d:bench:ready-done"); return r; });
|
|
53
|
+
const tReady = Date.now() - t0;
|
|
54
|
+
const readyNow = 0;
|
|
55
|
+
const s0 = Date.now();
|
|
56
|
+
await page.evaluate(() => window.__mosio._seek(0, { live: true }));
|
|
57
|
+
const tSeek0 = Date.now() - s0;
|
|
58
|
+
const s1 = Date.now();
|
|
59
|
+
await page.evaluate(() => window.__mosio._seek(7, { live: true }));
|
|
60
|
+
const tSeek1 = Date.now() - s1;
|
|
61
|
+
const data = await page.evaluate(() => ({
|
|
62
|
+
marks: performance.getEntriesByType("mark").filter((m) => m.name.startsWith("mosio3d:")).map((m) => [m.name, Math.round(m.startTime)]),
|
|
63
|
+
nav: (() => { const n = performance.getEntriesByType("navigation")[0]; return n ? { responseEnd: Math.round(n.responseEnd), dcl: Math.round(n.domContentLoadedEventEnd), load: Math.round(n.loadEventEnd) } : null; })(),
|
|
64
|
+
res: performance.getEntriesByType("resource").map((r) => ({ n: r.name.replace(/^https?:\/\/[^/]+/, ""), start: Math.round(r.startTime), end: Math.round(r.responseEnd), size: r.transferSize, dec: r.decodedBodySize })),
|
|
65
|
+
}));
|
|
66
|
+
if (trace) {
|
|
67
|
+
const done = new Promise((res) => trace.once("Tracing.tracingComplete", res));
|
|
68
|
+
await trace.send("Tracing.end"); const { stream } = await done;
|
|
69
|
+
let txt = ""; for (;;) { const c = await trace.send("IO.read", { handle: stream }); txt += c.data; if (c.eof) break; }
|
|
70
|
+
writeFileSync(process.env.BENCH_TRACE, txt);
|
|
71
|
+
}
|
|
72
|
+
if (prof) {
|
|
73
|
+
const { profile } = await prof.send("Profiler.stop");
|
|
74
|
+
const self = new Map(), byId = new Map(profile.nodes.map((nd) => [nd.id, nd]));
|
|
75
|
+
const dt = profile.timeDeltas;
|
|
76
|
+
profile.samples.forEach((id, i) => { const nd = byId.get(id), cf = nd.callFrame, k = `${cf.functionName || "(anon)"} ${cf.url.replace(/^https?:\/\/[^/]+/, "")}:${cf.lineNumber}`; self.set(k, (self.get(k) || 0) + (dt[i] || 0) / 1000); });
|
|
77
|
+
// who is on the stack while the thread is in native code: attribute "(program)" to its nearest JS ancestor, with its time window
|
|
78
|
+
const parent = new Map(); for (const nd of profile.nodes) for (const c of nd.children || []) parent.set(c, nd.id);
|
|
79
|
+
const owner = new Map(); let tcur = 0;
|
|
80
|
+
profile.samples.forEach((id, i) => { tcur += (dt[i] || 0) / 1000; const nd = byId.get(id); if (nd.callFrame.functionName !== "(program)") return; let q = parent.get(id), f = byId.get(q); while (f && (f.callFrame.functionName === "(root)" || !f.callFrame.url) && parent.has(f.id)) f = byId.get(parent.get(f.id)); const k = f ? `${f.callFrame.functionName || "(anon)"} ${f.callFrame.url.replace(/^https?:\/\/[^/]+/, "")}:${f.callFrame.lineNumber}` : "(no js)"; const o = owner.get(k) || { ms: 0, a: tcur, b: tcur }; o.ms += (dt[i] || 0) / 1000; o.b = tcur; owner.set(k, o); });
|
|
81
|
+
console.error("PROGRAM time by JS owner:\n" + [...owner.entries()].sort((a, b) => b[1].ms - a[1].ms).slice(0, 12).map(([k, o]) => `${Math.round(o.ms)} ms [${Math.round(o.a)}..${Math.round(o.b)}] ${k}`).join("\n"));
|
|
82
|
+
const top = [...self.entries()].sort((a, b) => b[1] - a[1]).slice(0, 25).map(([k, v]) => `${Math.round(v)} ms ${k}`);
|
|
83
|
+
console.error("PROFILE self-time top:\n" + top.join("\n"));
|
|
84
|
+
}
|
|
85
|
+
const cdp = await ctx.newCDPSession(page);
|
|
86
|
+
const metrics = Object.fromEntries((await cdp.send("Performance.getMetrics").catch(() => ({ metrics: [] }))).metrics.map((m) => [m.name, m.value]));
|
|
87
|
+
await page.close();
|
|
88
|
+
return { tReady, tCommit, readyNow, tSeek0, tSeek1, ok: ready && ready.ok !== false, ready: ready && { ok: ready.ok, errors: ready.errors }, ...data, scriptS: metrics.ScriptDuration, taskS: metrics.TaskDuration, logs: logs.slice(0, 3) };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const all = [];
|
|
92
|
+
for (let r = 0; r < runs; r++) {
|
|
93
|
+
const browser = await chromium.launch({ executablePath: chrome, args: FLAGS, headless: true });
|
|
94
|
+
const ctx = await browser.newContext();
|
|
95
|
+
const cold = await attach(ctx, `${r}c`);
|
|
96
|
+
const warm = [await attach(ctx, `${r}w1`), await attach(ctx, `${r}w2`)];
|
|
97
|
+
await browser.close();
|
|
98
|
+
all.push({ cold, warm });
|
|
99
|
+
console.error(`run ${r}: cold ready ${cold.tReady} ms (seek0 ${cold.tSeek0}, seek7 ${cold.tSeek1}); warm ready ${warm.map((w) => w.tReady).join(", ")} ms`);
|
|
100
|
+
}
|
|
101
|
+
po.close();
|
|
102
|
+
// phase table: marks are ms since navigation start; a phase = distance between two consecutive marks of the median run
|
|
103
|
+
const names = [...new Set(all.flatMap((a) => a.cold.marks.map((m) => m[0])))];
|
|
104
|
+
const phases = {};
|
|
105
|
+
for (const n of names) phases[n] = med(all.map((a) => (a.cold.marks.find((m) => m[0] === n) || [0, null])[1]).filter((v) => v !== null));
|
|
106
|
+
const summary = {
|
|
107
|
+
project, scene: scene.id, runs, chrome,
|
|
108
|
+
cold_commit_ms: med(all.map((a) => a.cold.tCommit)), cold_ready_now_ms: med(all.map((a) => a.cold.readyNow)),
|
|
109
|
+
cold_tail_after_ready_mark_ms: med(all.map((a) => { const m = Object.fromEntries(a.cold.marks); return m['mosio3d:bench:ready-done'] - m['mosio3d:ready']; })),
|
|
110
|
+
cold_ready_ms: med(all.map((a) => a.cold.tReady)), cold_first_seek_ms: med(all.map((a) => a.cold.tSeek0)), cold_second_seek_ms: med(all.map((a) => a.cold.tSeek1)),
|
|
111
|
+
warm_ready_ms: med(all.flatMap((a) => a.warm.map((w) => w.tReady))), warm_first_seek_ms: med(all.flatMap((a) => a.warm.map((w) => w.tSeek0))),
|
|
112
|
+
cold_marks_ms_since_nav_median: phases,
|
|
113
|
+
warm_marks_ms_since_nav_median: Object.fromEntries(names.map((n) => [n, med(all.flatMap((a) => a.warm.map((w) => (w.marks.find((m) => m[0] === n) || [0, null])[1])).filter((v) => v !== null))])),
|
|
114
|
+
cold_resources_first_run: all[0].cold.res, cold_script_s: med(all.map((a) => a.cold.scriptS)), cold_task_s: med(all.map((a) => a.cold.taskS)),
|
|
115
|
+
errors: all.flatMap((a) => [...a.cold.logs, ...a.warm.flatMap((w) => w.logs)]).slice(0, 5),
|
|
116
|
+
};
|
|
117
|
+
const out = arg("out", "");
|
|
118
|
+
if (out) writeFileSync(out, JSON.stringify({ summary, all }, null, 1));
|
|
119
|
+
console.log(JSON.stringify(summary, null, 1));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Bakes (or verifies) crates/mosio/src/adapters/room-env-pmrem.json: the RoomEnvironment PMREM cube that mosio-three
|
|
2
|
+
// uploads instead of recomputing it on the software GPU (see bakedRoomEnv in mosio-three.js).
|
|
3
|
+
// node --conditions=source --experimental-transform-types scripts/3d-bake-room-env.mjs # write the file
|
|
4
|
+
// node --conditions=source --experimental-transform-types scripts/3d-bake-room-env.mjs --verify # exit 1 unless the committed file equals a fresh live computation
|
|
5
|
+
// Sandbox only (pinned Chromium on SwiftShader). Env: MOSIO_CHROME, MOSIO_HOME.
|
|
6
|
+
import { readFileSync, writeFileSync, mkdtempSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
import { tmpdir } from "node:os";
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { deflateRawSync, inflateRawSync } from "node:zlib";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
import { PreviewOrigin } from "../packages/runtime/src/node/preview-origin.ts";
|
|
13
|
+
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const { chromium } = require("playwright-core");
|
|
16
|
+
const repo = resolve(new URL("..", import.meta.url).pathname);
|
|
17
|
+
const home = process.env.MOSIO_HOME || "/opt/mosio";
|
|
18
|
+
const chrome = process.env.MOSIO_CHROME || require("node:child_process").execSync(`ls -d ${home}/browsers/chrome-headless-shell-*/chrome-headless-shell-*/chrome-headless-shell | head -1`).toString().trim();
|
|
19
|
+
const target = join(repo, "crates/mosio/src/adapters/room-env-pmrem.json");
|
|
20
|
+
const verify = process.argv.includes("--verify");
|
|
21
|
+
|
|
22
|
+
const dir = mkdtempSync(join(tmpdir(), "bake-env-"));
|
|
23
|
+
mkdirSync(join(dir, "scenes"));
|
|
24
|
+
writeFileSync(join(dir, "mosio.json"), JSON.stringify({ mosio: 0, name: "bake", width: 1280, height: 720, fps: 30, seed: 1, background: "#000", libraries: ["three@0.187.0", "mosio-three@0.1.0"], scenes: [{ id: "s", src: "scenes/s.html", frames: 1 }], output: { default: { codec: "h264", crf: 18, preset: "medium", pix_fmt: "yuv420p", gop_frames: 60 } } }));
|
|
25
|
+
writeFileSync(join(dir, "scenes/s.html"), `<!doctype html><html><head><script type="importmap">{"imports":{"three":"/_lib/three@0.187.0/build/three.module.js","three/addons/":"/_lib/three@0.187.0/examples/jsm/"}}</script></head><body><canvas id="c"></canvas>
|
|
26
|
+
<script type="module">import * as THREE from "three"; import { createStage } from "/_lib/mosio-three@0.1.0/mosio-three.js";
|
|
27
|
+
await createStage({ THREE, canvas: document.getElementById("c"), backend: "webgl", async setup(ctx) { await ctx.roomEnvironment(1); } });</script></body></html>`);
|
|
28
|
+
const po = new PreviewOrigin({ dir, runtimeJs: readFileSync(join(repo, "crates/mosio/src/runtime.js"), "utf8"), libDir: join(home, "lib"), embeddedLibs: new Map(["mosio-three.js", "room-env-pmrem.json"].filter((f) => f !== "room-env-pmrem.json" || process.env.NO_ROOM_ENV_FILE !== "1").map((f) => [`mosio-three@0.1.0/${f}`, readFileSync(join(repo, "crates/mosio/src/adapters", f), "utf8")])), timeoutMs: 120000, inlineProxy: false });
|
|
29
|
+
await po.start();
|
|
30
|
+
const browser = await chromium.launch({ executablePath: chrome, headless: true, args: ["--no-sandbox", "--disable-gpu", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--use-gl=angle", "--ignore-gpu-blocklist"] });
|
|
31
|
+
|
|
32
|
+
async function open(noBake) {
|
|
33
|
+
const page = await browser.newPage();
|
|
34
|
+
if (noBake) await page.addInitScript("window.__mosio3dNoBake = true");
|
|
35
|
+
await page.goto(`${po.documentOrigin()}/scenes/s.html?mosio_scene=s&mosio_nonce=bakenonce1`, { waitUntil: "commit" });
|
|
36
|
+
for (let i = 0; i < 4000 && !(await page.evaluate(() => !!window.__mosio).catch(() => false)); i++) await new Promise((r) => setTimeout(r, 5));
|
|
37
|
+
const ready = await page.evaluate(() => window.__mosio._ready());
|
|
38
|
+
if (!ready.ok) throw new Error("page not ready: " + JSON.stringify(ready));
|
|
39
|
+
return page;
|
|
40
|
+
}
|
|
41
|
+
// live compute, then read every (lod, face) plane back as half floats
|
|
42
|
+
const live = await open(true);
|
|
43
|
+
const out = await live.evaluate(() => {
|
|
44
|
+
const st = window.__mosio3d.stages[0], r = st.renderer, gl = r.getContext(), rt = st.targets[0];
|
|
45
|
+
if (st.roomEnvBaked) throw new Error("the live page used the baked data");
|
|
46
|
+
const size = rt.texture.mipmaps[0].width, lods = rt.texture.mipmaps.length, chunks = [];
|
|
47
|
+
for (let l = 0; l < lods; l++) for (let f = 0; f < 6; f++) {
|
|
48
|
+
const w = size >> l, f32 = new Float32Array(w * w * 4);
|
|
49
|
+
r.setRenderTarget(rt, f, l); gl.readPixels(0, 0, w, w, gl.RGBA, gl.FLOAT, f32);
|
|
50
|
+
chunks.push(new Uint16Array(new Float16Array(f32).buffer));
|
|
51
|
+
}
|
|
52
|
+
r.setRenderTarget(null);
|
|
53
|
+
const total = chunks.reduce((a, c) => a + c.length, 0), all = new Uint16Array(total); let o = 0;
|
|
54
|
+
for (const c of chunks) { all.set(c, o); o += c.length; }
|
|
55
|
+
let bin = ""; const u8 = new Uint8Array(all.buffer); for (let i = 0; i < u8.length; i += 8192) bin += String.fromCharCode(...u8.subarray(i, i + 8192));
|
|
56
|
+
return { three: st.THREE.REVISION, size, lods, b64: btoa(bin), ua: navigator.userAgent };
|
|
57
|
+
});
|
|
58
|
+
await live.close();
|
|
59
|
+
const bytes = Buffer.from(out.b64, "base64");
|
|
60
|
+
const meta = { three: out.three, chrome: /Chrome\/(\d+)/.exec(out.ua)[1], size: out.size, sigma: 0.04, lods: out.lods, raw_bytes: bytes.length, raw_sha256: createHash("sha256").update(bytes).digest("hex") };
|
|
61
|
+
if (!verify) {
|
|
62
|
+
writeFileSync(target, JSON.stringify({ meta, data: deflateRawSync(bytes, { level: 9 }).toString("base64") }) + "\n");
|
|
63
|
+
console.log("wrote", target, JSON.stringify(meta));
|
|
64
|
+
} else {
|
|
65
|
+
const cur = JSON.parse(readFileSync(target, "utf8"));
|
|
66
|
+
const same = JSON.stringify(cur.meta) === JSON.stringify(meta) && createHash("sha256").update(inflateRawSync(Buffer.from(cur.data, "base64"))).digest("hex") === meta.raw_sha256;
|
|
67
|
+
// and the baked page must really take the baked path and end up with the same bytes in its texture
|
|
68
|
+
const baked = await open(false);
|
|
69
|
+
const used = await baked.evaluate(() => window.__mosio3d.stages[0].roomEnvBaked);
|
|
70
|
+
await baked.close();
|
|
71
|
+
console.log(JSON.stringify({ file_equals_live: same, baked_path_used: used, meta }));
|
|
72
|
+
if (!same || !used) process.exitCode = 1;
|
|
73
|
+
}
|
|
74
|
+
await browser.close(); po.close();
|
package/scripts/3d-e2b-job.sh
CHANGED
|
@@ -39,6 +39,7 @@ cargo build --release --locked -q 2>&1 | tail -3
|
|
|
39
39
|
mkdir -p "$MOSIO_HOME/downloads"
|
|
40
40
|
scripts/gen-assets.sh 2>&1 | tail -1
|
|
41
41
|
scripts/gen-3d-assets.sh 2>&1 | tail -1
|
|
42
|
+
[ "$kind" = acceptance ] && { npm ci --no-audit --no-fund >/dev/null 2>&1 || echo "note: npm ci failed; env-bake will be skipped" >&2; }
|
|
42
43
|
id mosio >/dev/null 2>&1 || useradd -m mosio
|
|
43
44
|
chown -R mosio "$REPO"; chmod -R o+rX "$REPO"; mkdir -p "$TMP3D"; chmod 777 "$TMP3D"
|
|
44
45
|
case "$kind" in
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Synthetic heavy 3D project for first-attach profiling (not a committed fixture; written to the given directory).
|
|
3
|
+
A stand-in for a textured museum-style model: 8 PBR materials (4096x4096 JPEG base colour + normal, 2048x2048
|
|
4
|
+
metal/rough), 8 UV spheres, room environment and a shadow-casting key light. Needs ffmpeg.
|
|
5
|
+
python3 scripts/3d-gen-heavy-fixture.py /tmp/var/heavy
|
|
6
|
+
"""
|
|
7
|
+
import json, math, os, shutil, struct, subprocess, sys
|
|
8
|
+
out = sys.argv[1]
|
|
9
|
+
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
10
|
+
shutil.rmtree(out, ignore_errors=True)
|
|
11
|
+
shutil.copytree(os.path.join(REPO, "fixtures/3d/t1-turntable"), out)
|
|
12
|
+
shutil.rmtree(os.path.join(out, "assets"), ignore_errors=True)
|
|
13
|
+
os.makedirs(os.path.join(out, "assets"))
|
|
14
|
+
N = 8
|
|
15
|
+
|
|
16
|
+
def jpeg(i, kind, size):
|
|
17
|
+
p = f"/tmp/heavy-{kind}-{i}.jpg"
|
|
18
|
+
src = {"c": f"testsrc2=size={size}x{size}:rate=1,hue=h={i * 40}", "n": f"gradients=size={size}x{size}:rate=1:seed={i + 1}", "o": f"gradients=size={size}x{size}:rate=1:seed={i + 50}"}[kind]
|
|
19
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-f", "lavfi", "-i", src, "-vf", "noise=alls=12:allf=t", "-frames:v", "1", "-q:v", "3", p], check=True)
|
|
20
|
+
return open(p, "rb").read()
|
|
21
|
+
|
|
22
|
+
def sphere(r, seg_u=96, seg_v=48):
|
|
23
|
+
pos, nor, uv, idx = [], [], [], []
|
|
24
|
+
for v in range(seg_v + 1):
|
|
25
|
+
for u in range(seg_u + 1):
|
|
26
|
+
th, ph = 2 * math.pi * u / seg_u, math.pi * v / seg_v
|
|
27
|
+
x, y, z = math.cos(th) * math.sin(ph), math.cos(ph), math.sin(th) * math.sin(ph)
|
|
28
|
+
pos += [r * x, r * y, r * z]; nor += [x, y, z]; uv += [u / seg_u, v / seg_v]
|
|
29
|
+
for v in range(seg_v):
|
|
30
|
+
for u in range(seg_u):
|
|
31
|
+
a = v * (seg_u + 1) + u; b = a + seg_u + 1
|
|
32
|
+
idx += [a, b, a + 1, b, b + 1, a + 1]
|
|
33
|
+
return pos, nor, uv, idx
|
|
34
|
+
|
|
35
|
+
bin_, views, accs, imgs, texs, mats, meshes, nodes = bytearray(), [], [], [], [], [], [], []
|
|
36
|
+
def view(data, target=None):
|
|
37
|
+
while len(bin_) % 4: bin_.append(0)
|
|
38
|
+
views.append({"buffer": 0, "byteOffset": len(bin_), "byteLength": len(data), **({"target": target} if target else {})})
|
|
39
|
+
bin_.extend(data); return len(views) - 1
|
|
40
|
+
def acc(arr, fmt, ctype, typ, target, minmax=False):
|
|
41
|
+
data = struct.pack(f"<{len(arr)}{fmt}", *arr)
|
|
42
|
+
a = {"bufferView": view(data, target), "componentType": ctype, "count": len(arr) // {"VEC3": 3, "VEC2": 2, "SCALAR": 1}[typ], "type": typ}
|
|
43
|
+
if minmax: a["min"] = [min(arr[i::3]) for i in range(3)]; a["max"] = [max(arr[i::3]) for i in range(3)]
|
|
44
|
+
accs.append(a); return len(accs) - 1
|
|
45
|
+
def image(data):
|
|
46
|
+
imgs.append({"bufferView": view(data), "mimeType": "image/jpeg"}); texs.append({"source": len(imgs) - 1}); return len(texs) - 1
|
|
47
|
+
for i in range(N):
|
|
48
|
+
bc, nm, mr = image(jpeg(i, "c", 4096)), image(jpeg(i, "n", 4096)), image(jpeg(i, "o", 2048))
|
|
49
|
+
mats.append({"name": f"m{i}", "pbrMetallicRoughness": {"baseColorTexture": {"index": bc}, "metallicRoughnessTexture": {"index": mr}, "metallicFactor": 1, "roughnessFactor": 1}, "normalTexture": {"index": nm}})
|
|
50
|
+
p, n, t, ix = sphere(0.045)
|
|
51
|
+
meshes.append({"name": f"s{i}", "primitives": [{"attributes": {"POSITION": acc(p, "f", 5126, "VEC3", 34962, True), "NORMAL": acc(n, "f", 5126, "VEC3", 34962), "TEXCOORD_0": acc(t, "f", 5126, "VEC2", 34962)}, "indices": acc(ix, "I", 5125, "SCALAR", 34963), "material": i}]})
|
|
52
|
+
nodes.append({"name": f"sphere{i}", "mesh": i, "translation": [(i % 4 - 1.5) * 0.11, 0.05 + (i // 4) * 0.11, 0]})
|
|
53
|
+
while len(bin_) % 4: bin_.append(0)
|
|
54
|
+
gltf = {"asset": {"version": "2.0"}, "scene": 0, "scenes": [{"nodes": list(range(N))}], "nodes": nodes, "meshes": meshes, "materials": mats, "textures": texs, "images": imgs,
|
|
55
|
+
"accessors": accs, "bufferViews": views, "buffers": [{"byteLength": len(bin_)}]}
|
|
56
|
+
js = json.dumps(gltf, separators=(",", ":")).encode()
|
|
57
|
+
js += b" " * (-len(js) % 4)
|
|
58
|
+
glb = struct.pack("<4sII", b"glTF", 2, 12 + 8 + len(js) + 8 + len(bin_)) + struct.pack("<I4s", len(js), b"JSON") + js + struct.pack("<I4s", len(bin_), b"BIN\0") + bytes(bin_)
|
|
59
|
+
open(os.path.join(out, "assets/heavy.glb"), "wb").write(glb)
|
|
60
|
+
m = json.load(open(os.path.join(out, "mosio.json"))); m["name"] = "heavy"; m["assets"] = ["assets/heavy.glb"]; json.dump(m, open(os.path.join(out, "mosio.json"), "w"), indent=1)
|
|
61
|
+
h = os.path.join(out, "scenes/turntable.html")
|
|
62
|
+
s = open(h).read().replace("/assets/speaker.glb", "/assets/heavy.glb").replace('prefix: "speaker"', 'prefix: "heavy"')
|
|
63
|
+
s = s.replace("c.position.set(0, 0.12 + 0.015 * Math.sin(t * 1.3), 0.52);\n c.lookAt(0, 0.075, 0);", "c.position.set(0, 0.11, 0.62);\n c.lookAt(0, 0.11, 0);").replace("ctx.model.rotation.y = (t / 4) * Math.PI * 2;", "ctx.model.rotation.y = 0.0;")
|
|
64
|
+
open(h, "w").write(s)
|
|
65
|
+
print(f"heavy fixture: {out}, glb {len(glb) / 1e6:.1f} MB, {N} materials")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Summarise a Chromium trace written by scripts/3d-attach-bench.mjs (BENCH_TRACE): the longest events per process/thread."""
|
|
3
|
+
import json, sys, collections
|
|
4
|
+
d = json.load(open(sys.argv[1])); ev = d["traceEvents"] if isinstance(d, dict) else d
|
|
5
|
+
names = {}
|
|
6
|
+
for e in ev:
|
|
7
|
+
if e.get("ph") == "M" and e["name"] in ("process_name", "thread_name"): names[(e["pid"], e["tid"] if e["name"] == "thread_name" else 0, e["name"])] = e["args"]["name"]
|
|
8
|
+
pn = lambda p: names.get((p, 0, "process_name"), str(p)); tn = lambda p, t: names.get((p, t, "thread_name"), str(t))
|
|
9
|
+
agg = collections.defaultdict(lambda: [0, 0])
|
|
10
|
+
for e in ev:
|
|
11
|
+
if e.get("ph") == "X" and e.get("dur", 0) > 0:
|
|
12
|
+
k = (pn(e["pid"]), tn(e["pid"], e["tid"]), e["name"]); agg[k][0] += e["dur"] / 1000; agg[k][1] += 1
|
|
13
|
+
for k, (ms, n) in sorted(agg.items(), key=lambda kv: -kv[1][0])[: int(sys.argv[2]) if len(sys.argv) > 2 else 40]:
|
|
14
|
+
print(f"{ms:9.1f} ms x{n:<5} {k[0]} / {k[1]} / {k[2]}")
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Camera readability checks of `mosio inspect` (docs/CLI.md "Camera checks"), run as root in the sandbox; Mosio runs as `mosio`.
|
|
3
|
+
# camera-inspect-1 fixtures/camera-inspect: the clean scene has no W_CAMERA_* finding, and every other scene has exactly the
|
|
4
|
+
# one code it was built to trigger (read time, text cut, move speed, motion behind text, shake, empty edges)
|
|
5
|
+
# camera-inspect-2 fixtures/camera-inspect-vertical (9:16): the clean tour has none, the text in the top band is W_CAMERA_SAFE_ZONE
|
|
6
|
+
# camera-inspect-3 every camera finding names its scene, shot, time range and a numeric fix, and points at the source
|
|
7
|
+
# camera-inspect-4 deterministic: a second run gives identical camera findings
|
|
8
|
+
set -uo pipefail
|
|
9
|
+
REPO="$(cd "$(dirname "$0")/../.." && pwd)"; cd "$REPO"
|
|
10
|
+
W=/home/mosio/acc-camera-inspect; F="$REPO/fixtures"
|
|
11
|
+
[ -x target/release/mosio ] || cargo build --release --locked 2>&1 | tail -1
|
|
12
|
+
chmod -R o+rX "$REPO"
|
|
13
|
+
u() { scripts/as-user.sh "$1"; }
|
|
14
|
+
u "rm -rf $W && mkdir -p $W"
|
|
15
|
+
fails=0
|
|
16
|
+
cam='[.findings[]|select(.code|startswith("W_CAMERA_"))]'
|
|
17
|
+
u "mosio inspect $F/camera-inspect --timeout-ms 5000 -o $W/a > $W/a.json 2> $W/a.err"
|
|
18
|
+
u "mosio inspect $F/camera-inspect-vertical --timeout-ms 5000 -o $W/v > $W/v.json 2> $W/v.err"
|
|
19
|
+
u "mosio inspect $F/camera-inspect --timeout-ms 5000 -o $W/a2 > $W/a2.json 2> $W/a2.err"
|
|
20
|
+
check() { # json scene expected-codes (sorted, comma separated, empty for none)
|
|
21
|
+
got=$(jq -r --arg s "$2" "[$cam[]|select(.scene==\$s)|.code]|unique|join(\",\")" "$1")
|
|
22
|
+
if [ "$got" = "$3" ]; then echo " $2: ${got:-no camera findings}"; else fails=$((fails+1)); echo " $2: got '$got', expected '$3'"; fi
|
|
23
|
+
}
|
|
24
|
+
check $W/a.json good ""
|
|
25
|
+
check $W/a.json read W_CAMERA_READ_TIME
|
|
26
|
+
check $W/a.json cut W_CAMERA_TEXT_CUT
|
|
27
|
+
check $W/a.json speed W_CAMERA_MOVE_SPEED
|
|
28
|
+
check $W/a.json behind W_CAMERA_MOTION_BEHIND_TEXT
|
|
29
|
+
check $W/a.json shake W_CAMERA_SHAKE
|
|
30
|
+
check $W/a.json edges W_CAMERA_EMPTY_EDGES
|
|
31
|
+
check $W/v.json good ""
|
|
32
|
+
check $W/v.json safe W_CAMERA_SAFE_ZONE
|
|
33
|
+
# the shake scene has both a long shake and a repeated one
|
|
34
|
+
n=$(jq -r '[.findings[]|select(.code=="W_CAMERA_SHAKE")|.reason]|sort|join(",")' $W/a.json)
|
|
35
|
+
[ "$n" = "long,repeated" ] || { fails=$((fails+1)); echo " shake reasons: '$n', expected long,repeated"; }
|
|
36
|
+
# inspect-level: no error findings and no skipped pass
|
|
37
|
+
for j in a v; do
|
|
38
|
+
e=$(jq '.errors' $W/$j.json); k=$(jq '[.findings[]|select(.code=="W_CAMERA_SKIPPED")]|length' $W/$j.json)
|
|
39
|
+
[ "$e" = 0 ] && [ "$k" = 0 ] || { fails=$((fails+1)); echo " $j: errors=$e skipped=$k: $(jq -c '[.findings[]|select(.severity=="error" or .code=="W_CAMERA_SKIPPED")|{code,scene,detail}]' $W/$j.json | head -c 600)"; }
|
|
40
|
+
done
|
|
41
|
+
# actionable fields
|
|
42
|
+
bad=$(jq -s "[.[]|$cam[]|select((.shot|type)!=\"number\" or (.range_s|length)!=2 or (.fix|test(\"[0-9]\")|not) or (.fix_options|length)==0 or (.at|type)!=\"string\" or (.camera_at|type)!=\"string\")]|length" $W/a.json $W/v.json)
|
|
43
|
+
[ "$bad" = 0 ] && echo " every camera finding has shot, range_s, a numeric fix, fix_options and its source" || { fails=$((fails+1)); echo " $bad camera findings lack shot, range_s, a numeric fix or a source"; }
|
|
44
|
+
# deterministic
|
|
45
|
+
d1=$(jq -S "$cam|map(del(.evidence_image))" $W/a.json | sha256sum); d2=$(jq -S "$cam|map(del(.evidence_image))" $W/a2.json | sha256sum)
|
|
46
|
+
[ "$d1" = "$d2" ] && echo " second run: identical camera findings" || { fails=$((fails+1)); echo " camera findings differ between two runs"; }
|
|
47
|
+
echo " $(jq -c "[$cam[]|{code,scene,shot,range_s,fix}]" $W/a.json $W/v.json | head -c 4000)"
|
|
48
|
+
[ $fails = 0 ] && echo "== camera-inspect PASS" || echo "== camera-inspect FAIL"
|
|
49
|
+
[ $fails = 0 ]
|
|
@@ -40,10 +40,12 @@ u "cd $W && mosio render w7-alpha --no-cache -o out/alpha.mov > alpha.json && py
|
|
|
40
40
|
jq -e .ok "$W/alpha.check.json" >/dev/null && R[export-4]=PASS || R[export-4]=FAIL
|
|
41
41
|
echo " alpha: $(cat $W/alpha.check.json 2>/dev/null) $(jq -r .error $W/alpha.json 2>/dev/null | grep -v null | head -c 300)"
|
|
42
42
|
|
|
43
|
-
# A5 crash recovery: kill one renderer process while W1 renders; compare with a clean render
|
|
44
|
-
|
|
43
|
+
# A5 crash recovery: kill one renderer process while W1 renders; compare with a clean render. One worker: the kill comes
|
|
44
|
+
# after 2 s and needs a render that is still running then (parallel slices finish sooner; hardening-2 injects a crash
|
|
45
|
+
# into a parallel render)
|
|
46
|
+
u "cd $W && mosio render w1-kinetic --no-cache --workers 1 -o out/w1-clean.mp4 > w1-clean.json"
|
|
45
47
|
# wait on the render's PID (a `pgrep -f "mosio render"` loop matched its own shell and never ended)
|
|
46
|
-
u "cd $W && { mosio render w1-kinetic --no-cache -o out/w1-crash.mp4 > w1-crash.json 2>&1 & pid=\$!; sleep 2; pkill -KILL -u mosio -f -n -- '--type=renderer' && echo killed-one-renderer; wait \$pid; }"
|
|
48
|
+
u "cd $W && { mosio render w1-kinetic --no-cache --workers 1 -o out/w1-crash.mp4 > w1-crash.json 2>&1 & pid=\$!; sleep 2; pkill -KILL -u mosio -f -n -- '--type=renderer' && echo killed-one-renderer; wait \$pid; }"
|
|
47
49
|
u "cd $W && mosio oracle compare out/w1-clean.frames.json out/w1-crash.frames.json > w1-crash.cmp.json"
|
|
48
50
|
if jq -e .equal "$W/w1-crash.cmp.json" >/dev/null && jq -e '.ok and .profile.retries >= 1' "$W/w1-crash.json" >/dev/null; then R[export-5]=PASS; else R[export-5]=FAIL; fi
|
|
49
51
|
echo " crash: render ok=$(jq -r .ok $W/w1-crash.json) retries=$(jq -r .profile.retries $W/w1-crash.json) cmp=$(jq -c '{equal,mismatched_frames}' $W/w1-crash.cmp.json) $(jq -r .error $W/w1-crash.json | grep -v null | head -c 300)"
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
# E_CANCELLED + exit 130, never a crash code; no staged files, temp dirs or children
|
|
12
12
|
# hardening-8 cancel latency in a blocking wait: SIGTERM while a page waits on a font held back 60 s by the asset
|
|
13
13
|
# origin; mosio must exit with E_CANCELLED within 1.5 s (CDP waits poll the token every 50 ms)
|
|
14
|
+
# hardening-9 SIGTERM while one scene renders on two pages (after its first progress event): as hardening-5
|
|
15
|
+
# hardening-10 SIGKILL while one scene renders on two pages: as hardening-6
|
|
14
16
|
set -uo pipefail
|
|
15
17
|
REPO="$(cd "$(dirname "$0")/../.." && pwd)"; cd "$REPO"
|
|
16
18
|
W=/home/mosio/acc-hardening; F="$REPO/fixtures"
|
|
@@ -25,6 +27,8 @@ temps() { find /tmp -maxdepth 1 -user mosio \( -name 'mosio-work-*' -o -name 'mo
|
|
|
25
27
|
wait_procs_gone() { for _ in $(seq 1 100); do [ "$(procs)" = 0 ] && return 0; sleep 0.05; done; return 1; }
|
|
26
28
|
declare -A R
|
|
27
29
|
u "rm -rf $W && mkdir -p $W && cp -r $F/w1-kinetic $W/w1 && cp -r $F/w4-effects $W/w4"
|
|
30
|
+
# a 20 s copy of w1 for the parallel signal checks: one scene, so its run is split over pages
|
|
31
|
+
u "cp -r $W/w1 $W/w1long && jq '.scenes[0].frames = 600' $W/w1/mosio.json > $W/w1long/mosio.json"
|
|
28
32
|
find /tmp -maxdepth 1 -user mosio -name 'mosio-*' -exec rm -rf {} + 2>/dev/null
|
|
29
33
|
|
|
30
34
|
# H1: crash in `frames` (no retry): fail fast with the typed code
|
|
@@ -65,16 +69,19 @@ u "cd $W && mosio render w4 --workers 1 -o out/w4.mp4 > h4.json && mosio oracle
|
|
|
65
69
|
if jq -e '.ok and .segments_reused >= 1 and .segments_rendered >= 1' $W/h4.json >/dev/null && jq -e .equal $W/h4.cmp.json >/dev/null; then R[hardening-4]=PASS; else R[hardening-4]=FAIL; fi
|
|
66
70
|
echo " H4: cancelled=$(jq -r .code $W/h4-cancel.json) then reused=$(jq -r .segments_reused $W/h4.json) rendered=$(jq -r .segments_rendered $W/h4.json) equal=$(jq -r .equal $W/h4.cmp.json)"
|
|
67
71
|
|
|
68
|
-
# H5: external SIGTERM
|
|
69
|
-
|
|
72
|
+
# H5: external SIGTERM mid-render, one worker. The signal waits for the first progress event (a frame is encoded) on
|
|
73
|
+
# the 20 s copy, not a fixed sleep: a fast render could otherwise finish before it
|
|
74
|
+
u "cd $W && { mosio render w1long --no-cache --workers 1 --progress jsonl -o out/w1-term.mp4 > h5.json 2> h5.jsonl & pid=\$!;
|
|
75
|
+
for t in \$(seq 1 1200); do grep -q '\"progress\"' h5.jsonl 2>/dev/null && break; sleep 0.05; done;
|
|
76
|
+
date +%s.%N > h5.t0; kill -TERM \$pid; wait \$pid; echo \$? > h5.rc; date +%s.%N > h5.t1; }"
|
|
70
77
|
wait_procs_gone; t2=$(now)
|
|
71
78
|
rc=$(cat $W/h5.rc); code=$(jq -r .code $W/h5.json 2>/dev/null); left=$(procs); tmp=$(temps)
|
|
72
79
|
exit_ms=$(ms "$(cat $W/h5.t0)" "$(cat $W/h5.t1)"); gone_ms=$(ms "$(cat $W/h5.t0)" "$t2")
|
|
73
80
|
if [ "$rc" = 130 ] && [ "$code" = E_CANCELLED ] && [ "$left" = 0 ] && [ "$tmp" = 0 ] && [ ! -e $W/out/w1-term.mp4 ] && [ "$exit_ms" -lt 3000 ]; then R[hardening-5]=PASS; else R[hardening-5]=FAIL; fi
|
|
74
81
|
echo " H5: rc=$rc code=$code exit_ms=$exit_ms all_children_gone_ms=$gone_ms temp_dirs=$tmp partial_output=$([ -e $W/out/w1-term.mp4 ] && echo YES || echo no)"
|
|
75
82
|
|
|
76
|
-
# H6: SIGKILL: children must not outlive mosio; the next run removes the stale temp dirs
|
|
77
|
-
u "cd $W && { mosio render w1 --no-cache -o out/w1-kill.mp4 > /dev/null 2>&1 & pid=\$!; sleep 3; kill -KILL \$pid; wait \$pid 2>/dev/null; true; }"
|
|
83
|
+
# H6: SIGKILL: children must not outlive mosio; the next run removes the stale temp dirs (one worker, as H5)
|
|
84
|
+
u "cd $W && { mosio render w1 --no-cache --workers 1 -o out/w1-kill.mp4 > /dev/null 2>&1 & pid=\$!; sleep 3; kill -KILL \$pid; wait \$pid 2>/dev/null; true; }"
|
|
78
85
|
t0=$(now); wait_procs_gone; t1=$(now); left=$(procs); stale=$(temps)
|
|
79
86
|
u "cd $W && mosio render w4 --workers 1 -o out/w4-after.mp4 > h6-next.json 2>&1"
|
|
80
87
|
after=$(temps)
|
|
@@ -120,9 +127,33 @@ h8_ms=$(cat $W/h8.ms); code=$(jq -r .code $W/h8.json 2>/dev/null)
|
|
|
120
127
|
if [ "$code" = E_CANCELLED ] && [ "$(cat $W/h8.rc)" = 130 ] && [ "$h8_ms" -lt 1500 ] && [ "$(procs)" = 0 ]; then R[hardening-8]=PASS; else R[hardening-8]=FAIL; fi
|
|
121
128
|
echo " H8: blocked in the font barrier; SIGTERM -> exit in ${h8_ms} ms code=$code rc=$(cat $W/h8.rc)"
|
|
122
129
|
|
|
123
|
-
|
|
130
|
+
# H9/H10: SIGTERM and SIGKILL while one scene renders on two pages. The signal waits for the first progress event (a
|
|
131
|
+
# frame is encoded) instead of a fixed sleep; the plan event must report two workers, so both pages were working.
|
|
132
|
+
par_run() { # $1 = signal, $2 = name
|
|
133
|
+
u "cd $W && { MOSIO_RUN_PAGES=2 mosio render w1long --no-cache --workers 2 --progress jsonl -o out/$2.mp4 > $2.json 2> $2.jsonl & m=\$!;
|
|
134
|
+
for t in \$(seq 1 1200); do grep -q '\"progress\"' $2.jsonl 2>/dev/null && break; sleep 0.05; done;
|
|
135
|
+
date +%s.%N > $2.t0; kill -$1 \$m; wait \$m 2>/dev/null; echo \$? > $2.rc; date +%s.%N > $2.t1; true; }"
|
|
136
|
+
}
|
|
137
|
+
par_run TERM h9
|
|
138
|
+
wait_procs_gone; t2=$(now)
|
|
139
|
+
rc=$(cat $W/h9.rc); code=$(jq -r .code $W/h9.json 2>/dev/null); left=$(procs); tmp=$(temps)
|
|
140
|
+
pw=$(grep '"plan"' $W/h9.jsonl | head -1 | jq -r .workers 2>/dev/null)
|
|
141
|
+
exit_ms=$(ms "$(cat $W/h9.t0)" "$(cat $W/h9.t1)")
|
|
142
|
+
if [ "$pw" = 2 ] && [ "$rc" = 130 ] && [ "$code" = E_CANCELLED ] && [ "$left" = 0 ] && [ "$tmp" = 0 ] && [ ! -e $W/out/h9.mp4 ] && [ "$exit_ms" -lt 3000 ]; then R[hardening-9]=PASS; else R[hardening-9]=FAIL; fi
|
|
143
|
+
echo " H9: plan_workers=$pw rc=$rc code=$code exit_ms=$exit_ms all_children_gone_ms=$(ms "$(cat $W/h9.t0)" "$t2") temp_dirs=$tmp partial_output=$([ -e $W/out/h9.mp4 ] && echo YES || echo no)"
|
|
144
|
+
|
|
145
|
+
find /tmp -maxdepth 1 -user mosio -name 'mosio-*' -exec rm -rf {} + 2>/dev/null
|
|
146
|
+
par_run KILL h10
|
|
147
|
+
t0=$(now); wait_procs_gone; t1=$(now); left=$(procs); stale=$(temps)
|
|
148
|
+
pw=$(grep '"plan"' $W/h10.jsonl | head -1 | jq -r .workers 2>/dev/null)
|
|
149
|
+
u "cd $W && mosio render w4 --workers 1 -o out/w4-after10.mp4 > h10-next.json 2>&1"
|
|
150
|
+
after=$(temps)
|
|
151
|
+
if [ "$pw" = 2 ] && [ "$left" = 0 ] && [ "$stale" -ge 1 ] && [ "$after" = 0 ] && [ ! -e $W/out/h10.mp4 ] && jq -e .ok $W/h10-next.json >/dev/null; then R[hardening-10]=PASS; else R[hardening-10]=FAIL; fi
|
|
152
|
+
echo " H10: plan_workers=$pw children_gone_after_kill_ms=$(ms $t0 $t1) left=$left stale_temp_dirs=$stale after_next_run=$after next_ok=$(jq -r .ok $W/h10-next.json)"
|
|
153
|
+
|
|
154
|
+
for k in hardening-1 hardening-2 hardening-3 hardening-4 hardening-5 hardening-6 hardening-7 hardening-8 hardening-9 hardening-10; do echo "== $k ${R[$k]}"; done
|
|
124
155
|
jq -n '$ARGS.named' --arg H1 "${R[hardening-1]}" --arg H2 "${R[hardening-2]}" --arg H3 "${R[hardening-3]}" \
|
|
125
156
|
--arg H4 "${R[hardening-4]}" --arg H5 "${R[hardening-5]}" --arg H6 "${R[hardening-6]}" \
|
|
126
|
-
--arg H7 "${R[hardening-7]}" --arg H8 "${R[hardening-8]}" > /tmp/acc-hardening.json
|
|
157
|
+
--arg H7 "${R[hardening-7]}" --arg H8 "${R[hardening-8]}" --arg H9 "${R[hardening-9]}" --arg H10 "${R[hardening-10]}" > /tmp/acc-hardening.json
|
|
127
158
|
cp /tmp/acc-hardening.json $W/summary.json
|
|
128
159
|
! grep -q FAIL $W/summary.json
|