@threenative/playtest 0.3.2 → 0.3.4
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/dist/capture.d.ts +7 -0
- package/dist/{diagnostics-f8464bJw.d.ts → diagnostics-BXhYI2sc.d.ts} +431 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +459 -90
- package/dist/protocol.d.ts +39 -1
- package/dist/protocol.js +2 -1
- package/dist/runner/cli.d.ts +2 -2
- package/dist/runner/cli.js +2016 -591
- package/dist/runner/index.d.ts +86 -242
- package/dist/runner/index.js +2891 -1701
- package/dist/{shared-BGwYk5HG.d.ts → shared-CHIDDJpp.d.ts} +46 -5
- package/dist/three/index.d.ts +10 -1
- package/dist/three/index.js +15 -7
- package/package.json +1 -1
package/dist/runner/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFile, access, mkdir, writeFile, mkdtemp, readdir,
|
|
3
|
-
import { resolve, dirname, join, basename, extname, isAbsolute, relative } from 'path';
|
|
2
|
+
import { readFile, access, mkdir, writeFile, stat, mkdtemp, readdir, rm, rename, unlink, rmdir, copyFile } from 'fs/promises';
|
|
3
|
+
import path, { resolve, dirname, join, basename, extname, isAbsolute, relative } from 'path';
|
|
4
4
|
import { PNG } from 'pngjs';
|
|
5
5
|
import { existsSync, realpathSync, createWriteStream, readdirSync, rmSync, readFileSync } from 'fs';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
|
+
import { createHash } from 'crypto';
|
|
7
8
|
import { tmpdir, homedir } from 'os';
|
|
8
9
|
import { execFile, spawn, execFileSync, spawnSync } from 'child_process';
|
|
9
10
|
import { createRequire } from 'module';
|
|
@@ -87,11 +88,11 @@ function resolveDiagnosticsPolicy(policy, target) {
|
|
|
87
88
|
...policy?.runtimeDiagnosticsOptOutReason === void 0 ? {} : { runtimeDiagnosticsOptOutReason: policy.runtimeDiagnosticsOptOutReason }
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
|
-
function trivialAssertionDiagnostic(id,
|
|
91
|
+
function trivialAssertionDiagnostic(id, path2, before, sourcePath) {
|
|
91
92
|
return {
|
|
92
93
|
code: "TN_PLAYTEST_ASSERTION_TRIVIAL",
|
|
93
|
-
message: `Assertion '${id}'${
|
|
94
|
-
path,
|
|
94
|
+
message: `Assertion '${id}'${path2 === void 0 ? "" : ` at path '${path2}'`} was already satisfied before the scenario ran (value ${JSON.stringify(before)}).`,
|
|
95
|
+
path: path2,
|
|
95
96
|
severity: "error",
|
|
96
97
|
...sourcePath === void 0 ? {} : { sourcePath },
|
|
97
98
|
suggestion: "Drive the asserted value from a failing initial state, or assert changed:true. If the value is genuinely a held invariant, allowTrivial takes the reason it is held \u2014 it is recorded in the report and counted against the run."
|
|
@@ -152,7 +153,7 @@ function pathAssertionDiagnostic(kind, assertion, before, after, context) {
|
|
|
152
153
|
suggestion: unchanged ? `${kind === "hud" ? "Observed HUD value" : "Observed resource value"} did not change during the scenario. Inspect effect-log.json for the owning system's resource writes, run tn build --project . --json for undeclared writes, and check whether duplicate/stale systems or route/collision setup prevented the state transition.` : kind === "hud" ? "Check UI binding IDs and whether the backing resource changes during the scenario." : "Check resource IDs, script writes, and assertion path spelling."
|
|
153
154
|
};
|
|
154
155
|
}
|
|
155
|
-
function summarizeResourceEffectLog(effectLog, resourceId,
|
|
156
|
+
function summarizeResourceEffectLog(effectLog, resourceId, path2) {
|
|
156
157
|
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
157
158
|
return void 0;
|
|
158
159
|
}
|
|
@@ -166,7 +167,7 @@ function summarizeResourceEffectLog(effectLog, resourceId, path) {
|
|
|
166
167
|
if (typeof entry.system === "string") {
|
|
167
168
|
systems.add(entry.system);
|
|
168
169
|
}
|
|
169
|
-
values.add(shortJson(readPath(entry.value,
|
|
170
|
+
values.add(shortJson(readPath(entry.value, path2)));
|
|
170
171
|
}
|
|
171
172
|
return {
|
|
172
173
|
distinctValues: Array.from(values).slice(0, 3).join(", "),
|
|
@@ -206,11 +207,11 @@ function runtimeDiagnosticsSnapshot(value) {
|
|
|
206
207
|
function consoleErrors(entries) {
|
|
207
208
|
return entries.filter((entry) => entry.type === "error" || entry.type === "assert" || entry.type === "pageerror");
|
|
208
209
|
}
|
|
209
|
-
function readPath(value,
|
|
210
|
-
if (
|
|
210
|
+
function readPath(value, path2) {
|
|
211
|
+
if (path2 === void 0 || path2.length === 0) {
|
|
211
212
|
return value;
|
|
212
213
|
}
|
|
213
|
-
return
|
|
214
|
+
return path2.split(".").reduce((current, part) => {
|
|
214
215
|
if (Array.isArray(current) && /^(0|[1-9]\d*)$/u.test(part)) {
|
|
215
216
|
return current[Number(part)];
|
|
216
217
|
}
|
|
@@ -263,7 +264,24 @@ function formatNumber(value) {
|
|
|
263
264
|
return Number.isInteger(value) ? String(value) : value.toFixed(3);
|
|
264
265
|
}
|
|
265
266
|
function jsonEqual(left, right) {
|
|
266
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
267
|
+
return JSON.stringify(sortedKeys(left)) === JSON.stringify(sortedKeys(right));
|
|
268
|
+
}
|
|
269
|
+
function sortedKeys(value) {
|
|
270
|
+
if (Array.isArray(value)) {
|
|
271
|
+
return value.map(sortedKeys);
|
|
272
|
+
}
|
|
273
|
+
if (!isRecord(value)) {
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
const prototype = Object.getPrototypeOf(value);
|
|
277
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
const sorted = {};
|
|
281
|
+
for (const key of Object.keys(value).sort()) {
|
|
282
|
+
sorted[key] = sortedKeys(value[key]);
|
|
283
|
+
}
|
|
284
|
+
return sorted;
|
|
267
285
|
}
|
|
268
286
|
function isRecord(value) {
|
|
269
287
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -288,6 +306,9 @@ function requiredPlaytestCapabilities(scenario, target) {
|
|
|
288
306
|
if (scenario.steps.some((step) => step.kind === "aimAt")) {
|
|
289
307
|
required.add("entity.setup");
|
|
290
308
|
}
|
|
309
|
+
if (scenario.assert?.geometry !== void 0) {
|
|
310
|
+
required.add("runtime.geometry");
|
|
311
|
+
}
|
|
291
312
|
if (scenario.artifacts?.screenshots !== false) {
|
|
292
313
|
required.add("browser.screenshot");
|
|
293
314
|
}
|
|
@@ -623,14 +644,16 @@ var init_assertion_schema = __esm({
|
|
|
623
644
|
trivialityRationale: "It evaluates captured error and readiness channels across the run; no initial scalar value can satisfy those diagnostics by itself."
|
|
624
645
|
},
|
|
625
646
|
{
|
|
626
|
-
description: "Proves a live render sample exists and optionally bounds frame time, an fps floor, per-phase frame budget, draw calls
|
|
627
|
-
example: { performance: { maxPhaseMsP95: { render: 12 }, minFps: 30 } },
|
|
647
|
+
description: "Proves a live render sample exists and optionally bounds frame time, an fps floor, per-phase frame budget, whole-frame or per-pass draw calls and triangles.",
|
|
648
|
+
example: { performance: { maxPassDrawCalls: { shadow: 400 }, maxPhaseMsP95: { render: 12 }, minFps: 30 } },
|
|
628
649
|
fields: [
|
|
629
650
|
{ description: "Maximum nearest-rank 95th-percentile frame time in milliseconds.", name: "maxFrameMsP95", type: "number" },
|
|
630
651
|
{ description: "Minimum sustained frames per second, from the median sampled frame.", name: "minFps", type: "number" },
|
|
631
652
|
{ description: "Per-phase millisecond ceilings at nearest-rank p95. Phases: hostGap, update, render, overlay, residual.", name: "maxPhaseMsP95", type: "{ [phase]: number }" },
|
|
632
|
-
{ description: "Maximum observed renderer draw-call count.", name: "maxDrawCalls", type: "number" },
|
|
633
|
-
{ description: "
|
|
653
|
+
{ description: "Maximum observed renderer draw-call count across every pass combined.", name: "maxDrawCalls", type: "number" },
|
|
654
|
+
{ description: "Per-pass draw-call ceilings, keyed by pass kind: main, shadow, reflection, nested. Fails closed when a sampled frame carries no pass split or omits the declared kind.", name: "maxPassDrawCalls", type: "{ [pass: 'main' | 'shadow' | 'reflection' | 'nested']: number }" },
|
|
655
|
+
{ description: "Per-pass triangle ceilings, keyed by pass kind: main, shadow, reflection, nested. Fails closed when a sampled frame carries no pass split or omits the declared kind.", name: "maxPassTriangles", type: "{ [pass: 'main' | 'shadow' | 'reflection' | 'nested']: number }" },
|
|
656
|
+
{ description: "Maximum observed renderer triangle count across every pass combined.", name: "maxTriangles", type: "number" }
|
|
634
657
|
],
|
|
635
658
|
cardinality: "object",
|
|
636
659
|
kind: "performance",
|
|
@@ -679,6 +702,24 @@ var init_assertion_schema = __esm({
|
|
|
679
702
|
triviality: "reject-initial-value",
|
|
680
703
|
trivialityRationale: "An entity can be present and in-frame before input; the scenario must prove visibility after its setup or document why that presence is held."
|
|
681
704
|
},
|
|
705
|
+
{
|
|
706
|
+
description: "Proves which labelled audio cues the game actually played, and how often.",
|
|
707
|
+
example: { audio: [{ cue: "speech:p01", maxPlays: 1 }] },
|
|
708
|
+
fields: [
|
|
709
|
+
{ description: "Cue label the game passed to AudioBus.play/playAt.", name: "cue", required: true, type: "string" },
|
|
710
|
+
{ description: "Fewest plays required. Defaults to 1, so naming a cue asserts it was heard.", name: "minPlays", type: "non-negative integer" },
|
|
711
|
+
{ description: "Most plays allowed; 0 proves silence and 1 proves a one-shot stayed one.", name: "maxPlays", type: "non-negative integer" },
|
|
712
|
+
{ description: "Fewest milliseconds between this cue and the cue played before it, so one line cannot cut another.", name: "minGapMs", type: "non-negative integer" }
|
|
713
|
+
],
|
|
714
|
+
cardinality: "array",
|
|
715
|
+
kind: "audio",
|
|
716
|
+
observationPath: "runtimeObservations",
|
|
717
|
+
requiredCapabilities: ["runtime.audio"],
|
|
718
|
+
resultIdPrefix: "audio.",
|
|
719
|
+
supportedOn: ["web", "desktop"],
|
|
720
|
+
triviality: "not-applicable",
|
|
721
|
+
trivialityRationale: "A cue count starts at zero and only a played cue moves it, so there is no initial value to reject."
|
|
722
|
+
},
|
|
682
723
|
{
|
|
683
724
|
description: "Proves runtime world metadata exposed by the application bridge.",
|
|
684
725
|
example: { world: { seed: 90210 } },
|
|
@@ -868,7 +909,8 @@ var init_assertion_schema = __esm({
|
|
|
868
909
|
{ description: "Exact render-chain quality tier required after the chain applies.", name: "tier", type: "string" },
|
|
869
910
|
{ description: "Stage ids to include, exclude, or find as an ordered subsequence in the applied chain.", name: "stages", type: "object" },
|
|
870
911
|
{ description: "Applied stage ids whose build returned a different graph node than its input; this is graph evidence, not pixel attribution.", name: "contributions", type: "object" },
|
|
871
|
-
{ description: "Temporal history rejection ceiling as a fraction from 0 to 1.", name: "velocity", type: "object" }
|
|
912
|
+
{ description: "Temporal history rejection ceiling as a fraction from 0 to 1.", name: "velocity", type: "object" },
|
|
913
|
+
{ description: "What the chain must be on each adapter class the harness classified from its own adapter.info reading; an unclassifiable adapter fails rather than matching either branch.", name: "perAdapter", type: "object" }
|
|
872
914
|
],
|
|
873
915
|
cardinality: "object",
|
|
874
916
|
kind: "renderChain",
|
|
@@ -1557,6 +1599,53 @@ function contactAssertionSatisfiedAtStep(assertion, observations, scenario) {
|
|
|
1557
1599
|
const minimum = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1558
1600
|
return stepAvailable && (!anonymous || candidates.length > 0) && count >= minimum && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
1559
1601
|
}
|
|
1602
|
+
function smallestGapBefore(recent, cue) {
|
|
1603
|
+
let smallest;
|
|
1604
|
+
for (let index = 1; index < recent.length; index += 1) {
|
|
1605
|
+
const entry = recent[index];
|
|
1606
|
+
const previous = recent[index - 1];
|
|
1607
|
+
if (!isRecord(entry) || !isRecord(previous)) continue;
|
|
1608
|
+
if (entry.cue !== cue) continue;
|
|
1609
|
+
if (typeof entry.atMs !== "number" || typeof previous.atMs !== "number") continue;
|
|
1610
|
+
const gap = entry.atMs - previous.atMs;
|
|
1611
|
+
if (smallest === void 0 || gap < smallest) smallest = gap;
|
|
1612
|
+
}
|
|
1613
|
+
return smallest;
|
|
1614
|
+
}
|
|
1615
|
+
function evaluateAudioAssertion(assertion, observations) {
|
|
1616
|
+
const gameplay = gameplayObservations(observations);
|
|
1617
|
+
const audio = isRecord(gameplay?.audio) ? gameplay.audio : void 0;
|
|
1618
|
+
const cues = isRecord(audio?.cues) ? audio.cues : void 0;
|
|
1619
|
+
const observed = cues === void 0 ? void 0 : cues[assertion.cue];
|
|
1620
|
+
const plays = typeof observed === "number" ? observed : 0;
|
|
1621
|
+
const minimum = assertion.minPlays ?? 1;
|
|
1622
|
+
const recent = Array.isArray(audio?.recentCues) ? audio.recentCues : [];
|
|
1623
|
+
const gap = smallestGapBefore(recent, assertion.cue);
|
|
1624
|
+
const gapPass = assertion.minGapMs === void 0 || gap === void 0 || gap >= assertion.minGapMs;
|
|
1625
|
+
const pass = cues !== void 0 && plays >= minimum && (assertion.maxPlays === void 0 || plays <= assertion.maxPlays) && gapPass;
|
|
1626
|
+
const result = {
|
|
1627
|
+
details: {
|
|
1628
|
+
cue: assertion.cue,
|
|
1629
|
+
maxPlays: assertion.maxPlays ?? null,
|
|
1630
|
+
minGapMs: assertion.minGapMs ?? null,
|
|
1631
|
+
minPlays: minimum,
|
|
1632
|
+
observed: cues === void 0 ? null : plays,
|
|
1633
|
+
observedGapMs: gap ?? null
|
|
1634
|
+
},
|
|
1635
|
+
id: `audio.${assertion.cue}`,
|
|
1636
|
+
pass
|
|
1637
|
+
};
|
|
1638
|
+
return pass ? { assertion: result } : {
|
|
1639
|
+
assertion: result,
|
|
1640
|
+
diagnostic: {
|
|
1641
|
+
code: "TN_PLAYTEST_AUDIO_ASSERTION_FAILED",
|
|
1642
|
+
message: cues === void 0 ? `No runtime audio ledger was published, so cue '${assertion.cue}' cannot be proved either way.` : gapPass ? `Cue '${assertion.cue}' played ${plays} time(s); expected at least ${minimum}${assertion.maxPlays === void 0 ? "" : ` and at most ${assertion.maxPlays}`}.` : `Cue '${assertion.cue}' started ${gap ?? 0} ms after the line before it, which is under the ${String(assertion.minGapMs)} ms it needs; one of them was cut off.`,
|
|
1643
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/audio/cues",
|
|
1644
|
+
severity: "error",
|
|
1645
|
+
suggestion: cues === void 0 ? "Run on a target whose bridge advertises runtime.audio, and pass `cue` to AudioBus.play/playAt for the lines under test." : "Read observations.json/runtimeObservations/gameplay/audio/recentCues for when each play happened, and check the one-shot flag that gates the cue."
|
|
1646
|
+
}
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1560
1649
|
function evaluateWorldAssertion(assertion, observations) {
|
|
1561
1650
|
const gameplay = gameplayObservations(observations);
|
|
1562
1651
|
const world = isRecord(gameplay?.world) ? gameplay.world : void 0;
|
|
@@ -1735,6 +1824,51 @@ var init_families_observation = __esm({
|
|
|
1735
1824
|
}
|
|
1736
1825
|
});
|
|
1737
1826
|
|
|
1827
|
+
// src/protocol.ts
|
|
1828
|
+
function jsonByteLength(value) {
|
|
1829
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1830
|
+
}
|
|
1831
|
+
function assertJsonSafe(value, path2 = "$") {
|
|
1832
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
if (typeof value === "number") {
|
|
1836
|
+
if (Number.isFinite(value)) {
|
|
1837
|
+
return;
|
|
1838
|
+
}
|
|
1839
|
+
throw new TypeError(`${path2} must contain only finite JSON numbers.`);
|
|
1840
|
+
}
|
|
1841
|
+
if (Array.isArray(value)) {
|
|
1842
|
+
value.forEach((item, index) => assertJsonSafe(item, `${path2}[${index}]`));
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
if (typeof value === "object") {
|
|
1846
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1847
|
+
assertJsonSafe(item, `${path2}.${key}`);
|
|
1848
|
+
}
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
throw new TypeError(`${path2} must be JSON-safe.`);
|
|
1852
|
+
}
|
|
1853
|
+
var PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, PLAYTEST_FRAME_BUDGET_PHASES, PLAYTEST_FRAME_PASS_KINDS;
|
|
1854
|
+
var init_protocol = __esm({
|
|
1855
|
+
"src/protocol.ts"() {
|
|
1856
|
+
PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
1857
|
+
PLAYTEST_PROTOCOL_VERSION = 1;
|
|
1858
|
+
PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
1859
|
+
PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
1860
|
+
PLAYTEST_PROTOCOL_LIMITS = {
|
|
1861
|
+
maxEntitiesPerSample: 100,
|
|
1862
|
+
maxEventsPerDrain: 1e3,
|
|
1863
|
+
maxPayloadBytes: 1e6,
|
|
1864
|
+
operationTimeoutMs: 5e3
|
|
1865
|
+
};
|
|
1866
|
+
PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
1867
|
+
PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
1868
|
+
PLAYTEST_FRAME_PASS_KINDS = ["main", "shadow", "reflection", "nested"];
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
|
|
1738
1872
|
// src/evaluators/render-evidence.ts
|
|
1739
1873
|
function projectedPixelsForEntity(snapshot, entity, viewport) {
|
|
1740
1874
|
const rendered = renderedEntity(snapshot, entity);
|
|
@@ -1765,7 +1899,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1765
1899
|
const maxObservedTriangles = triangles.length === 0 ? void 0 : Math.max(...triangles);
|
|
1766
1900
|
const results = [];
|
|
1767
1901
|
const diagnostics = [];
|
|
1768
|
-
const
|
|
1902
|
+
const path2 = `${sourcePath ?? "playtest"}/observations.json/performanceSeries`;
|
|
1769
1903
|
const samplesPass = validSamples;
|
|
1770
1904
|
results.push({
|
|
1771
1905
|
details: { sampleCount: samples.length, valid: validSamples },
|
|
@@ -1776,7 +1910,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1776
1910
|
diagnostics.push({
|
|
1777
1911
|
code: "TN_PLAYTEST_PERFORMANCE_SAMPLES_MISSING",
|
|
1778
1912
|
message: samples.length === 0 ? "Performance assertion received no render samples." : "Performance assertion received an invalid render sample series.",
|
|
1779
|
-
observedRuntimePath:
|
|
1913
|
+
observedRuntimePath: path2,
|
|
1780
1914
|
severity: "error",
|
|
1781
1915
|
sourcePath,
|
|
1782
1916
|
suggestion: "Run the scenario against the real render loop and keep the performance bridge provider installed."
|
|
@@ -1787,7 +1921,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1787
1921
|
if (!pass) diagnostics.push({
|
|
1788
1922
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1789
1923
|
message: `${id} expected at most ${expected} ${unit}, observed ${actual ?? "unavailable"}.`,
|
|
1790
|
-
observedRuntimePath:
|
|
1924
|
+
observedRuntimePath: path2,
|
|
1791
1925
|
severity: "error",
|
|
1792
1926
|
sourcePath,
|
|
1793
1927
|
suggestion: "Inspect the recorded frame-cost series and reduce the authored scene cost that owns the regression."
|
|
@@ -1822,7 +1956,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1822
1956
|
if (!pass) diagnostics.push({
|
|
1823
1957
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1824
1958
|
message: `performance.minFps expected at least ${assertion.minFps} fps, observed ${observed2 ?? "unavailable"}.`,
|
|
1825
|
-
observedRuntimePath:
|
|
1959
|
+
observedRuntimePath: path2,
|
|
1826
1960
|
severity: "error",
|
|
1827
1961
|
sourcePath,
|
|
1828
1962
|
suggestion: "Read the TN_FRAME_BUDGET marker for this run: it names which frame phase owns the time."
|
|
@@ -1841,7 +1975,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1841
1975
|
if (!pass) diagnostics.push({
|
|
1842
1976
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1843
1977
|
message: actual === void 0 ? `performance.maxPhaseMsP95.${phase} received no frame-budget phase samples; the run produced ${measured.length} of ${samples.length}.` : `performance.maxPhaseMsP95.${phase} expected at most ${ceiling} ms, observed ${actual}.`,
|
|
1844
|
-
observedRuntimePath:
|
|
1978
|
+
observedRuntimePath: path2,
|
|
1845
1979
|
severity: "error",
|
|
1846
1980
|
sourcePath,
|
|
1847
1981
|
suggestion: actual === void 0 ? "Keep the engine frame budget installed: defineGame({ frameBudget: false }) silences the marker but a phase ceiling still needs the per-frame split." : "Reduce the cost of that phase, or move the ceiling and say why in the scenario."
|
|
@@ -1857,13 +1991,47 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1857
1991
|
samplesPass && triangles.length === samples.length && maxObservedTriangles !== void 0 && maxObservedTriangles <= assertion.maxTriangles
|
|
1858
1992
|
);
|
|
1859
1993
|
}
|
|
1994
|
+
const addPassBound = (unit, kind, ceiling) => {
|
|
1995
|
+
const noun = unit === "draws" ? "draw calls" : "triangles";
|
|
1996
|
+
const measured = observed.flatMap((sample) => {
|
|
1997
|
+
const pass2 = sample.passes?.find((candidate) => candidate.kind === kind);
|
|
1998
|
+
return pass2 === void 0 ? [] : [pass2[unit]];
|
|
1999
|
+
});
|
|
2000
|
+
const actual = measured.length === samples.length ? Math.max(...measured) : void 0;
|
|
2001
|
+
const id = unit === "draws" ? `performance.maxPassDrawCalls.${kind}` : `performance.maxPassTriangles.${kind}`;
|
|
2002
|
+
const pass = samplesPass && actual !== void 0 && actual <= ceiling;
|
|
2003
|
+
results.push({
|
|
2004
|
+
details: { actual: actual ?? null, expected: ceiling, pass: kind, sampleCount: samples.length, unit: noun },
|
|
2005
|
+
id,
|
|
2006
|
+
pass
|
|
2007
|
+
});
|
|
2008
|
+
if (!pass) diagnostics.push({
|
|
2009
|
+
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
2010
|
+
message: actual === void 0 ? `${id} received no per-pass samples for '${kind}'; ${measured.length} of ${samples.length} frames carried that pass.` : `${id} expected at most ${ceiling} ${noun}, observed ${actual}.`,
|
|
2011
|
+
observedRuntimePath: path2,
|
|
2012
|
+
severity: "error",
|
|
2013
|
+
sourcePath,
|
|
2014
|
+
suggestion: "Keep the engine frame budget installed so the run carries a per-pass split; a renderer that reports no split cannot satisfy a per-pass ceiling."
|
|
2015
|
+
});
|
|
2016
|
+
};
|
|
2017
|
+
for (const [kind, ceiling] of Object.entries(assertion.maxPassDrawCalls ?? {}))
|
|
2018
|
+
addPassBound("draws", kind, ceiling);
|
|
2019
|
+
for (const [kind, ceiling] of Object.entries(assertion.maxPassTriangles ?? {}))
|
|
2020
|
+
addPassBound("triangles", kind, ceiling);
|
|
1860
2021
|
return { assertions: results, diagnostics };
|
|
1861
2022
|
}
|
|
1862
2023
|
function isRuntimeDiagnosticsSample(value) {
|
|
1863
2024
|
if (!isRecord(value) || typeof value.frameMs !== "number" || !Number.isFinite(value.frameMs) || value.frameMs <= 0) {
|
|
1864
2025
|
return false;
|
|
1865
2026
|
}
|
|
1866
|
-
return (value.drawCalls === void 0 || typeof value.drawCalls === "number" && Number.isFinite(value.drawCalls) && value.drawCalls >= 0) && (value.triangles === void 0 || typeof value.triangles === "number" && Number.isFinite(value.triangles) && value.triangles >= 0) && isFramePhaseSplit(value.phases);
|
|
2027
|
+
return (value.drawCalls === void 0 || typeof value.drawCalls === "number" && Number.isFinite(value.drawCalls) && value.drawCalls >= 0) && (value.triangles === void 0 || typeof value.triangles === "number" && Number.isFinite(value.triangles) && value.triangles >= 0) && isFramePhaseSplit(value.phases) && isFramePassSplit(value.passes);
|
|
2028
|
+
}
|
|
2029
|
+
function isFramePassSplit(value) {
|
|
2030
|
+
if (value === void 0) return true;
|
|
2031
|
+
if (!Array.isArray(value)) return false;
|
|
2032
|
+
return value.every(
|
|
2033
|
+
(pass) => isRecord(pass) && PLAYTEST_FRAME_PASS_KINDS.includes(pass.kind) && typeof pass.draws === "number" && Number.isFinite(pass.draws) && pass.draws >= 0 && typeof pass.triangles === "number" && Number.isFinite(pass.triangles) && pass.triangles >= 0
|
|
2034
|
+
);
|
|
1867
2035
|
}
|
|
1868
2036
|
function isFramePhaseSplit(value) {
|
|
1869
2037
|
if (value === void 0) return true;
|
|
@@ -2042,6 +2210,7 @@ function minimumResolvedDistance(effectLog, effectLogSeries, entityId, target, b
|
|
|
2042
2210
|
}
|
|
2043
2211
|
var init_render_evidence = __esm({
|
|
2044
2212
|
"src/evaluators/render-evidence.ts"() {
|
|
2213
|
+
init_protocol();
|
|
2045
2214
|
init_measures();
|
|
2046
2215
|
init_assertion_report();
|
|
2047
2216
|
}
|
|
@@ -3134,6 +3303,11 @@ function emitPerfSignalsWorld(ctx) {
|
|
|
3134
3303
|
suggestion: "Expose a bounded events callback on the playtest bridge and inspect the emitted signal name and entity."
|
|
3135
3304
|
});
|
|
3136
3305
|
}
|
|
3306
|
+
for (const assertion of scenarioAssertions.audio ?? []) {
|
|
3307
|
+
const result = evaluateAudioAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
3308
|
+
assertions.push(result.assertion);
|
|
3309
|
+
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
3310
|
+
}
|
|
3137
3311
|
if (scenarioAssertions.world !== void 0) {
|
|
3138
3312
|
const result = evaluateWorldAssertion(scenarioAssertions.world, input.report.observations?.runtimeObservations);
|
|
3139
3313
|
assertions.push(result.assertion);
|
|
@@ -3718,34 +3892,169 @@ var init_world_gameplay = __esm({
|
|
|
3718
3892
|
}
|
|
3719
3893
|
});
|
|
3720
3894
|
|
|
3895
|
+
// src/runner/browser.ts
|
|
3896
|
+
var browser_exports = {};
|
|
3897
|
+
__export(browser_exports, {
|
|
3898
|
+
PERFORMANCE_BROWSER_ARGS: () => PERFORMANCE_BROWSER_ARGS,
|
|
3899
|
+
WEBGPU_BROWSER_ARGS: () => WEBGPU_BROWSER_ARGS,
|
|
3900
|
+
reconcileBrowserPointers: () => reconcileBrowserPointers,
|
|
3901
|
+
resolveBrowserArguments: () => resolveBrowserArguments,
|
|
3902
|
+
softwareAdapterName: () => softwareAdapterName
|
|
3903
|
+
});
|
|
3904
|
+
function resolveBrowserArguments(browserArgs) {
|
|
3905
|
+
return [...browserArgs ?? []];
|
|
3906
|
+
}
|
|
3907
|
+
function softwareAdapterName(adapter) {
|
|
3908
|
+
if (adapter === void 0) return void 0;
|
|
3909
|
+
for (const value of Object.values(adapter)) {
|
|
3910
|
+
if (typeof value === "string" && SOFTWARE_ADAPTER.test(value)) return value;
|
|
3911
|
+
}
|
|
3912
|
+
return void 0;
|
|
3913
|
+
}
|
|
3914
|
+
function reconcileBrowserPointers(previous, next) {
|
|
3915
|
+
const normalized = new Map(next.map((pointer) => [pointer.id, {
|
|
3916
|
+
buttons: pointer.buttons ?? 1,
|
|
3917
|
+
id: pointer.id,
|
|
3918
|
+
x: pointer.x,
|
|
3919
|
+
y: pointer.y
|
|
3920
|
+
}]));
|
|
3921
|
+
const previousPrimary = previous.keys().next().value;
|
|
3922
|
+
const nextPrimary = normalized.keys().next().value;
|
|
3923
|
+
const changes = [];
|
|
3924
|
+
for (const pointer of previous.values()) {
|
|
3925
|
+
if (!normalized.has(pointer.id)) {
|
|
3926
|
+
changes.push({ isPrimary: pointer.id === previousPrimary, pointer: { ...pointer, buttons: 0 }, type: "pointerup" });
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
for (const pointer of normalized.values()) {
|
|
3930
|
+
const old = previous.get(pointer.id);
|
|
3931
|
+
if (old === void 0) {
|
|
3932
|
+
changes.push({ isPrimary: pointer.id === nextPrimary, pointer, type: "pointerdown" });
|
|
3933
|
+
} else if (old.x !== pointer.x || old.y !== pointer.y || old.buttons !== pointer.buttons) {
|
|
3934
|
+
changes.push({ isPrimary: pointer.id === nextPrimary, pointer, type: "pointermove" });
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
return changes;
|
|
3938
|
+
}
|
|
3939
|
+
var WEBGPU_BROWSER_ARGS, PERFORMANCE_BROWSER_ARGS, SOFTWARE_ADAPTER;
|
|
3940
|
+
var init_browser = __esm({
|
|
3941
|
+
"src/runner/browser.ts"() {
|
|
3942
|
+
WEBGPU_BROWSER_ARGS = [
|
|
3943
|
+
"--ozone-platform=x11",
|
|
3944
|
+
"--enable-unsafe-webgpu",
|
|
3945
|
+
"--disable-gpu-sandbox",
|
|
3946
|
+
"--ignore-gpu-blocklist",
|
|
3947
|
+
// Without this Chromium never reaches the Vulkan driver on Linux and silently serves WebGPU
|
|
3948
|
+
// from SwiftShader, its CPU rasteriser. Nothing errors: the adapter answers, the run
|
|
3949
|
+
// proceeds, and the results are a software renderer's. Measured on an RTX 2080 under Xvfb,
|
|
3950
|
+
// `adapter.info` reads `swiftshader / google` without the flag and `turing / nvidia` with it,
|
|
3951
|
+
// which is the difference between blank captures and a rendered frame.
|
|
3952
|
+
"--enable-features=Vulkan"
|
|
3953
|
+
];
|
|
3954
|
+
PERFORMANCE_BROWSER_ARGS = [
|
|
3955
|
+
"--disable-frame-rate-limit",
|
|
3956
|
+
"--disable-gpu-vsync"
|
|
3957
|
+
];
|
|
3958
|
+
SOFTWARE_ADAPTER = /swiftshader|llvmpipe|lavapipe|softwarerasterizer|software adapter|basic render/i;
|
|
3959
|
+
}
|
|
3960
|
+
});
|
|
3961
|
+
|
|
3962
|
+
// src/evaluators/adapter-class.ts
|
|
3963
|
+
function classifyAdapter(report) {
|
|
3964
|
+
const capture = report.capture;
|
|
3965
|
+
if (capture === void 0 || capture.rendererKind !== "webgpu") return {};
|
|
3966
|
+
if (adapterIdentity(capture.adapter) === void 0) return {};
|
|
3967
|
+
const software = softwareAdapterName(capture.adapter);
|
|
3968
|
+
return software === void 0 ? { adapterClass: "hardware" } : { adapterClass: "software", softwareAdapter: software };
|
|
3969
|
+
}
|
|
3970
|
+
function adapterIdentity(adapter) {
|
|
3971
|
+
if (adapter === void 0) return void 0;
|
|
3972
|
+
for (const key of ADAPTER_IDENTITY_KEYS) {
|
|
3973
|
+
const value = adapter[key];
|
|
3974
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
3975
|
+
}
|
|
3976
|
+
return void 0;
|
|
3977
|
+
}
|
|
3978
|
+
function adapterFieldsFromIdentity(identity) {
|
|
3979
|
+
if (typeof identity !== "string") return void 0;
|
|
3980
|
+
const prefix = "webgpu:";
|
|
3981
|
+
if (!identity.startsWith(prefix)) return void 0;
|
|
3982
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
3983
|
+
for (const pair of identity.slice(prefix.length).split("|")) {
|
|
3984
|
+
const separator = pair.indexOf("=");
|
|
3985
|
+
if (separator <= 0) return void 0;
|
|
3986
|
+
const key = pair.slice(0, separator);
|
|
3987
|
+
if (!ADAPTER_IDENTITY_KEYS.includes(key) || Object.hasOwn(fields, key)) {
|
|
3988
|
+
return void 0;
|
|
3989
|
+
}
|
|
3990
|
+
let value;
|
|
3991
|
+
try {
|
|
3992
|
+
value = decodeURIComponent(pair.slice(separator + 1));
|
|
3993
|
+
} catch {
|
|
3994
|
+
return void 0;
|
|
3995
|
+
}
|
|
3996
|
+
if (value.trim() === "") return void 0;
|
|
3997
|
+
fields[key] = value;
|
|
3998
|
+
}
|
|
3999
|
+
if (Object.keys(fields).length === 0) return void 0;
|
|
4000
|
+
return fields;
|
|
4001
|
+
}
|
|
4002
|
+
function nativeCaptureProvenance(census, target, viewport) {
|
|
4003
|
+
if (census === void 0 || census === null || typeof census !== "object" || Array.isArray(census)) return void 0;
|
|
4004
|
+
const adapterRecord = census.adapter;
|
|
4005
|
+
if (adapterRecord === void 0 || adapterRecord === null || typeof adapterRecord !== "object" || Array.isArray(adapterRecord)) return void 0;
|
|
4006
|
+
const adapter = adapterFieldsFromIdentity(adapterRecord.identity);
|
|
4007
|
+
if (adapter === void 0) return void 0;
|
|
4008
|
+
return {
|
|
4009
|
+
adapter,
|
|
4010
|
+
// A native launch carries no browser command line; there is no argument list to report and
|
|
4011
|
+
// inventing one would be a flag nobody can check.
|
|
4012
|
+
browserArgs: [],
|
|
4013
|
+
captureMethod: "device.screenshot",
|
|
4014
|
+
rendererKind: "webgpu",
|
|
4015
|
+
target,
|
|
4016
|
+
viewport
|
|
4017
|
+
};
|
|
4018
|
+
}
|
|
4019
|
+
var ADAPTER_IDENTITY_KEYS;
|
|
4020
|
+
var init_adapter_class = __esm({
|
|
4021
|
+
"src/evaluators/adapter-class.ts"() {
|
|
4022
|
+
init_browser();
|
|
4023
|
+
ADAPTER_IDENTITY_KEYS = ["architecture", "description", "device", "vendor"];
|
|
4024
|
+
}
|
|
4025
|
+
});
|
|
4026
|
+
|
|
3721
4027
|
// src/evaluators/render-chain.ts
|
|
3722
4028
|
function emitRenderChain(ctx) {
|
|
3723
4029
|
const assertion = ctx.scenarioAssertions.renderChain;
|
|
3724
4030
|
if (assertion === void 0) return;
|
|
3725
4031
|
const observed = ctx.input.report.observations?.renderChain;
|
|
3726
|
-
|
|
3727
|
-
|
|
4032
|
+
const selected = selectExpectation(ctx, assertion);
|
|
4033
|
+
const expected = selected.expectation;
|
|
4034
|
+
if (expected.tier !== void 0) {
|
|
4035
|
+
const pass = observed?.tier === expected.tier;
|
|
3728
4036
|
ctx.assertions.push({
|
|
3729
|
-
details: { expected:
|
|
4037
|
+
details: { ...selected.provenance, expected: expected.tier, observed: observed?.tier },
|
|
3730
4038
|
id: "renderChain.tier",
|
|
3731
4039
|
pass
|
|
3732
4040
|
});
|
|
3733
4041
|
if (!pass) {
|
|
3734
4042
|
ctx.diagnostics.push({
|
|
3735
4043
|
code: observed === void 0 ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_TIER_FAILED",
|
|
3736
|
-
message: observed === void 0 ? "Render-chain tier was not observed because the TN_RENDER_CHAIN marker was absent." : `Render-chain tier '${observed.tier}' did not match the asserted tier '${
|
|
4044
|
+
message: observed === void 0 ? "Render-chain tier was not observed because the TN_RENDER_CHAIN marker was absent." : `Render-chain tier '${observed.tier}' did not match the asserted tier '${expected.tier}'.`,
|
|
3737
4045
|
observedRuntimePath: "observations.json/renderChain/tier",
|
|
3738
4046
|
severity: "error",
|
|
3739
4047
|
suggestion: "Install the RenderChain through the renderer seam and keep its marker callback connected to the playtest bridge."
|
|
3740
4048
|
});
|
|
3741
4049
|
}
|
|
3742
4050
|
}
|
|
3743
|
-
const stageAssertion =
|
|
4051
|
+
const stageAssertion = expected.stages;
|
|
3744
4052
|
if (stageAssertion !== void 0) {
|
|
3745
4053
|
const observedStages = observed?.stages;
|
|
3746
4054
|
if (stageAssertion.includes !== void 0) {
|
|
3747
4055
|
emitStageCheck(
|
|
3748
4056
|
ctx,
|
|
4057
|
+
selected.provenance,
|
|
3749
4058
|
observedStages,
|
|
3750
4059
|
"includes",
|
|
3751
4060
|
stageAssertion.includes,
|
|
@@ -3755,6 +4064,7 @@ function emitRenderChain(ctx) {
|
|
|
3755
4064
|
if (stageAssertion.excludes !== void 0) {
|
|
3756
4065
|
emitStageCheck(
|
|
3757
4066
|
ctx,
|
|
4067
|
+
selected.provenance,
|
|
3758
4068
|
observedStages,
|
|
3759
4069
|
"excludes",
|
|
3760
4070
|
stageAssertion.excludes,
|
|
@@ -3764,6 +4074,7 @@ function emitRenderChain(ctx) {
|
|
|
3764
4074
|
if (stageAssertion.order !== void 0) {
|
|
3765
4075
|
emitStageCheck(
|
|
3766
4076
|
ctx,
|
|
4077
|
+
selected.provenance,
|
|
3767
4078
|
observedStages,
|
|
3768
4079
|
"order",
|
|
3769
4080
|
stageAssertion.order,
|
|
@@ -3771,7 +4082,7 @@ function emitRenderChain(ctx) {
|
|
|
3771
4082
|
);
|
|
3772
4083
|
}
|
|
3773
4084
|
}
|
|
3774
|
-
const contributionAssertion =
|
|
4085
|
+
const contributionAssertion = expected.contributions;
|
|
3775
4086
|
if (contributionAssertion !== void 0) {
|
|
3776
4087
|
const observedContributions = observed?.contributions;
|
|
3777
4088
|
const pass = Array.isArray(observedContributions) && contributionAssertion.graphOutputChanged.every(
|
|
@@ -3779,6 +4090,7 @@ function emitRenderChain(ctx) {
|
|
|
3779
4090
|
);
|
|
3780
4091
|
ctx.assertions.push({
|
|
3781
4092
|
details: {
|
|
4093
|
+
...selected.provenance,
|
|
3782
4094
|
expected: contributionAssertion.graphOutputChanged,
|
|
3783
4095
|
observed: observedContributions
|
|
3784
4096
|
},
|
|
@@ -3795,14 +4107,15 @@ function emitRenderChain(ctx) {
|
|
|
3795
4107
|
});
|
|
3796
4108
|
}
|
|
3797
4109
|
}
|
|
3798
|
-
if (
|
|
4110
|
+
if (expected.velocity !== void 0) {
|
|
3799
4111
|
const rejectionFraction = observed?.velocity.rejectionFraction;
|
|
3800
4112
|
const measurementFrame = observed?.velocity.measurementFrame;
|
|
3801
4113
|
const hasMeasurement = rejectionFraction !== void 0 && Number.isFinite(rejectionFraction) && typeof measurementFrame === "number" && Number.isInteger(measurementFrame) && measurementFrame >= 0;
|
|
3802
|
-
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <=
|
|
4114
|
+
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <= expected.velocity.maxRejectionFraction;
|
|
3803
4115
|
ctx.assertions.push({
|
|
3804
4116
|
details: {
|
|
3805
|
-
|
|
4117
|
+
...selected.provenance,
|
|
4118
|
+
expected: expected.velocity.maxRejectionFraction,
|
|
3806
4119
|
measurementFrame,
|
|
3807
4120
|
observed: rejectionFraction
|
|
3808
4121
|
},
|
|
@@ -3812,17 +4125,47 @@ function emitRenderChain(ctx) {
|
|
|
3812
4125
|
if (!pass) {
|
|
3813
4126
|
ctx.diagnostics.push({
|
|
3814
4127
|
code: observed === void 0 || !hasMeasurement ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_REJECTION_FAILED",
|
|
3815
|
-
message: observed === void 0 ? "Render-chain velocity rejection was not observed because the TN_RENDER_CHAIN marker was absent." : !hasMeasurement ? "Render-chain velocity was provisioned without a fresh completed-frame history-rejection measurement." : `Render-chain history rejection fraction ${rejectionFraction ?? "missing"} exceeded the asserted ceiling ${
|
|
4128
|
+
message: observed === void 0 ? "Render-chain velocity rejection was not observed because the TN_RENDER_CHAIN marker was absent." : !hasMeasurement ? "Render-chain velocity was provisioned without a fresh completed-frame history-rejection measurement." : `Render-chain history rejection fraction ${rejectionFraction ?? "missing"} exceeded the asserted ceiling ${expected.velocity.maxRejectionFraction}.`,
|
|
3816
4129
|
observedRuntimePath: "observations.json/renderChain/velocity/rejectionFraction",
|
|
3817
4130
|
severity: "error",
|
|
3818
4131
|
suggestion: "Publish the temporal stage's measured rejection fraction on the same render-chain marker used for tier reporting."
|
|
3819
4132
|
});
|
|
3820
4133
|
}
|
|
3821
4134
|
}
|
|
4135
|
+
if (assertion.perAdapter !== void 0 && selected.classification === void 0) {
|
|
4136
|
+
ctx.assertions.push({
|
|
4137
|
+
details: { ...selected.provenance, expected: Object.keys(assertion.perAdapter) },
|
|
4138
|
+
id: "renderChain.adapterClass",
|
|
4139
|
+
pass: false
|
|
4140
|
+
});
|
|
4141
|
+
ctx.diagnostics.push({
|
|
4142
|
+
code: "TN_PLAYTEST_RENDER_CHAIN_ADAPTER_UNCLASSIFIED",
|
|
4143
|
+
message: "No adapter.info field named a software rasteriser, so this run is not proven to be either adapter class and was held to the flat render-chain expectation.",
|
|
4144
|
+
observedRuntimePath: "observations.json/capture/adapter",
|
|
4145
|
+
severity: "error",
|
|
4146
|
+
suggestion: "Run on a lane that reports adapter.info, or drop perAdapter and assert one policy for every adapter."
|
|
4147
|
+
});
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
function selectExpectation(ctx, assertion) {
|
|
4151
|
+
const flat = {
|
|
4152
|
+
...assertion.tier === void 0 ? {} : { tier: assertion.tier },
|
|
4153
|
+
...assertion.stages === void 0 ? {} : { stages: assertion.stages },
|
|
4154
|
+
...assertion.contributions === void 0 ? {} : { contributions: assertion.contributions },
|
|
4155
|
+
...assertion.velocity === void 0 ? {} : { velocity: assertion.velocity }
|
|
4156
|
+
};
|
|
4157
|
+
const provenance = classifyAdapter(ctx.input.report);
|
|
4158
|
+
const { adapterClass } = provenance;
|
|
4159
|
+
const branch = adapterClass === void 0 ? void 0 : assertion.perAdapter?.[adapterClass];
|
|
4160
|
+
return {
|
|
4161
|
+
classification: adapterClass,
|
|
4162
|
+
expectation: branch ?? flat,
|
|
4163
|
+
provenance
|
|
4164
|
+
};
|
|
3822
4165
|
}
|
|
3823
|
-
function emitStageCheck(ctx, observed, kind, expected, pass) {
|
|
4166
|
+
function emitStageCheck(ctx, provenance, observed, kind, expected, pass) {
|
|
3824
4167
|
ctx.assertions.push({
|
|
3825
|
-
details: { expected, observed },
|
|
4168
|
+
details: { ...provenance, expected, observed },
|
|
3826
4169
|
id: `renderChain.stages.${kind}`,
|
|
3827
4170
|
pass
|
|
3828
4171
|
});
|
|
@@ -3846,6 +4189,7 @@ function isOrderedSubsequence(expected, observed) {
|
|
|
3846
4189
|
}
|
|
3847
4190
|
var init_render_chain = __esm({
|
|
3848
4191
|
"src/evaluators/render-chain.ts"() {
|
|
4192
|
+
init_adapter_class();
|
|
3849
4193
|
}
|
|
3850
4194
|
});
|
|
3851
4195
|
|
|
@@ -4373,6 +4717,19 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
4373
4717
|
emitRenderChain(ctx);
|
|
4374
4718
|
emitScene(ctx);
|
|
4375
4719
|
emitSceneNodes(ctx);
|
|
4720
|
+
if (scenarioAssertions.geometry !== void 0) {
|
|
4721
|
+
const observed = input.report.observations?.geometry;
|
|
4722
|
+
const status = observed?.status;
|
|
4723
|
+
const pass = status === "captured";
|
|
4724
|
+
assertions.push({ details: { observed, status }, id: "geometry.observed", pass });
|
|
4725
|
+
if (!pass) diagnostics.push({
|
|
4726
|
+
code: "TN_PLAYTEST_GEOMETRY_UNOBSERVED",
|
|
4727
|
+
message: "A geometry assertion was evaluated against a run whose bridge reported no captured geometry frame.",
|
|
4728
|
+
observedRuntimePath: "observations.json/geometry",
|
|
4729
|
+
severity: "error",
|
|
4730
|
+
suggestion: "Request the capture on a target whose bridge advertises runtime.geometry and is presenting world frames."
|
|
4731
|
+
});
|
|
4732
|
+
}
|
|
4376
4733
|
emitCausedBy(ctx);
|
|
4377
4734
|
emitStartup(ctx);
|
|
4378
4735
|
emitMovementEvidence(ctx);
|
|
@@ -4412,50 +4769,6 @@ var init_assertions = __esm({
|
|
|
4412
4769
|
init_assertion_schema();
|
|
4413
4770
|
}
|
|
4414
4771
|
});
|
|
4415
|
-
|
|
4416
|
-
// src/protocol.ts
|
|
4417
|
-
function jsonByteLength(value) {
|
|
4418
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
4419
|
-
}
|
|
4420
|
-
function assertJsonSafe(value, path = "$") {
|
|
4421
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
4422
|
-
return;
|
|
4423
|
-
}
|
|
4424
|
-
if (typeof value === "number") {
|
|
4425
|
-
if (Number.isFinite(value)) {
|
|
4426
|
-
return;
|
|
4427
|
-
}
|
|
4428
|
-
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
4429
|
-
}
|
|
4430
|
-
if (Array.isArray(value)) {
|
|
4431
|
-
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
4432
|
-
return;
|
|
4433
|
-
}
|
|
4434
|
-
if (typeof value === "object") {
|
|
4435
|
-
for (const [key, item] of Object.entries(value)) {
|
|
4436
|
-
assertJsonSafe(item, `${path}.${key}`);
|
|
4437
|
-
}
|
|
4438
|
-
return;
|
|
4439
|
-
}
|
|
4440
|
-
throw new TypeError(`${path} must be JSON-safe.`);
|
|
4441
|
-
}
|
|
4442
|
-
var PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, PLAYTEST_FRAME_BUDGET_PHASES;
|
|
4443
|
-
var init_protocol = __esm({
|
|
4444
|
-
"src/protocol.ts"() {
|
|
4445
|
-
PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
4446
|
-
PLAYTEST_PROTOCOL_VERSION = 1;
|
|
4447
|
-
PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
4448
|
-
PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
4449
|
-
PLAYTEST_PROTOCOL_LIMITS = {
|
|
4450
|
-
maxEntitiesPerSample: 100,
|
|
4451
|
-
maxEventsPerDrain: 1e3,
|
|
4452
|
-
maxPayloadBytes: 1e6,
|
|
4453
|
-
operationTimeoutMs: 5e3
|
|
4454
|
-
};
|
|
4455
|
-
PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
4456
|
-
PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
4457
|
-
}
|
|
4458
|
-
});
|
|
4459
4772
|
var NUMERIC_COMPARISON_KEYS, MIN_TRIVIALITY_REASON_LENGTH;
|
|
4460
4773
|
var init_schema_base = __esm({
|
|
4461
4774
|
"src/scenario/schema-base.ts"() {
|
|
@@ -4598,6 +4911,8 @@ var init_generated_assertion_validators = __esm({
|
|
|
4598
4911
|
"minFps": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4599
4912
|
"maxPhaseMsP95": (value) => isRecord2(value),
|
|
4600
4913
|
"maxDrawCalls": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4914
|
+
"maxPassDrawCalls": (value) => isRecord2(value),
|
|
4915
|
+
"maxPassTriangles": (value) => isRecord2(value),
|
|
4601
4916
|
"maxTriangles": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4602
4917
|
}),
|
|
4603
4918
|
"parity": Object.freeze({
|
|
@@ -4614,6 +4929,12 @@ var init_generated_assertion_validators = __esm({
|
|
|
4614
4929
|
"present": (value) => typeof value === "boolean",
|
|
4615
4930
|
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4616
4931
|
}),
|
|
4932
|
+
"audio": Object.freeze({
|
|
4933
|
+
"cue": (value) => typeof value === "string" && value.trim() !== "",
|
|
4934
|
+
"minPlays": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4935
|
+
"maxPlays": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4936
|
+
"minGapMs": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0
|
|
4937
|
+
}),
|
|
4617
4938
|
"world": Object.freeze({
|
|
4618
4939
|
"seed": (value) => true,
|
|
4619
4940
|
"runtime": (value) => isRecord2(value)
|
|
@@ -4683,7 +5004,8 @@ var init_generated_assertion_validators = __esm({
|
|
|
4683
5004
|
"tier": (value) => typeof value === "string" && value.trim() !== "",
|
|
4684
5005
|
"stages": (value) => isRecord2(value),
|
|
4685
5006
|
"contributions": (value) => isRecord2(value),
|
|
4686
|
-
"velocity": (value) => isRecord2(value)
|
|
5007
|
+
"velocity": (value) => isRecord2(value),
|
|
5008
|
+
"perAdapter": (value) => isRecord2(value)
|
|
4687
5009
|
})
|
|
4688
5010
|
});
|
|
4689
5011
|
}
|
|
@@ -4919,10 +5241,12 @@ function validateDeviceMetricsAssertion(value, scenarioPath, objectPath) {
|
|
|
4919
5241
|
}
|
|
4920
5242
|
function validatePerformanceAssertion(value, scenarioPath, objectPath) {
|
|
4921
5243
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
4922
|
-
rejectUnknownKeys(record4, ["maxDrawCalls", "maxFrameMsP95", "maxPhaseMsP95", "maxTriangles", "minFps"], scenarioPath, objectPath);
|
|
5244
|
+
rejectUnknownKeys(record4, ["maxDrawCalls", "maxFrameMsP95", "maxPassDrawCalls", "maxPassTriangles", "maxPhaseMsP95", "maxTriangles", "minFps"], scenarioPath, objectPath);
|
|
4923
5245
|
return {
|
|
4924
5246
|
...present("maxDrawCalls", optionalNonNegativeNumber(record4, "maxDrawCalls", scenarioPath, objectPath)),
|
|
4925
5247
|
...present("maxFrameMsP95", optionalNonNegativeNumber(record4, "maxFrameMsP95", scenarioPath, objectPath)),
|
|
5248
|
+
...present("maxPassDrawCalls", validatePassBudget(record4.maxPassDrawCalls, scenarioPath, `${objectPath}.maxPassDrawCalls`)),
|
|
5249
|
+
...present("maxPassTriangles", validatePassBudget(record4.maxPassTriangles, scenarioPath, `${objectPath}.maxPassTriangles`)),
|
|
4926
5250
|
...present("maxPhaseMsP95", validatePhaseBudget(record4.maxPhaseMsP95, scenarioPath, `${objectPath}.maxPhaseMsP95`)),
|
|
4927
5251
|
...present("maxTriangles", optionalNonNegativeNumber(record4, "maxTriangles", scenarioPath, objectPath)),
|
|
4928
5252
|
...present("minFps", optionalNonNegativeNumber(record4, "minFps", scenarioPath, objectPath))
|
|
@@ -4981,6 +5305,33 @@ function validateParityAssertion(value, scenarioPath, objectPath) {
|
|
|
4981
5305
|
}
|
|
4982
5306
|
function validateRenderChainAssertion(value, scenarioPath, objectPath) {
|
|
4983
5307
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5308
|
+
const perAdapter = record4.perAdapter === void 0 ? void 0 : validateRenderChainPerAdapter(record4.perAdapter, scenarioPath, `${objectPath}.perAdapter`);
|
|
5309
|
+
const expectation = validateRenderChainExpectation(record4, scenarioPath, objectPath);
|
|
5310
|
+
return perAdapter === void 0 ? expectation : { ...expectation, perAdapter };
|
|
5311
|
+
}
|
|
5312
|
+
function validateRenderChainPerAdapter(value, scenarioPath, objectPath) {
|
|
5313
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5314
|
+
const entries = Object.entries(record4);
|
|
5315
|
+
if (entries.length === 0) {
|
|
5316
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must name at least one adapter class.`);
|
|
5317
|
+
}
|
|
5318
|
+
const result = {};
|
|
5319
|
+
for (const [kind, branch] of entries) {
|
|
5320
|
+
if (kind !== "hardware" && kind !== "software") {
|
|
5321
|
+
throw invalidScenario(
|
|
5322
|
+
scenarioPath,
|
|
5323
|
+
`'${objectPath}.${kind}' is not an adapter class this harness can classify; expected hardware or software.`
|
|
5324
|
+
);
|
|
5325
|
+
}
|
|
5326
|
+
result[kind] = validateRenderChainExpectation(
|
|
5327
|
+
requireRecord(branch, scenarioPath, `${objectPath}.${kind}`),
|
|
5328
|
+
scenarioPath,
|
|
5329
|
+
`${objectPath}.${kind}`
|
|
5330
|
+
);
|
|
5331
|
+
}
|
|
5332
|
+
return result;
|
|
5333
|
+
}
|
|
5334
|
+
function validateRenderChainExpectation(record4, scenarioPath, objectPath) {
|
|
4984
5335
|
const tier = record4.tier;
|
|
4985
5336
|
if (tier !== void 0 && tier !== "high" && tier !== "medium" && tier !== "low" && tier !== "off") {
|
|
4986
5337
|
throw invalidScenario(scenarioPath, `'${objectPath}.tier' must be high, medium, low, or off, received ${describeValue(tier)}.`);
|
|
@@ -5058,28 +5409,47 @@ function validateStartupAssertion(value, scenarioPath, objectPath) {
|
|
|
5058
5409
|
}
|
|
5059
5410
|
return result;
|
|
5060
5411
|
}
|
|
5061
|
-
function
|
|
5412
|
+
function validatePassBudget(value, scenarioPath, objectPath) {
|
|
5062
5413
|
if (value === void 0) return void 0;
|
|
5063
5414
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5064
5415
|
const entries = Object.entries(record4);
|
|
5065
5416
|
if (entries.length === 0)
|
|
5066
|
-
throw invalidScenario(scenarioPath, `${objectPath} must name at least one
|
|
5417
|
+
throw invalidScenario(scenarioPath, `${objectPath} must name at least one render pass.`);
|
|
5067
5418
|
const budget = {};
|
|
5068
|
-
for (const [
|
|
5069
|
-
if (!
|
|
5419
|
+
for (const [pass, ceiling] of entries) {
|
|
5420
|
+
if (!PLAYTEST_FRAME_PASS_KINDS.includes(pass))
|
|
5070
5421
|
throw invalidScenario(
|
|
5071
5422
|
scenarioPath,
|
|
5072
|
-
`${objectPath}.${
|
|
5423
|
+
`${objectPath}.${pass} is not a render pass. Expected one of: ${PLAYTEST_FRAME_PASS_KINDS.join(", ")}.`
|
|
5073
5424
|
);
|
|
5074
5425
|
if (typeof ceiling !== "number" || !Number.isFinite(ceiling) || ceiling < 0)
|
|
5075
|
-
throw invalidScenario(scenarioPath, `${objectPath}.${
|
|
5076
|
-
budget[
|
|
5426
|
+
throw invalidScenario(scenarioPath, `${objectPath}.${pass} must be a non-negative number of draw calls or triangles.`);
|
|
5427
|
+
budget[pass] = ceiling;
|
|
5077
5428
|
}
|
|
5078
5429
|
return budget;
|
|
5079
5430
|
}
|
|
5080
|
-
function
|
|
5431
|
+
function validatePhaseBudget(value, scenarioPath, objectPath) {
|
|
5432
|
+
if (value === void 0) return void 0;
|
|
5081
5433
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5082
|
-
|
|
5434
|
+
const entries = Object.entries(record4);
|
|
5435
|
+
if (entries.length === 0)
|
|
5436
|
+
throw invalidScenario(scenarioPath, `${objectPath} must name at least one frame-budget phase.`);
|
|
5437
|
+
const budget = {};
|
|
5438
|
+
for (const [phase, ceiling] of entries) {
|
|
5439
|
+
if (!PLAYTEST_FRAME_BUDGET_PHASES.includes(phase))
|
|
5440
|
+
throw invalidScenario(
|
|
5441
|
+
scenarioPath,
|
|
5442
|
+
`${objectPath}.${phase} is not a frame-budget phase. Expected one of: ${PLAYTEST_FRAME_BUDGET_PHASES.join(", ")}.`
|
|
5443
|
+
);
|
|
5444
|
+
if (typeof ceiling !== "number" || !Number.isFinite(ceiling) || ceiling < 0)
|
|
5445
|
+
throw invalidScenario(scenarioPath, `${objectPath}.${phase} must be a non-negative number of milliseconds.`);
|
|
5446
|
+
budget[phase] = ceiling;
|
|
5447
|
+
}
|
|
5448
|
+
return budget;
|
|
5449
|
+
}
|
|
5450
|
+
function validateFramebufferCoverageAssertion(value, scenarioPath, objectPath) {
|
|
5451
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5452
|
+
rejectUnknownKeys(record4, ["backdrop", "grid", "tolerance", "window"], scenarioPath, objectPath);
|
|
5083
5453
|
const backdrop = requireArray(record4, "backdrop", scenarioPath, objectPath);
|
|
5084
5454
|
if (backdrop.length !== 3 || backdrop.some((channel) => typeof channel !== "number" || !Number.isInteger(channel) || channel < 0 || channel > 255)) {
|
|
5085
5455
|
throw invalidScenario(
|
|
@@ -5520,32 +5890,28 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
5520
5890
|
`assert.${kind}${suffix}.runtime`
|
|
5521
5891
|
);
|
|
5522
5892
|
}
|
|
5523
|
-
if (kind === "renderChain"
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
scenarioPath,
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
scenarioPath,
|
|
5536
|
-
`assert.${kind}${suffix}.contributions`
|
|
5537
|
-
);
|
|
5893
|
+
if (kind === "renderChain") {
|
|
5894
|
+
rejectRenderChainExpectationKeys(value, scenarioPath, `assert.${kind}${suffix}`);
|
|
5895
|
+
if (isRecord3(value.perAdapter)) {
|
|
5896
|
+
const branchPath = `assert.renderChain${suffix}.perAdapter`;
|
|
5897
|
+
rejectUnknownKeys(value.perAdapter, ["hardware", "software"], scenarioPath, branchPath);
|
|
5898
|
+
for (const [adapterKind, branch] of Object.entries(value.perAdapter)) {
|
|
5899
|
+
if (isRecord3(branch)) {
|
|
5900
|
+
rejectUnknownKeys(branch, ["contributions", "stages", "tier", "velocity"], scenarioPath, `${branchPath}.${adapterKind}`);
|
|
5901
|
+
rejectRenderChainExpectationKeys(branch, scenarioPath, `${branchPath}.${adapterKind}`);
|
|
5902
|
+
}
|
|
5903
|
+
}
|
|
5904
|
+
}
|
|
5538
5905
|
}
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
scenarioPath,
|
|
5544
|
-
|
|
5545
|
-
);
|
|
5906
|
+
}
|
|
5907
|
+
function rejectRenderChainExpectationKeys(value, scenarioPath, objectPath) {
|
|
5908
|
+
for (const [field, keys] of Object.entries(RENDER_CHAIN_NESTED_KEYS)) {
|
|
5909
|
+
if (isRecord3(value[field])) {
|
|
5910
|
+
rejectUnknownKeys(value[field], keys, scenarioPath, `${objectPath}.${field}`);
|
|
5911
|
+
}
|
|
5546
5912
|
}
|
|
5547
5913
|
}
|
|
5548
|
-
var STARTUP_CEILINGS, SCENE_FLAGS, SCENE_NODE_SELECTOR_KEYS, SCENE_NODE_BOUNDS;
|
|
5914
|
+
var STARTUP_CEILINGS, SCENE_FLAGS, SCENE_NODE_SELECTOR_KEYS, SCENE_NODE_BOUNDS, RENDER_CHAIN_NESTED_KEYS;
|
|
5549
5915
|
var init_schema_accessors = __esm({
|
|
5550
5916
|
"src/scenario/schema-accessors.ts"() {
|
|
5551
5917
|
init_assertions();
|
|
@@ -5557,6 +5923,11 @@ var init_schema_accessors = __esm({
|
|
|
5557
5923
|
SCENE_FLAGS = ["cameraClearsScene", "fogClearsScene", "litMaterialsAreLit"];
|
|
5558
5924
|
SCENE_NODE_SELECTOR_KEYS = ["limit", "name", "nameContains", "pathContains", "type"];
|
|
5559
5925
|
SCENE_NODE_BOUNDS = ["animated", "inFrustum", "maxCount", "minCount", "minTriangles", "texturesLoaded", "visible"];
|
|
5926
|
+
RENDER_CHAIN_NESTED_KEYS = {
|
|
5927
|
+
contributions: ["graphOutputChanged"],
|
|
5928
|
+
stages: ["excludes", "includes", "order"],
|
|
5929
|
+
velocity: ["maxRejectionFraction"]
|
|
5930
|
+
};
|
|
5560
5931
|
}
|
|
5561
5932
|
});
|
|
5562
5933
|
|
|
@@ -5854,6 +6225,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
5854
6225
|
"holdFrames",
|
|
5855
6226
|
"holdTicks",
|
|
5856
6227
|
"kind",
|
|
6228
|
+
"lifecycle",
|
|
5857
6229
|
"overlayMessage",
|
|
5858
6230
|
"pitch",
|
|
5859
6231
|
"pointerPosition",
|
|
@@ -5903,9 +6275,9 @@ function validateStep(value, scenarioPath, index) {
|
|
|
5903
6275
|
const holdTicks = positiveInteger(value.holdTicks);
|
|
5904
6276
|
const waitFrames2 = positiveInteger(value.waitFrames);
|
|
5905
6277
|
const waitTicks = positiveInteger(value.waitTicks);
|
|
5906
|
-
const kind = value.kind === "aimAt" ? "aimAt" : value.kind === "click" ? "click" : value.kind === "wait" ? "wait" : value.kind === "input" ? "input" : void 0;
|
|
6278
|
+
const kind = value.kind === "aimAt" ? "aimAt" : value.kind === "click" ? "click" : value.kind === "lifecycle" ? "lifecycle" : value.kind === "wait" ? "wait" : value.kind === "input" ? "input" : void 0;
|
|
5907
6279
|
if (value.kind !== void 0 && kind === void 0) {
|
|
5908
|
-
throw invalidStep(scenarioPath, `Scenario step ${index} kind must be 'aimAt', 'click', 'input', or 'wait'.`);
|
|
6280
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} kind must be 'aimAt', 'click', 'input', 'lifecycle', or 'wait'.`);
|
|
5909
6281
|
}
|
|
5910
6282
|
const at = validateClickTarget(value.at, scenarioPath, index);
|
|
5911
6283
|
const target = validateAimTarget(value.target, scenarioPath, index);
|
|
@@ -5919,6 +6291,10 @@ function validateStep(value, scenarioPath, index) {
|
|
|
5919
6291
|
if (isRecord3(value.window)) {
|
|
5920
6292
|
rejectUnknownKeys(value.window, ["height", "operation", "width"], scenarioPath, `steps[${index}].window`);
|
|
5921
6293
|
}
|
|
6294
|
+
if (isRecord3(value.lifecycle)) {
|
|
6295
|
+
rejectUnknownKeys(value.lifecycle, ["operation", "rotation"], scenarioPath, `steps[${index}].lifecycle`);
|
|
6296
|
+
}
|
|
6297
|
+
const lifecycle = validateLifecycleStep(value.lifecycle, scenarioPath, index);
|
|
5922
6298
|
if (kind !== "click" && (at !== void 0 || value.at !== void 0)) {
|
|
5923
6299
|
throw invalidStep(scenarioPath, `Scenario step ${index} declares at, which belongs to kind 'click'.`);
|
|
5924
6300
|
}
|
|
@@ -5985,8 +6361,38 @@ function validateStep(value, scenarioPath, index) {
|
|
|
5985
6361
|
if (value.window !== void 0 && window2 === void 0) {
|
|
5986
6362
|
throw invalidStep(scenarioPath, `Scenario step ${index} window must define minimize, restore, or resize with positive width and height.`);
|
|
5987
6363
|
}
|
|
5988
|
-
if (
|
|
5989
|
-
throw invalidStep(scenarioPath, `Scenario step ${index} must define
|
|
6364
|
+
if (value.lifecycle !== void 0 && lifecycle === void 0) {
|
|
6365
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} lifecycle must define an operation of 'background', 'foreground', or 'rotate', and 'rotate' must name a rotation from 0 through 3.`);
|
|
6366
|
+
}
|
|
6367
|
+
if (kind !== "lifecycle" && value.lifecycle !== void 0) {
|
|
6368
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} declares lifecycle, which belongs to kind 'lifecycle'.`);
|
|
6369
|
+
}
|
|
6370
|
+
if (kind === "lifecycle") {
|
|
6371
|
+
if (lifecycle === void 0) {
|
|
6372
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} with kind 'lifecycle' must define lifecycle.operation.`);
|
|
6373
|
+
}
|
|
6374
|
+
for (const forbidden of [
|
|
6375
|
+
"holdFrames",
|
|
6376
|
+
"holdTicks",
|
|
6377
|
+
"label",
|
|
6378
|
+
"overlayMessage",
|
|
6379
|
+
"pointerPosition",
|
|
6380
|
+
"pointers",
|
|
6381
|
+
"press",
|
|
6382
|
+
"screenshot",
|
|
6383
|
+
"target",
|
|
6384
|
+
"waitFrames",
|
|
6385
|
+
"waitTicks",
|
|
6386
|
+
"wheel",
|
|
6387
|
+
"window"
|
|
6388
|
+
]) {
|
|
6389
|
+
if (value[forbidden] !== void 0) {
|
|
6390
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} with kind 'lifecycle' cannot define ${forbidden}; a lifecycle step is one device operation and nothing else.`);
|
|
6391
|
+
}
|
|
6392
|
+
}
|
|
6393
|
+
}
|
|
6394
|
+
if (at === void 0 && press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && pointers === void 0 && wheel === void 0 && window2 === void 0 && waitFrames2 === void 0 && waitTicks === void 0 && target === void 0 && waitForResource2 === void 0 && lifecycle === void 0) {
|
|
6395
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must define click at, press, overlayMessage, pointerPosition, pointers, wheel, window, aimAt target, lifecycle operation, or waitFrames/waitTicks.`);
|
|
5990
6396
|
}
|
|
5991
6397
|
if (value.holdFrames !== void 0 && holdFrames === void 0) {
|
|
5992
6398
|
throw invalidStep(scenarioPath, `Scenario step ${index} holdFrames must be a positive integer.`);
|
|
@@ -6015,6 +6421,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6015
6421
|
...holdTicks === void 0 ? {} : { holdTicks },
|
|
6016
6422
|
...typeof value.label === "string" ? { label: value.label } : {},
|
|
6017
6423
|
...at === void 0 ? {} : { at },
|
|
6424
|
+
...lifecycle === void 0 ? {} : { lifecycle },
|
|
6018
6425
|
...overlayMessage === void 0 ? {} : { overlayMessage },
|
|
6019
6426
|
...pitch === void 0 ? {} : { pitch },
|
|
6020
6427
|
...pointerPosition === void 0 ? {} : { pointerPosition },
|
|
@@ -6031,6 +6438,22 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6031
6438
|
...window2 === void 0 ? {} : { window: window2 }
|
|
6032
6439
|
};
|
|
6033
6440
|
}
|
|
6441
|
+
function validateLifecycleStep(value, scenarioPath, index) {
|
|
6442
|
+
if (!isRecord3(value)) return void 0;
|
|
6443
|
+
const rotation = value.rotation;
|
|
6444
|
+
const rotationValue = typeof rotation === "number" && Number.isInteger(rotation) && rotation >= 0 && rotation <= 3 ? rotation : void 0;
|
|
6445
|
+
if (value.operation === "rotate") {
|
|
6446
|
+
if (rotationValue === void 0) {
|
|
6447
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} lifecycle.operation 'rotate' must name a rotation from 0 through 3.`);
|
|
6448
|
+
}
|
|
6449
|
+
return { operation: "rotate", rotation: rotationValue };
|
|
6450
|
+
}
|
|
6451
|
+
if (value.operation !== "background" && value.operation !== "foreground") return void 0;
|
|
6452
|
+
if (rotation !== void 0) {
|
|
6453
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} lifecycle.operation '${value.operation}' cannot define rotation; only 'rotate' takes one.`);
|
|
6454
|
+
}
|
|
6455
|
+
return { operation: value.operation };
|
|
6456
|
+
}
|
|
6034
6457
|
function validateResourceWait(value, scenarioPath, index) {
|
|
6035
6458
|
const objectPath = `steps[${index}].waitForResource`;
|
|
6036
6459
|
if (!isRecord3(value)) {
|
|
@@ -6052,8 +6475,8 @@ function validateResourceWait(value, scenarioPath, index) {
|
|
|
6052
6475
|
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.lte must be a finite number.`);
|
|
6053
6476
|
}
|
|
6054
6477
|
const id = requireString(value, "id", scenarioPath, objectPath);
|
|
6055
|
-
const
|
|
6056
|
-
if (
|
|
6478
|
+
const path2 = requireString(value, "path", scenarioPath, objectPath);
|
|
6479
|
+
if (path2.split(".").some((part) => part.length === 0)) {
|
|
6057
6480
|
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.path must be a non-empty dot path.`);
|
|
6058
6481
|
}
|
|
6059
6482
|
return {
|
|
@@ -6061,7 +6484,7 @@ function validateResourceWait(value, scenarioPath, index) {
|
|
|
6061
6484
|
...gte === void 0 ? {} : { gte },
|
|
6062
6485
|
id,
|
|
6063
6486
|
...lte === void 0 ? {} : { lte },
|
|
6064
|
-
path
|
|
6487
|
+
path: path2
|
|
6065
6488
|
};
|
|
6066
6489
|
}
|
|
6067
6490
|
function validateClickTarget(value, scenarioPath, index) {
|
|
@@ -6096,17 +6519,17 @@ function validateAimTarget(value, scenarioPath, stepIndex) {
|
|
|
6096
6519
|
return { x, z };
|
|
6097
6520
|
}
|
|
6098
6521
|
function validatePointer(value, scenarioPath, stepIndex, pointerIndex) {
|
|
6099
|
-
const
|
|
6100
|
-
if (!isRecord3(value)) throw invalidStep(scenarioPath, `${
|
|
6101
|
-
rejectUnknownKeys(value, ["buttons", "id", "x", "y"], scenarioPath,
|
|
6522
|
+
const path2 = `steps[${stepIndex}].pointers[${pointerIndex}]`;
|
|
6523
|
+
if (!isRecord3(value)) throw invalidStep(scenarioPath, `${path2} must be an object.`);
|
|
6524
|
+
rejectUnknownKeys(value, ["buttons", "id", "x", "y"], scenarioPath, path2);
|
|
6102
6525
|
if (!Number.isInteger(value.id) || value.id < 1) {
|
|
6103
|
-
throw invalidStep(scenarioPath, `${
|
|
6526
|
+
throw invalidStep(scenarioPath, `${path2}.id must be a positive integer.`);
|
|
6104
6527
|
}
|
|
6105
6528
|
if (typeof value.x !== "number" || !Number.isFinite(value.x) || value.x < 0 || value.x > 1 || typeof value.y !== "number" || !Number.isFinite(value.y) || value.y < 0 || value.y > 1) {
|
|
6106
|
-
throw invalidStep(scenarioPath, `${
|
|
6529
|
+
throw invalidStep(scenarioPath, `${path2} must define normalized x and y values from 0 through 1.`);
|
|
6107
6530
|
}
|
|
6108
6531
|
if (value.buttons !== void 0 && (!Number.isInteger(value.buttons) || value.buttons < 1)) {
|
|
6109
|
-
throw invalidStep(scenarioPath, `${
|
|
6532
|
+
throw invalidStep(scenarioPath, `${path2}.buttons must be a positive integer when present.`);
|
|
6110
6533
|
}
|
|
6111
6534
|
return {
|
|
6112
6535
|
...typeof value.buttons === "number" ? { buttons: value.buttons } : {},
|
|
@@ -6128,9 +6551,9 @@ function validateStepLabels(steps, assertions, scenarioPath) {
|
|
|
6128
6551
|
labels.add(step.label);
|
|
6129
6552
|
}
|
|
6130
6553
|
if (assertions === void 0) return;
|
|
6131
|
-
const requireLabel = (label,
|
|
6554
|
+
const requireLabel = (label, path2) => {
|
|
6132
6555
|
if (label !== void 0 && !labels.has(label)) {
|
|
6133
|
-
throw invalidScenario(scenarioPath, `Assertion '${
|
|
6556
|
+
throw invalidScenario(scenarioPath, `Assertion '${path2}' names step label '${label}', but no scenario step defines it.`);
|
|
6134
6557
|
}
|
|
6135
6558
|
};
|
|
6136
6559
|
for (const [index, assertion] of (assertions.resources ?? []).entries()) {
|
|
@@ -6168,14 +6591,16 @@ function validateStepLabels(steps, assertions, scenarioPath) {
|
|
|
6168
6591
|
}
|
|
6169
6592
|
}
|
|
6170
6593
|
function playtestStepHoldTicks(step, fallback = 1) {
|
|
6171
|
-
|
|
6594
|
+
const pointerHold = (step.pointers !== void 0 || step.pointerPosition !== void 0) && step.holdTicks !== void 0;
|
|
6595
|
+
if (step.press === void 0 && !pointerHold || step.holdFrames !== void 0 || step.waitFrames !== void 0)
|
|
6596
|
+
return 0;
|
|
6172
6597
|
return Math.max(1, step.holdTicks ?? fallback);
|
|
6173
6598
|
}
|
|
6174
6599
|
function playtestStepWaitTicks(step) {
|
|
6175
6600
|
return step.waitFrames === void 0 ? Math.max(0, step.waitTicks ?? 0) : 0;
|
|
6176
6601
|
}
|
|
6177
6602
|
function validateAssertions(value, scenarioPath) {
|
|
6178
|
-
rejectUnknownKeys(value, PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), scenarioPath, "assert");
|
|
6603
|
+
rejectUnknownKeys(value, [...PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), "geometry"], scenarioPath, "assert");
|
|
6179
6604
|
validateAssertionShapes(value, scenarioPath);
|
|
6180
6605
|
validateAssertionKeys(value, scenarioPath);
|
|
6181
6606
|
if (Array.isArray(value.signals) && value.signals.length === 0) {
|
|
@@ -6201,6 +6626,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6201
6626
|
const renderChain = value.renderChain === void 0 ? void 0 : validateRenderChainAssertion(value.renderChain, scenarioPath, "assert.renderChain");
|
|
6202
6627
|
const startup = value.startup === void 0 ? void 0 : validateStartupAssertion(value.startup, scenarioPath, "assert.startup");
|
|
6203
6628
|
const scene = value.scene === void 0 ? void 0 : validateSceneAssertion(value.scene, scenarioPath, "assert.scene");
|
|
6629
|
+
const geometry = value.geometry === void 0 ? void 0 : validateGeometryCaptureRequest(value.geometry, scenarioPath, "assert.geometry");
|
|
6204
6630
|
const world = isRecord3(value.world) ? value.world : void 0;
|
|
6205
6631
|
const optOuts = [
|
|
6206
6632
|
["noConsoleErrors", "consoleErrorsOptOutReason"],
|
|
@@ -6218,6 +6644,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6218
6644
|
return {
|
|
6219
6645
|
...Array.isArray(value.aerodynamics) ? { aerodynamics: value.aerodynamics.map((entry, index) => validateAerodynamicsAssertion(entry, scenarioPath, `assert.aerodynamics[${index}]`)) } : {},
|
|
6220
6646
|
...Array.isArray(value.animation) ? { animation: value.animation.map((entry, index) => validateAnimationAssertion(entry, scenarioPath, `assert.animation[${index}]`)) } : {},
|
|
6647
|
+
...Array.isArray(value.audio) ? { audio: value.audio.map((entry, index) => validateAudioAssertion(entry, scenarioPath, `assert.audio[${index}]`)) } : {},
|
|
6221
6648
|
...camera === void 0 ? {} : {
|
|
6222
6649
|
camera: {
|
|
6223
6650
|
...typeof camera.entity === "string" ? { entity: camera.entity } : {},
|
|
@@ -6250,6 +6677,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6250
6677
|
...renderChain === void 0 ? {} : { renderChain },
|
|
6251
6678
|
...startup === void 0 ? {} : { startup },
|
|
6252
6679
|
...scene === void 0 ? {} : { scene },
|
|
6680
|
+
...geometry === void 0 ? {} : { geometry },
|
|
6253
6681
|
...hasKey(value, "causedBy") ? {
|
|
6254
6682
|
causedBy: requireArray(value, "causedBy", scenarioPath, "assert.causedBy").map((entry, index) => validateCausedByAssertion(entry, scenarioPath, `assert.causedBy[${index}]`))
|
|
6255
6683
|
} : {},
|
|
@@ -6309,6 +6737,34 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6309
6737
|
...world === void 0 ? {} : { world: validateWorldAssertion(world, scenarioPath) }
|
|
6310
6738
|
};
|
|
6311
6739
|
}
|
|
6740
|
+
function validateAudioAssertion(value, scenarioPath, objectPath) {
|
|
6741
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
6742
|
+
rejectUnknownKeys(record4, ["cue", "maxPlays", "minGapMs", "minPlays"], scenarioPath, objectPath);
|
|
6743
|
+
if (typeof record4.cue !== "string" || record4.cue.trim() === "")
|
|
6744
|
+
throw invalidScenario(scenarioPath, `Assertion '${objectPath}.cue' must be a non-empty string.`);
|
|
6745
|
+
const bound = (name) => {
|
|
6746
|
+
const raw = record4[name];
|
|
6747
|
+
if (raw === void 0) return void 0;
|
|
6748
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0)
|
|
6749
|
+
throw invalidScenario(scenarioPath, `Assertion '${objectPath}.${name}' must be a non-negative integer.`);
|
|
6750
|
+
return raw;
|
|
6751
|
+
};
|
|
6752
|
+
const minPlays = bound("minPlays");
|
|
6753
|
+
const maxPlays = bound("maxPlays");
|
|
6754
|
+
const minGapMs = bound("minGapMs");
|
|
6755
|
+
if (minPlays !== void 0 && maxPlays !== void 0 && maxPlays < minPlays) {
|
|
6756
|
+
throw invalidScenario(
|
|
6757
|
+
scenarioPath,
|
|
6758
|
+
`Assertion '${objectPath}' cannot require at least ${minPlays} play(s) and at most ${maxPlays}.`
|
|
6759
|
+
);
|
|
6760
|
+
}
|
|
6761
|
+
return {
|
|
6762
|
+
cue: record4.cue,
|
|
6763
|
+
...maxPlays === void 0 ? {} : { maxPlays },
|
|
6764
|
+
...minGapMs === void 0 ? {} : { minGapMs },
|
|
6765
|
+
...minPlays === void 0 ? {} : { minPlays }
|
|
6766
|
+
};
|
|
6767
|
+
}
|
|
6312
6768
|
function validateWorldAssertion(value, scenarioPath) {
|
|
6313
6769
|
rejectUnknownKeys(value, ["runtime", "seed"], scenarioPath, "assert.world");
|
|
6314
6770
|
if (!hasKey(value, "seed") || value.seed !== null && (typeof value.seed !== "number" || !Number.isFinite(value.seed))) {
|
|
@@ -6475,6 +6931,24 @@ function validateOccludedAssertion(value, scenarioPath, objectPath) {
|
|
|
6475
6931
|
...present("target", optionalString(record4, "target", scenarioPath, objectPath))
|
|
6476
6932
|
};
|
|
6477
6933
|
}
|
|
6934
|
+
function validateGeometryCaptureRequest(value, scenarioPath, objectPath) {
|
|
6935
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
6936
|
+
rejectUnknownKeys(record4, ["limit", "sort", "timeoutMs"], scenarioPath, objectPath);
|
|
6937
|
+
if (record4.limit !== void 0 && (typeof record4.limit !== "number" || !Number.isInteger(record4.limit) || record4.limit < 1 || record4.limit > 500)) {
|
|
6938
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.limit' must be an integer from 1 to 500, received ${describeValue(record4.limit)}.`);
|
|
6939
|
+
}
|
|
6940
|
+
if (record4.sort !== void 0 && record4.sort !== "triangles" && record4.sort !== "draws" && record4.sort !== "projected") {
|
|
6941
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.sort' must be one of triangles, draws, projected, received ${describeValue(record4.sort)}.`);
|
|
6942
|
+
}
|
|
6943
|
+
if (record4.timeoutMs !== void 0 && (typeof record4.timeoutMs !== "number" || !Number.isFinite(record4.timeoutMs) || record4.timeoutMs <= 0)) {
|
|
6944
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.timeoutMs' must be a positive finite number, received ${describeValue(record4.timeoutMs)}.`);
|
|
6945
|
+
}
|
|
6946
|
+
return {
|
|
6947
|
+
...record4.limit === void 0 ? {} : { limit: record4.limit },
|
|
6948
|
+
...record4.sort === void 0 ? {} : { sort: record4.sort },
|
|
6949
|
+
...record4.timeoutMs === void 0 ? {} : { timeoutMs: record4.timeoutMs }
|
|
6950
|
+
};
|
|
6951
|
+
}
|
|
6478
6952
|
var PLAYTEST_ROOT_KEYS, PLAYTEST_STEP_KEYS, MAX_RESOURCE_WAIT_TIMEOUT_MS;
|
|
6479
6953
|
var init_schema_validate = __esm({
|
|
6480
6954
|
"src/scenario/schema-validate.ts"() {
|
|
@@ -6505,6 +6979,7 @@ var init_schema_validate = __esm({
|
|
|
6505
6979
|
"holdTicks",
|
|
6506
6980
|
"kind",
|
|
6507
6981
|
"label",
|
|
6982
|
+
"lifecycle",
|
|
6508
6983
|
"overlayMessage",
|
|
6509
6984
|
"pitch",
|
|
6510
6985
|
"pointerPosition",
|
|
@@ -6688,73 +7163,6 @@ var init_scenario = __esm({
|
|
|
6688
7163
|
}
|
|
6689
7164
|
});
|
|
6690
7165
|
|
|
6691
|
-
// src/runner/browser.ts
|
|
6692
|
-
var browser_exports = {};
|
|
6693
|
-
__export(browser_exports, {
|
|
6694
|
-
PERFORMANCE_BROWSER_ARGS: () => PERFORMANCE_BROWSER_ARGS,
|
|
6695
|
-
WEBGPU_BROWSER_ARGS: () => WEBGPU_BROWSER_ARGS,
|
|
6696
|
-
reconcileBrowserPointers: () => reconcileBrowserPointers,
|
|
6697
|
-
resolveBrowserArguments: () => resolveBrowserArguments,
|
|
6698
|
-
softwareAdapterName: () => softwareAdapterName
|
|
6699
|
-
});
|
|
6700
|
-
function resolveBrowserArguments(browserArgs) {
|
|
6701
|
-
return [...browserArgs ?? []];
|
|
6702
|
-
}
|
|
6703
|
-
function softwareAdapterName(adapter) {
|
|
6704
|
-
if (adapter === void 0) return void 0;
|
|
6705
|
-
for (const value of Object.values(adapter)) {
|
|
6706
|
-
if (typeof value === "string" && SOFTWARE_ADAPTER.test(value)) return value;
|
|
6707
|
-
}
|
|
6708
|
-
return void 0;
|
|
6709
|
-
}
|
|
6710
|
-
function reconcileBrowserPointers(previous, next) {
|
|
6711
|
-
const normalized = new Map(next.map((pointer) => [pointer.id, {
|
|
6712
|
-
buttons: pointer.buttons ?? 1,
|
|
6713
|
-
id: pointer.id,
|
|
6714
|
-
x: pointer.x,
|
|
6715
|
-
y: pointer.y
|
|
6716
|
-
}]));
|
|
6717
|
-
const previousPrimary = previous.keys().next().value;
|
|
6718
|
-
const nextPrimary = normalized.keys().next().value;
|
|
6719
|
-
const changes = [];
|
|
6720
|
-
for (const pointer of previous.values()) {
|
|
6721
|
-
if (!normalized.has(pointer.id)) {
|
|
6722
|
-
changes.push({ isPrimary: pointer.id === previousPrimary, pointer: { ...pointer, buttons: 0 }, type: "pointerup" });
|
|
6723
|
-
}
|
|
6724
|
-
}
|
|
6725
|
-
for (const pointer of normalized.values()) {
|
|
6726
|
-
const old = previous.get(pointer.id);
|
|
6727
|
-
if (old === void 0) {
|
|
6728
|
-
changes.push({ isPrimary: pointer.id === nextPrimary, pointer, type: "pointerdown" });
|
|
6729
|
-
} else if (old.x !== pointer.x || old.y !== pointer.y || old.buttons !== pointer.buttons) {
|
|
6730
|
-
changes.push({ isPrimary: pointer.id === nextPrimary, pointer, type: "pointermove" });
|
|
6731
|
-
}
|
|
6732
|
-
}
|
|
6733
|
-
return changes;
|
|
6734
|
-
}
|
|
6735
|
-
var WEBGPU_BROWSER_ARGS, PERFORMANCE_BROWSER_ARGS, SOFTWARE_ADAPTER;
|
|
6736
|
-
var init_browser = __esm({
|
|
6737
|
-
"src/runner/browser.ts"() {
|
|
6738
|
-
WEBGPU_BROWSER_ARGS = [
|
|
6739
|
-
"--ozone-platform=x11",
|
|
6740
|
-
"--enable-unsafe-webgpu",
|
|
6741
|
-
"--disable-gpu-sandbox",
|
|
6742
|
-
"--ignore-gpu-blocklist",
|
|
6743
|
-
// Without this Chromium never reaches the Vulkan driver on Linux and silently serves WebGPU
|
|
6744
|
-
// from SwiftShader, its CPU rasteriser. Nothing errors: the adapter answers, the run
|
|
6745
|
-
// proceeds, and the results are a software renderer's. Measured on an RTX 2080 under Xvfb,
|
|
6746
|
-
// `adapter.info` reads `swiftshader / google` without the flag and `turing / nvidia` with it,
|
|
6747
|
-
// which is the difference between blank captures and a rendered frame.
|
|
6748
|
-
"--enable-features=Vulkan"
|
|
6749
|
-
];
|
|
6750
|
-
PERFORMANCE_BROWSER_ARGS = [
|
|
6751
|
-
"--disable-frame-rate-limit",
|
|
6752
|
-
"--disable-gpu-vsync"
|
|
6753
|
-
];
|
|
6754
|
-
SOFTWARE_ADAPTER = /swiftshader|llvmpipe|lavapipe|softwarerasterizer|software adapter|basic render/i;
|
|
6755
|
-
}
|
|
6756
|
-
});
|
|
6757
|
-
|
|
6758
7166
|
// src/runner/deviceMetrics.ts
|
|
6759
7167
|
function parseDeviceBattery(output) {
|
|
6760
7168
|
const source = String(output);
|
|
@@ -7067,6 +7475,7 @@ var init_capabilities = __esm({
|
|
|
7067
7475
|
capability("runtime.diagnostics", "Captures application runtime errors."),
|
|
7068
7476
|
capability("runtime.events", "Drains bounded application event observations."),
|
|
7069
7477
|
capability("runtime.fixedStep", "Advances an application-owned deterministic tick."),
|
|
7478
|
+
capability("runtime.geometry", "Answers one armed per-object geometry capture for the frame it was requested on."),
|
|
7070
7479
|
capability("runtime.physics", "Samples bounded application-owned physics observations."),
|
|
7071
7480
|
capability("runtime.performance", "Samples bounded per-render frame cost and renderer counts."),
|
|
7072
7481
|
capability("runtime.pipelineCensus", "Samples bounded shader and pipeline creation observations."),
|
|
@@ -7114,6 +7523,8 @@ var init_index = __esm({
|
|
|
7114
7523
|
init_diagnostics();
|
|
7115
7524
|
init_protocol();
|
|
7116
7525
|
init_scenario();
|
|
7526
|
+
init_scenario();
|
|
7527
|
+
init_scenario();
|
|
7117
7528
|
}
|
|
7118
7529
|
});
|
|
7119
7530
|
|
|
@@ -7127,6 +7538,7 @@ var init_observationFields = __esm({
|
|
|
7127
7538
|
"console",
|
|
7128
7539
|
"effectLogBefore",
|
|
7129
7540
|
"framebufferCoverage",
|
|
7541
|
+
"geometry",
|
|
7130
7542
|
"hud",
|
|
7131
7543
|
"network",
|
|
7132
7544
|
"physicsDebugSeries",
|
|
@@ -7146,7 +7558,7 @@ var init_observationFields = __esm({
|
|
|
7146
7558
|
"startup",
|
|
7147
7559
|
"visual"
|
|
7148
7560
|
];
|
|
7149
|
-
HOST_PLAYTEST_OBSERVATION_FIELDS = ["deviceMetrics"];
|
|
7561
|
+
HOST_PLAYTEST_OBSERVATION_FIELDS = ["deviceLifecycle", "deviceMetrics"];
|
|
7150
7562
|
}
|
|
7151
7563
|
});
|
|
7152
7564
|
|
|
@@ -7250,9 +7662,9 @@ function setupRequest(scenario) {
|
|
|
7250
7662
|
}))
|
|
7251
7663
|
},
|
|
7252
7664
|
...scenario.setup?.resources === void 0 ? {} : {
|
|
7253
|
-
resources: scenario.setup.resources.map(({ id, path, value }) => ({
|
|
7665
|
+
resources: scenario.setup.resources.map(({ id, path: path2, value }) => ({
|
|
7254
7666
|
id,
|
|
7255
|
-
...
|
|
7667
|
+
...path2 === void 0 ? {} : { path: path2 },
|
|
7256
7668
|
value
|
|
7257
7669
|
}))
|
|
7258
7670
|
}
|
|
@@ -7338,11 +7750,12 @@ function managedServerError(message, url, timeoutMs, output) {
|
|
|
7338
7750
|
"Run the server command directly, fix its first error, then rerun the same playtest command."
|
|
7339
7751
|
));
|
|
7340
7752
|
}
|
|
7341
|
-
var UNHANDLED_REJECTION_PREFIX, MAX_FIXED_STEP_STARTUP_RETRIES, STOPPED_LOOP_ERROR, ManagedServerError;
|
|
7753
|
+
var UNHANDLED_REJECTION_PREFIX, SCREENSHOT_TIMEOUT_MS, MAX_FIXED_STEP_STARTUP_RETRIES, STOPPED_LOOP_ERROR, ManagedServerError;
|
|
7342
7754
|
var init_shared = __esm({
|
|
7343
7755
|
"src/runner/shared.ts"() {
|
|
7344
7756
|
init_index();
|
|
7345
7757
|
UNHANDLED_REJECTION_PREFIX = "__THREENATIVE_PLAYTEST_UNHANDLED_REJECTION__:";
|
|
7758
|
+
SCREENSHOT_TIMEOUT_MS = 12e4;
|
|
7346
7759
|
MAX_FIXED_STEP_STARTUP_RETRIES = 120;
|
|
7347
7760
|
STOPPED_LOOP_ERROR = "Cannot advance a stopped loop.";
|
|
7348
7761
|
ManagedServerError = class extends Error {
|
|
@@ -7569,13 +7982,13 @@ function unavailableObservation(scenario) {
|
|
|
7569
7982
|
reason: `Assertion '${entry.kind}' is not supported on target '${scenario.target}'.`
|
|
7570
7983
|
};
|
|
7571
7984
|
}
|
|
7572
|
-
for (const
|
|
7573
|
-
if (HOST_OBSERVATION_FIELD_SET.includes(
|
|
7574
|
-
if (!STANDALONE_OBSERVATION_FIELD_SET.includes(
|
|
7985
|
+
for (const path2 of requiredObservationPaths(scenario, entry.kind, entry.observationPath)) {
|
|
7986
|
+
if (HOST_OBSERVATION_FIELD_SET.includes(path2)) continue;
|
|
7987
|
+
if (!STANDALONE_OBSERVATION_FIELD_SET.includes(path2)) {
|
|
7575
7988
|
return {
|
|
7576
7989
|
assertion: entry.kind,
|
|
7577
|
-
path,
|
|
7578
|
-
reason: `The standalone runner does not produce an ${
|
|
7990
|
+
path: path2,
|
|
7991
|
+
reason: `The standalone runner does not produce an ${path2} observation required by this assertion.`
|
|
7579
7992
|
};
|
|
7580
7993
|
}
|
|
7581
7994
|
}
|
|
@@ -7790,6 +8203,10 @@ var init_capture = __esm({
|
|
|
7790
8203
|
// src/runner/cli.ts
|
|
7791
8204
|
init_scenario();
|
|
7792
8205
|
|
|
8206
|
+
// src/runner/buildReport.ts
|
|
8207
|
+
init_assertion_schema();
|
|
8208
|
+
init_schema_accessors();
|
|
8209
|
+
|
|
7793
8210
|
// src/runner/config.ts
|
|
7794
8211
|
init_browser();
|
|
7795
8212
|
var PLAYTEST_FLAGS = {
|
|
@@ -7803,16 +8220,22 @@ var PLAYTEST_FLAGS = {
|
|
|
7803
8220
|
"--activity": { default: ".MystralActivity", summary: "Android launch activity", takesValue: true },
|
|
7804
8221
|
"--user": { default: "current foreground Android user", summary: "Android user id for force-stop and launch", takesValue: true },
|
|
7805
8222
|
"--app": { default: "required for iOS", summary: "built iOS .app bundle", takesValue: true },
|
|
8223
|
+
"--artifact": { default: "none (browser and android: with --build-report)", summary: "the built artifact this run exercises, hashed to prove the build report describes it", takesValue: true },
|
|
7806
8224
|
"--artifacts": { default: "artifacts/playtest", summary: "artifact output directory", takesValue: true },
|
|
8225
|
+
"--build-report": { default: "none", summary: "the <artifact>.build-report.json threenative build published; its performanceBudget bounds every scenario, and a stale or foreign report refuses the run", takesValue: true },
|
|
7807
8226
|
"--no-screenshots": { default: "false", summary: "skip the before/after artifact frames; scenarios that assert on a frame still capture one", takesValue: false },
|
|
7808
8227
|
"--browser-arg": { allowDashValue: true, default: "none (repeatable)", repeatable: true, summary: "one additional Chromium argument", takesValue: true },
|
|
7809
8228
|
"--browser-recipe": { default: "none", summary: "named browser recipe (webgpu)", takesValue: true },
|
|
8229
|
+
"--cpu-prof": { default: "none", summary: "write a Chrome DevTools .cpuprofile for this run (browser and desktop targets)", takesValue: true },
|
|
7810
8230
|
"--bundle-id": { default: "dev.threenative.runtime", summary: "iOS application bundle identifier", takesValue: true },
|
|
7811
8231
|
"--device": { default: "platform default", summary: "Android serial or iOS device identifier", takesValue: true },
|
|
7812
8232
|
"--executable": { default: "required for desktop", summary: "native desktop game executable", takesValue: true },
|
|
7813
8233
|
"--endpoint": { default: "http://127.0.0.1:41777/playtest", summary: "device bridge endpoint", takesValue: true },
|
|
7814
8234
|
"--headed": { default: "false", summary: "show the browser window", takesValue: false },
|
|
7815
|
-
"--
|
|
8235
|
+
"--judge-marker-url": { default: "none", summary: "judge-owned loopback marker URL whose POST failures are not network errors", takesValue: true },
|
|
8236
|
+
// `allowDashValue` so a host flag can be passed as one: `--host-arg --ui` is the UI root the
|
|
8237
|
+
// overlay serves, and the parser would otherwise read `--ui` as a playtest flag and reject it.
|
|
8238
|
+
"--host-arg": { allowDashValue: true, default: "none", repeatable: true, summary: "argument passed to the native desktop host, repeatable", takesValue: true },
|
|
7816
8239
|
"--mailbox-root": { default: "Android external files directory", summary: "native device mailbox directory", takesValue: true },
|
|
7817
8240
|
"--ios-transport": { default: "simulator", summary: "iOS transport (simulator or device)", takesValue: true },
|
|
7818
8241
|
"--project": { default: ".", summary: "project root used to resolve paths", takesValue: true },
|
|
@@ -7858,6 +8281,9 @@ function formatUsage() {
|
|
|
7858
8281
|
" with repeatable --host-arg, or --logcat <serial>",
|
|
7859
8282
|
" bounds: --max-frame-p95 <ms>, --min-fps <fps>",
|
|
7860
8283
|
" --require-windows <n> (default 2), --timeout <s>, --text",
|
|
8284
|
+
" --allow-virtual-display accepts a frame rate the display did not",
|
|
8285
|
+
" see (a private Xvfb, or a loop the presentation cap outran); without",
|
|
8286
|
+
" it such a run prints no fps column and refuses a --min-fps bound",
|
|
7861
8287
|
" trace record a Chrome performance trace of a running game and name the",
|
|
7862
8288
|
" functions inside its slow frames \u2014 a percentile says a frame was",
|
|
7863
8289
|
" slow, a trace says which function. Take one BEFORE attributing any",
|
|
@@ -7907,6 +8333,16 @@ function formatUsage() {
|
|
|
7907
8333
|
" 1 assertions failed",
|
|
7908
8334
|
" 2 the run never reached assertions",
|
|
7909
8335
|
" 75 the capture lock timed out \u2014 not a test failure; rerun when the queue clears",
|
|
8336
|
+
"",
|
|
8337
|
+
"A build's own budgets:",
|
|
8338
|
+
" threenative build publishes <artifact>.build-report.json beside the artifact it wrote, and",
|
|
8339
|
+
" --build-report hands that to a run. The report is proved against the artifact under test",
|
|
8340
|
+
" (--artifact on browser and android; --executable / --app on desktop and iOS) and its",
|
|
8341
|
+
" performanceBudget is merged into every scenario's assert.performance, so a ceiling declared",
|
|
8342
|
+
" at build time bounds the run without being retyped into each scenario. A report that is",
|
|
8343
|
+
" malformed, was built for another target, or describes bytes that have since changed exits 2",
|
|
8344
|
+
" with TN_PLAYTEST_BUILD_REPORT_INVALID or TN_PLAYTEST_BUILD_REPORT_STALE \u2014 the run measured",
|
|
8345
|
+
" nothing, which is not the same as a game that failed.",
|
|
7910
8346
|
""
|
|
7911
8347
|
].join("\n");
|
|
7912
8348
|
}
|
|
@@ -7952,6 +8388,19 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
7952
8388
|
throw new PlaytestCliUsageError("Choose --browser-recipe or --browser-arg, not both.");
|
|
7953
8389
|
}
|
|
7954
8390
|
const device = flags.get("--device")?.[0];
|
|
8391
|
+
const cpuProfilePath = flags.get("--cpu-prof")?.[0];
|
|
8392
|
+
const judgeMarkerUrl = flags.get("--judge-marker-url")?.[0];
|
|
8393
|
+
if (judgeMarkerUrl !== void 0) {
|
|
8394
|
+
let marker2;
|
|
8395
|
+
try {
|
|
8396
|
+
marker2 = new URL(judgeMarkerUrl);
|
|
8397
|
+
} catch {
|
|
8398
|
+
throw new PlaytestCliUsageError("--judge-marker-url must be a canonical http://127.0.0.1:<port>/first-frame URL for browser runs.");
|
|
8399
|
+
}
|
|
8400
|
+
if (marker2.href !== judgeMarkerUrl || marker2.protocol !== "http:" || marker2.hostname !== "127.0.0.1" || marker2.port === "" || marker2.pathname !== "/first-frame" || marker2.search !== "" || marker2.hash !== "" || marker2.username !== "" || marker2.password !== "" || target !== "browser" || device !== void 0) {
|
|
8401
|
+
throw new PlaytestCliUsageError("--judge-marker-url must be a canonical http://127.0.0.1:<port>/first-frame URL for browser runs.");
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
7955
8404
|
if (target === "browser" && device !== void 0) {
|
|
7956
8405
|
if (browserRecipe !== void 0) {
|
|
7957
8406
|
throw new PlaytestCliUsageError("Android Chrome device runs cannot honor --browser-recipe; remove it.");
|
|
@@ -7975,9 +8424,17 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
7975
8424
|
throw new PlaytestCliUsageError(`Android --user must be numeric, got '${androidUser}'.`);
|
|
7976
8425
|
}
|
|
7977
8426
|
const hostArgs = flags.get("--host-arg") ?? [];
|
|
8427
|
+
const artifact = flags.get("--artifact")?.[0];
|
|
8428
|
+
const buildReport2 = flags.get("--build-report")?.[0];
|
|
8429
|
+
if (buildReport2 !== void 0 && artifact === void 0 && target !== "desktop" && target !== "ios") {
|
|
8430
|
+
throw new PlaytestCliUsageError(
|
|
8431
|
+
`--build-report on the ${target} target also needs --artifact <path>: nothing else says which build this run exercises.`
|
|
8432
|
+
);
|
|
8433
|
+
}
|
|
7978
8434
|
const browserArgs = explicitBrowserArgs.length > 0 ? explicitBrowserArgs : browserRecipe === "webgpu" ? [...WEBGPU_BROWSER_ARGS] : [];
|
|
7979
8435
|
return {
|
|
7980
8436
|
...flags.get("--adb")?.[0] === void 0 ? {} : { adbPath: flags.get("--adb")[0] },
|
|
8437
|
+
...artifact === void 0 ? {} : { artifactPath: artifact },
|
|
7981
8438
|
...touchRotation === void 0 ? {} : { touchRotation },
|
|
7982
8439
|
// A scaffolded project's own `test` script is what a user runs, and it deliberately refuses a
|
|
7983
8440
|
// software adapter — nothing about that should change to suit a runner. But CI has no GPU and
|
|
@@ -7994,6 +8451,8 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
7994
8451
|
artifactDirectory: resolve(projectPath, flags.get("--artifacts")?.[0] ?? "artifacts/playtest"),
|
|
7995
8452
|
captureArtifactScreenshots: !argv.includes("--no-screenshots"),
|
|
7996
8453
|
...browserArgs.length === 0 ? {} : { browserArgs },
|
|
8454
|
+
...buildReport2 === void 0 ? {} : { buildReportPath: resolve(projectPath, buildReport2) },
|
|
8455
|
+
...cpuProfilePath === void 0 ? {} : { cpuProfilePath: resolve(projectPath, cpuProfilePath) },
|
|
7997
8456
|
...device === void 0 ? {} : { device },
|
|
7998
8457
|
...executable === void 0 ? {} : {
|
|
7999
8458
|
desktop: {
|
|
@@ -8008,6 +8467,7 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
8008
8467
|
bundleId: flags.get("--bundle-id")?.[0] ?? "dev.threenative.runtime",
|
|
8009
8468
|
transport: iosTransport
|
|
8010
8469
|
},
|
|
8470
|
+
...judgeMarkerUrl === void 0 ? {} : { judgeMarkerUrl },
|
|
8011
8471
|
...flags.get("--mailbox-root")?.[0] === void 0 ? {} : { mailboxRoot: flags.get("--mailbox-root")[0] },
|
|
8012
8472
|
...serverCommand === void 0 ? effectivePort === void 0 ? {} : { port: effectivePort } : { port: effectivePort ?? 0 },
|
|
8013
8473
|
projectPath,
|
|
@@ -8123,6 +8583,191 @@ function isPlaytestFlag(value) {
|
|
|
8123
8583
|
return Object.prototype.hasOwnProperty.call(PLAYTEST_FLAGS, value);
|
|
8124
8584
|
}
|
|
8125
8585
|
|
|
8586
|
+
// src/runner/buildReport.ts
|
|
8587
|
+
var REPORT_KEYS = [
|
|
8588
|
+
"artifact",
|
|
8589
|
+
"measured",
|
|
8590
|
+
"manifestSha256",
|
|
8591
|
+
"performanceBudget",
|
|
8592
|
+
"profile",
|
|
8593
|
+
"schemaVersion",
|
|
8594
|
+
"target"
|
|
8595
|
+
];
|
|
8596
|
+
var REPORT_TARGETS = ["android", "desktop", "ios", "web"];
|
|
8597
|
+
function invalid(reportPath, detail) {
|
|
8598
|
+
return new Error(`TN_PLAYTEST_BUILD_REPORT_INVALID: ${reportPath}: ${detail}`);
|
|
8599
|
+
}
|
|
8600
|
+
function harnessDetail(error) {
|
|
8601
|
+
return (error instanceof Error ? error.message : String(error)).replace(/^Playtest scenario '.*' is invalid: /su, "");
|
|
8602
|
+
}
|
|
8603
|
+
function isRecord4(value) {
|
|
8604
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8605
|
+
}
|
|
8606
|
+
function requireKeys(value, label, keys, reportPath) {
|
|
8607
|
+
if (!isRecord4(value)) throw invalid(reportPath, `${label} must be an object.`);
|
|
8608
|
+
for (const key of Object.keys(value)) {
|
|
8609
|
+
if (!keys.includes(key)) throw invalid(reportPath, `${label}.${key} is not recognised.`);
|
|
8610
|
+
}
|
|
8611
|
+
return value;
|
|
8612
|
+
}
|
|
8613
|
+
function sha256(bytes) {
|
|
8614
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
8615
|
+
}
|
|
8616
|
+
async function listFiles(target, prefix = "") {
|
|
8617
|
+
const entries = await readdir(target, { withFileTypes: true });
|
|
8618
|
+
const files = [];
|
|
8619
|
+
for (const entry of entries.sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
8620
|
+
const relative3 = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
8621
|
+
if (entry.isDirectory()) files.push(...await listFiles(path.join(target, entry.name), relative3));
|
|
8622
|
+
else if (entry.isFile()) files.push(relative3);
|
|
8623
|
+
}
|
|
8624
|
+
return files;
|
|
8625
|
+
}
|
|
8626
|
+
async function hashArtifact(target) {
|
|
8627
|
+
const name = path.basename(target);
|
|
8628
|
+
if (!(await stat(target)).isDirectory()) {
|
|
8629
|
+
return { kind: "file", name, sha256: sha256(await readFile(target)) };
|
|
8630
|
+
}
|
|
8631
|
+
const lines = [];
|
|
8632
|
+
for (const file of await listFiles(target)) {
|
|
8633
|
+
lines.push(`${file} ${sha256(await readFile(path.join(target, file)))}`);
|
|
8634
|
+
}
|
|
8635
|
+
return { kind: "directory", name, sha256: sha256(Buffer.from(lines.join("\n"), "utf8")) };
|
|
8636
|
+
}
|
|
8637
|
+
function artifactUnderTest(config) {
|
|
8638
|
+
const target = config.target ?? "browser";
|
|
8639
|
+
const own = target === "desktop" ? config.desktop?.executable : target === "ios" ? config.ios?.appPath : void 0;
|
|
8640
|
+
if (own !== void 0) {
|
|
8641
|
+
if (config.artifactPath !== void 0) {
|
|
8642
|
+
throw new PlaytestCliUsageError(
|
|
8643
|
+
`The ${target} target already names the artifact under test; drop --artifact or the target's own flag.`
|
|
8644
|
+
);
|
|
8645
|
+
}
|
|
8646
|
+
return own;
|
|
8647
|
+
}
|
|
8648
|
+
if (config.artifactPath === void 0) {
|
|
8649
|
+
throw new PlaytestCliUsageError(
|
|
8650
|
+
`The ${target} target does not say which artifact it is about to run; pass --artifact <path> beside --build-report.`
|
|
8651
|
+
);
|
|
8652
|
+
}
|
|
8653
|
+
return config.artifactPath;
|
|
8654
|
+
}
|
|
8655
|
+
async function readReport(reportPath) {
|
|
8656
|
+
let raw;
|
|
8657
|
+
try {
|
|
8658
|
+
raw = await readFile(reportPath, "utf8");
|
|
8659
|
+
} catch (error) {
|
|
8660
|
+
throw invalid(reportPath, `could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
8661
|
+
}
|
|
8662
|
+
let parsed;
|
|
8663
|
+
try {
|
|
8664
|
+
parsed = JSON.parse(raw);
|
|
8665
|
+
} catch (error) {
|
|
8666
|
+
throw invalid(reportPath, `is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
8667
|
+
}
|
|
8668
|
+
const report = requireKeys(parsed, "report", REPORT_KEYS, reportPath);
|
|
8669
|
+
if (!("performanceBudget" in report)) {
|
|
8670
|
+
throw invalid(
|
|
8671
|
+
reportPath,
|
|
8672
|
+
"report.performanceBudget is missing; a build always writes it, null when no profile declares one."
|
|
8673
|
+
);
|
|
8674
|
+
}
|
|
8675
|
+
if (report.schemaVersion !== 1) {
|
|
8676
|
+
throw invalid(reportPath, `schemaVersion must be 1, received ${JSON.stringify(report.schemaVersion)}.`);
|
|
8677
|
+
}
|
|
8678
|
+
if (typeof report.target !== "string" || !REPORT_TARGETS.includes(report.target)) {
|
|
8679
|
+
throw invalid(reportPath, `target must be one of ${REPORT_TARGETS.join(", ")}.`);
|
|
8680
|
+
}
|
|
8681
|
+
if (report.profile !== null && typeof report.profile !== "string") {
|
|
8682
|
+
throw invalid(reportPath, "profile must be a profile name or null.");
|
|
8683
|
+
}
|
|
8684
|
+
const artifact = requireKeys(report.artifact, "report.artifact", ["kind", "name", "sha256"], reportPath);
|
|
8685
|
+
if (artifact.kind !== "directory" && artifact.kind !== "file") {
|
|
8686
|
+
throw invalid(reportPath, "report.artifact.kind must be 'directory' or 'file'.");
|
|
8687
|
+
}
|
|
8688
|
+
if (typeof artifact.name !== "string" || artifact.name.length === 0) {
|
|
8689
|
+
throw invalid(reportPath, "report.artifact.name must be a non-empty basename.");
|
|
8690
|
+
}
|
|
8691
|
+
if (typeof artifact.sha256 !== "string" || !/^[0-9a-f]{64}$/u.test(artifact.sha256)) {
|
|
8692
|
+
throw invalid(reportPath, "report.artifact.sha256 must be a sha256 hex digest.");
|
|
8693
|
+
}
|
|
8694
|
+
const measured = requireKeys(report.measured, "report.measured", ["artifactBytes", "packagedAssetBytes"], reportPath);
|
|
8695
|
+
for (const key of ["artifactBytes", "packagedAssetBytes"]) {
|
|
8696
|
+
if (typeof measured[key] !== "number" || !Number.isFinite(measured[key])) {
|
|
8697
|
+
throw invalid(reportPath, `report.measured.${key} must be a number.`);
|
|
8698
|
+
}
|
|
8699
|
+
}
|
|
8700
|
+
if (report.manifestSha256 !== null && typeof report.manifestSha256 !== "string") {
|
|
8701
|
+
throw invalid(reportPath, "report.manifestSha256 must be a sha256 hex digest or null.");
|
|
8702
|
+
}
|
|
8703
|
+
if (report.performanceBudget !== null && report.performanceBudget !== void 0) {
|
|
8704
|
+
try {
|
|
8705
|
+
validatePerformanceAssertion(report.performanceBudget, reportPath, "performanceBudget");
|
|
8706
|
+
} catch (error) {
|
|
8707
|
+
throw invalid(reportPath, harnessDetail(error));
|
|
8708
|
+
}
|
|
8709
|
+
}
|
|
8710
|
+
return report;
|
|
8711
|
+
}
|
|
8712
|
+
function assertTargetMatches(report, reportPath, target) {
|
|
8713
|
+
const runTarget = target === "browser" ? "web" : target;
|
|
8714
|
+
if (report.target === runTarget) return;
|
|
8715
|
+
throw invalid(
|
|
8716
|
+
reportPath,
|
|
8717
|
+
`was built for '${report.target}' but this run's target is '${runTarget}'. A budget measured on one artifact cannot bound another.`
|
|
8718
|
+
);
|
|
8719
|
+
}
|
|
8720
|
+
function withPerformanceBudget(scenario, budget) {
|
|
8721
|
+
if (budget === void 0) return scenario;
|
|
8722
|
+
const declared = scenario.assert?.performance;
|
|
8723
|
+
const maps = {
|
|
8724
|
+
maxPassDrawCalls: { ...budget.maxPassDrawCalls, ...declared?.maxPassDrawCalls },
|
|
8725
|
+
maxPassTriangles: { ...budget.maxPassTriangles, ...declared?.maxPassTriangles },
|
|
8726
|
+
maxPhaseMsP95: { ...budget.maxPhaseMsP95, ...declared?.maxPhaseMsP95 }
|
|
8727
|
+
};
|
|
8728
|
+
const performance = {
|
|
8729
|
+
...budget,
|
|
8730
|
+
...declared,
|
|
8731
|
+
...Object.fromEntries(Object.entries(maps).filter(([, value]) => Object.keys(value).length > 0))
|
|
8732
|
+
};
|
|
8733
|
+
return { ...scenario, assert: { ...scenario.assert, performance } };
|
|
8734
|
+
}
|
|
8735
|
+
async function resolveBuildReport(config) {
|
|
8736
|
+
if (config.buildReportPath === void 0) return config;
|
|
8737
|
+
const reportPath = config.buildReportPath;
|
|
8738
|
+
const report = await readReport(reportPath);
|
|
8739
|
+
assertTargetMatches(report, reportPath, config.target ?? "browser");
|
|
8740
|
+
const artifact = artifactUnderTest(config);
|
|
8741
|
+
let measured;
|
|
8742
|
+
try {
|
|
8743
|
+
measured = await hashArtifact(artifact);
|
|
8744
|
+
} catch (error) {
|
|
8745
|
+
throw invalid(
|
|
8746
|
+
reportPath,
|
|
8747
|
+
`names artifact '${report.artifact.name}', which could not be hashed at ${artifact}: ${error instanceof Error ? error.message : String(error)}`
|
|
8748
|
+
);
|
|
8749
|
+
}
|
|
8750
|
+
if (measured.sha256 !== report.artifact.sha256 || measured.kind !== report.artifact.kind) {
|
|
8751
|
+
throw new Error(
|
|
8752
|
+
`TN_PLAYTEST_BUILD_REPORT_STALE: ${reportPath} describes artifact '${report.artifact.name}' with sha256 ${report.artifact.sha256} (${report.artifact.kind}), but ${artifact} now hashes to ${measured.sha256} (${measured.kind}). Rebuild, or point --build-report at the build you are running.`
|
|
8753
|
+
);
|
|
8754
|
+
}
|
|
8755
|
+
const budget = report.performanceBudget === null || report.performanceBudget === void 0 ? void 0 : validatePerformanceAssertion(report.performanceBudget, reportPath, "performanceBudget");
|
|
8756
|
+
assertPerformanceObservable(budget, config.target ?? "browser", reportPath);
|
|
8757
|
+
return { ...config, performanceBudget: budget };
|
|
8758
|
+
}
|
|
8759
|
+
function assertPerformanceObservable(budget, target, reportPath) {
|
|
8760
|
+
if (budget === void 0) return;
|
|
8761
|
+
const runTarget = target === "browser" ? "web" : target;
|
|
8762
|
+
const entry = PLAYTEST_ASSERTION_REGISTRY.find(({ kind }) => kind === "performance");
|
|
8763
|
+
const supported = entry?.supportedOn ?? [];
|
|
8764
|
+
if (supported.includes(runTarget)) return;
|
|
8765
|
+
throw invalid(
|
|
8766
|
+
reportPath,
|
|
8767
|
+
`declares a performanceBudget, which the '${runTarget}' target cannot observe. Bounds on frames are measured on: ${supported.join(", ")}.`
|
|
8768
|
+
);
|
|
8769
|
+
}
|
|
8770
|
+
|
|
8126
8771
|
// src/runner/cli.ts
|
|
8127
8772
|
init_browser();
|
|
8128
8773
|
var CAPTURE_LOCK_TIMEOUT_MS_CONTESTED = 12e4;
|
|
@@ -8163,11 +8808,11 @@ function queueDirOf(lockRoot) {
|
|
|
8163
8808
|
return join(lockRoot, QUEUE_DIR_NAME);
|
|
8164
8809
|
}
|
|
8165
8810
|
function readHolder(lockDirectory) {
|
|
8166
|
-
const
|
|
8167
|
-
if (!existsSync(
|
|
8811
|
+
const path2 = join(lockDirectory, HOLDER_FILE);
|
|
8812
|
+
if (!existsSync(path2)) return void 0;
|
|
8168
8813
|
let raw;
|
|
8169
8814
|
try {
|
|
8170
|
-
raw = readFileSync(
|
|
8815
|
+
raw = readFileSync(path2, "utf8");
|
|
8171
8816
|
} catch {
|
|
8172
8817
|
return void 0;
|
|
8173
8818
|
}
|
|
@@ -8176,7 +8821,7 @@ function readHolder(lockDirectory) {
|
|
|
8176
8821
|
if (typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid)) throw new Error("bad pid");
|
|
8177
8822
|
return { ...parsed.command === void 0 ? {} : { command: parsed.command }, pid: parsed.pid, startedAt: String(parsed.startedAt ?? "") };
|
|
8178
8823
|
} catch {
|
|
8179
|
-
throw new Error(`Malformed capture lock holder record at ${
|
|
8824
|
+
throw new Error(`Malformed capture lock holder record at ${path2}; remove the stale '${lockDirectory}' directory if no playtest is running.`);
|
|
8180
8825
|
}
|
|
8181
8826
|
}
|
|
8182
8827
|
var CaptureLockTimeoutError = class extends Error {
|
|
@@ -8326,6 +8971,8 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8326
8971
|
}
|
|
8327
8972
|
options;
|
|
8328
8973
|
static COVERAGE_VIDEO_PATH = "/sdcard/tn-playtest-framebuffer-coverage.mp4";
|
|
8974
|
+
/** Bounded polls for a lifecycle operation to become visible to the device's own readings. */
|
|
8975
|
+
static LIFECYCLE_ATTEMPTS = 50;
|
|
8329
8976
|
adbPath;
|
|
8330
8977
|
screenrecord;
|
|
8331
8978
|
screenrecordError;
|
|
@@ -8335,6 +8982,8 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8335
8982
|
touchViewport;
|
|
8336
8983
|
user;
|
|
8337
8984
|
activeUser;
|
|
8985
|
+
/** Set by a lifecycle `rotate`, whose display lock `stop()` has to free on its own account. */
|
|
8986
|
+
lifecycleRotationLocked = false;
|
|
8338
8987
|
viewportPresented = false;
|
|
8339
8988
|
async prepare(endpoint, mailboxRoot, viewport) {
|
|
8340
8989
|
const url = new URL(endpoint);
|
|
@@ -8342,9 +8991,9 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8342
8991
|
const user = await this.resolveUser();
|
|
8343
8992
|
this.activeUser = user;
|
|
8344
8993
|
await this.adb(["reverse", `tcp:${port}`, `tcp:${port}`]);
|
|
8345
|
-
await this.adb(["logcat", "-c"]);
|
|
8346
8994
|
await this.adb(["shell", "am", "force-stop", "--user", user, this.options.packageName]);
|
|
8347
8995
|
if (viewport !== void 0) await this.presentViewport(viewport);
|
|
8996
|
+
await this.adb(["logcat", "-c"]);
|
|
8348
8997
|
await this.adb([
|
|
8349
8998
|
"shell",
|
|
8350
8999
|
"am",
|
|
@@ -8397,6 +9046,80 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8397
9046
|
async tap(x, y) {
|
|
8398
9047
|
await this.adb(tapCommand(x, y));
|
|
8399
9048
|
}
|
|
9049
|
+
/**
|
|
9050
|
+
* The three device operations a `lifecycle` step names, each waiting for the device to *report*
|
|
9051
|
+
* the effect rather than for the command to return.
|
|
9052
|
+
*
|
|
9053
|
+
* `input keyevent 3` and `am start` both answer `OK` whether or not anything moved, and `wm
|
|
9054
|
+
* user-rotation lock` answers the same way on a device whose rotation is pinned. A step that
|
|
9055
|
+
* recorded a phase on the strength of the exit code alone would certify a device that never went
|
|
9056
|
+
* away — which is the exact value the gate exists to read off the phone, so each op polls the
|
|
9057
|
+
* reading it is about to claim and throws when the claim is false.
|
|
9058
|
+
*/
|
|
9059
|
+
async background() {
|
|
9060
|
+
await this.adb(["shell", "input", "keyevent", "3"]);
|
|
9061
|
+
await this.waitForFocus(false);
|
|
9062
|
+
}
|
|
9063
|
+
async foreground() {
|
|
9064
|
+
const user = this.activeUser ?? await this.resolveUser();
|
|
9065
|
+
await this.adb([
|
|
9066
|
+
"shell",
|
|
9067
|
+
"am",
|
|
9068
|
+
"start",
|
|
9069
|
+
"--user",
|
|
9070
|
+
user,
|
|
9071
|
+
"-n",
|
|
9072
|
+
`${this.options.packageName}/${this.options.activity}`
|
|
9073
|
+
]);
|
|
9074
|
+
await this.waitForFocus(true);
|
|
9075
|
+
}
|
|
9076
|
+
async rotate(rotation) {
|
|
9077
|
+
if (![0, 1, 2, 3].includes(rotation)) {
|
|
9078
|
+
throw new Error(
|
|
9079
|
+
`TN_PLAYTEST_ANDROID_ROTATION_INVALID: rotation must be 0, 1, 2 or 3, got '${String(rotation)}'.`
|
|
9080
|
+
);
|
|
9081
|
+
}
|
|
9082
|
+
await this.adb(["shell", "wm", "user-rotation", "lock", String(rotation)]);
|
|
9083
|
+
this.lifecycleRotationLocked = true;
|
|
9084
|
+
let observed;
|
|
9085
|
+
for (let attempt = 0; attempt < _AdbAndroidDriver.LIFECYCLE_ATTEMPTS; attempt += 1) {
|
|
9086
|
+
observed = windowRotationFromDump(await this.adb(["shell", "dumpsys", "window"]));
|
|
9087
|
+
if (observed === rotation) return;
|
|
9088
|
+
await delay(100);
|
|
9089
|
+
}
|
|
9090
|
+
throw new Error(
|
|
9091
|
+
`TN_PLAYTEST_ANDROID_LIFECYCLE_NOT_APPLIED: asked the device for rotation ${rotation} and dumpsys window still reports ${String(observed)}.`
|
|
9092
|
+
);
|
|
9093
|
+
}
|
|
9094
|
+
async lifecycleState() {
|
|
9095
|
+
const [pids, window2, frames] = await Promise.all([
|
|
9096
|
+
this.adb(["shell", "pidof", this.options.packageName]),
|
|
9097
|
+
this.adb(["shell", "dumpsys", "window"]),
|
|
9098
|
+
this.adb(["shell", "dumpsys", "gfxinfo", this.options.packageName])
|
|
9099
|
+
]);
|
|
9100
|
+
const pid = parseAndroidAppPid(pids);
|
|
9101
|
+
const appFrames = parseAndroidAppFrames(frames);
|
|
9102
|
+
const windowRotation = windowRotationFromDump(window2);
|
|
9103
|
+
return {
|
|
9104
|
+
focused: windowHasFocus(window2, this.options.packageName),
|
|
9105
|
+
...appFrames === void 0 ? {} : { frames: appFrames },
|
|
9106
|
+
...pid === void 0 ? {} : { pid },
|
|
9107
|
+
...windowRotation === void 0 ? {} : { windowRotation }
|
|
9108
|
+
};
|
|
9109
|
+
}
|
|
9110
|
+
async waitForFocus(expected) {
|
|
9111
|
+
for (let attempt = 0; attempt < _AdbAndroidDriver.LIFECYCLE_ATTEMPTS; attempt += 1) {
|
|
9112
|
+
const focused = windowHasFocus(
|
|
9113
|
+
await this.adb(["shell", "dumpsys", "window"]),
|
|
9114
|
+
this.options.packageName
|
|
9115
|
+
);
|
|
9116
|
+
if (focused === expected) return;
|
|
9117
|
+
await delay(100);
|
|
9118
|
+
}
|
|
9119
|
+
throw new Error(
|
|
9120
|
+
`TN_PLAYTEST_ANDROID_LIFECYCLE_NOT_APPLIED: the device still reports '${this.options.packageName}' as ${expected ? "not focused" : "focused"} after the operation.`
|
|
9121
|
+
);
|
|
9122
|
+
}
|
|
8400
9123
|
/**
|
|
8401
9124
|
* Dismiss the soft keyboard and wait for it to actually be gone.
|
|
8402
9125
|
*
|
|
@@ -8423,14 +9146,14 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8423
9146
|
const output = await this.adb(["logcat", "-d", "-v", "brief"]);
|
|
8424
9147
|
return parseAndroidConsole(output);
|
|
8425
9148
|
}
|
|
8426
|
-
async screenshot(
|
|
9149
|
+
async screenshot(path2) {
|
|
8427
9150
|
const { stdout } = await execFileAsync(this.adbPath, [
|
|
8428
9151
|
...this.serialArgs(),
|
|
8429
9152
|
"exec-out",
|
|
8430
9153
|
"screencap",
|
|
8431
9154
|
"-p"
|
|
8432
9155
|
], { encoding: "buffer", maxBuffer: 32 * 1024 * 1024 });
|
|
8433
|
-
await writeFile(
|
|
9156
|
+
await writeFile(path2, stdout);
|
|
8434
9157
|
}
|
|
8435
9158
|
async startScreenRecording() {
|
|
8436
9159
|
if (this.screenrecord !== void 0) {
|
|
@@ -8461,7 +9184,7 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8461
9184
|
throw error;
|
|
8462
9185
|
}
|
|
8463
9186
|
}
|
|
8464
|
-
async stopScreenRecording(
|
|
9187
|
+
async stopScreenRecording(path2) {
|
|
8465
9188
|
const recorder = this.screenrecord;
|
|
8466
9189
|
if (recorder === void 0) {
|
|
8467
9190
|
throw new Error("TN_PLAYTEST_FRAMEBUFFER_COVERAGE_RECORDING_NOT_ACTIVE");
|
|
@@ -8472,8 +9195,8 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8472
9195
|
const pids = (await this.adb(["shell", "pidof", "screenrecord"]).catch(() => "")).trim().split(/\s+/u).filter((pid) => /^\d+$/u.test(pid));
|
|
8473
9196
|
for (const pid of pids) await this.adb(["shell", "kill", "-2", pid]);
|
|
8474
9197
|
await waitForProcessExit(recorder, 5e3);
|
|
8475
|
-
await this.adb(["pull", _AdbAndroidDriver.COVERAGE_VIDEO_PATH,
|
|
8476
|
-
if ((await stat(
|
|
9198
|
+
await this.adb(["pull", _AdbAndroidDriver.COVERAGE_VIDEO_PATH, path2]);
|
|
9199
|
+
if ((await stat(path2)).size === 0) {
|
|
8477
9200
|
throw new Error("TN_PLAYTEST_FRAMEBUFFER_COVERAGE_RECORDING_EMPTY");
|
|
8478
9201
|
}
|
|
8479
9202
|
} finally {
|
|
@@ -8545,21 +9268,25 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8545
9268
|
trackingIds: [...this.touchSlots.values()].map(({ trackingId }) => trackingId)
|
|
8546
9269
|
};
|
|
8547
9270
|
}
|
|
8548
|
-
async readFile(
|
|
9271
|
+
async readFile(path2) {
|
|
8549
9272
|
try {
|
|
8550
|
-
const contents = await this.adb(["exec-out", "cat",
|
|
9273
|
+
const contents = await this.adb(["exec-out", "cat", path2]);
|
|
8551
9274
|
return isMissingRemoteFileOutput(contents) ? void 0 : contents;
|
|
8552
9275
|
} catch (error) {
|
|
8553
9276
|
if (isMissingRemoteFile(error)) return void 0;
|
|
8554
9277
|
throw error;
|
|
8555
9278
|
}
|
|
8556
9279
|
}
|
|
8557
|
-
async removeFile(
|
|
8558
|
-
await this.adb(["shell", "rm", "-f",
|
|
9280
|
+
async removeFile(path2) {
|
|
9281
|
+
await this.adb(["shell", "rm", "-f", path2]);
|
|
8559
9282
|
}
|
|
8560
9283
|
async stop() {
|
|
8561
9284
|
await this.abortScreenRecording();
|
|
8562
9285
|
await this.setPointers([]).catch(() => void 0);
|
|
9286
|
+
if (this.lifecycleRotationLocked) {
|
|
9287
|
+
this.lifecycleRotationLocked = false;
|
|
9288
|
+
await this.adb(["shell", "wm", "user-rotation", "free"]).catch(() => void 0);
|
|
9289
|
+
}
|
|
8563
9290
|
if (this.viewportPresented) {
|
|
8564
9291
|
this.viewportPresented = false;
|
|
8565
9292
|
this.touchViewport = void 0;
|
|
@@ -8586,14 +9313,14 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8586
9313
|
if (/^[0-3]$/u.test(setting)) return Number(setting);
|
|
8587
9314
|
throw new Error("TN_PLAYTEST_ANDROID_ROTATION_UNKNOWN: dumpsys window, dumpsys input and user_rotation did not report 0 through 3.");
|
|
8588
9315
|
}
|
|
8589
|
-
async writeFile(
|
|
9316
|
+
async writeFile(path2, contents) {
|
|
8590
9317
|
const directory = await mkdtemp(join(tmpdir(), "threenative-adb-mailbox-"));
|
|
8591
9318
|
const localPath = join(directory, "payload.json");
|
|
8592
|
-
const remotePath = `${
|
|
9319
|
+
const remotePath = `${path2}.incoming-${process.pid}-${Date.now()}`;
|
|
8593
9320
|
try {
|
|
8594
9321
|
await writeFile(localPath, contents, "utf8");
|
|
8595
9322
|
await this.adb(["push", localPath, remotePath]);
|
|
8596
|
-
await this.adb(["shell", "mv", remotePath,
|
|
9323
|
+
await this.adb(["shell", "mv", remotePath, path2]);
|
|
8597
9324
|
} finally {
|
|
8598
9325
|
await rm(directory, { force: true, recursive: true });
|
|
8599
9326
|
await this.adb(["shell", "rm", "-f", remotePath]).catch(() => void 0);
|
|
@@ -8773,10 +9500,26 @@ function viewportPresentationObserved(override, expected, physical) {
|
|
|
8773
9500
|
return expected !== void 0 && (override === expected || override === void 0 && expected === `${physical.width}x${physical.height}`);
|
|
8774
9501
|
}
|
|
8775
9502
|
function touchRotationFromWindowDump(dump) {
|
|
9503
|
+
const rotation = windowRotationFromDump(dump);
|
|
9504
|
+
return rotation === void 0 ? void 0 : (4 - rotation) % 4;
|
|
9505
|
+
}
|
|
9506
|
+
function windowRotationFromDump(dump) {
|
|
8776
9507
|
const rotation = /\bmRotation=([0-3])\b/u.exec(dump)?.[1];
|
|
8777
|
-
return rotation === void 0 ? void 0 :
|
|
9508
|
+
return rotation === void 0 ? void 0 : Number(rotation);
|
|
8778
9509
|
}
|
|
8779
|
-
function
|
|
9510
|
+
function windowHasFocus(dump, packageName) {
|
|
9511
|
+
const escaped = packageName.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
9512
|
+
return new RegExp(`mCurrentFocus=.*\\s${escaped}/`, "u").test(dump);
|
|
9513
|
+
}
|
|
9514
|
+
function parseAndroidAppPid(output) {
|
|
9515
|
+
const pid = output.trim().split(/\s+/u)[0];
|
|
9516
|
+
return pid !== void 0 && /^\d+$/u.test(pid) ? Number(pid) : void 0;
|
|
9517
|
+
}
|
|
9518
|
+
function parseAndroidAppFrames(dump) {
|
|
9519
|
+
const frames = /Total frames rendered:\s*(\d+)/u.exec(dump)?.[1];
|
|
9520
|
+
return frames === void 0 ? void 0 : Number(frames);
|
|
9521
|
+
}
|
|
9522
|
+
function viewportPresentationCommands(viewport, physical) {
|
|
8780
9523
|
if (!(viewport.width > 0) || !(viewport.height > 0)) {
|
|
8781
9524
|
throw new Error(
|
|
8782
9525
|
`TN_PLAYTEST_ANDROID_VIEWPORT_INVALID: a scenario viewport of ${viewport.width}x${viewport.height} cannot be presented on a device.`
|
|
@@ -8844,6 +9587,9 @@ function discoverAdb(environment = process.env) {
|
|
|
8844
9587
|
"adb was not found. Install Android SDK Platform Tools, set ANDROID_HOME, or pass --adb /absolute/path/to/adb."
|
|
8845
9588
|
);
|
|
8846
9589
|
}
|
|
9590
|
+
function delay(milliseconds) {
|
|
9591
|
+
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
9592
|
+
}
|
|
8847
9593
|
|
|
8848
9594
|
// src/runner/doctor.ts
|
|
8849
9595
|
init_deviceMetrics();
|
|
@@ -9189,6 +9935,7 @@ function summariseScene(observation) {
|
|
|
9189
9935
|
const points = positions(entities);
|
|
9190
9936
|
const frames = (snapshot.runtimeDiagnosticsSeries ?? []).map(({ frameMs: frameMs2 }) => frameMs2);
|
|
9191
9937
|
const frameMs = median(frames);
|
|
9938
|
+
const passSplit = (snapshot.runtimeDiagnosticsSeries ?? []).at(-1)?.passes;
|
|
9192
9939
|
const world = snapshot.gameplay?.world;
|
|
9193
9940
|
const clips = Object.entries(snapshot.gameplay?.animation ?? {}).filter(([, animation]) => animation.advancedFrames > 0).map(([entity, animation]) => `${entity}: ${animation.clip}`);
|
|
9194
9941
|
const base = {
|
|
@@ -9231,6 +9978,7 @@ function summariseScene(observation) {
|
|
|
9231
9978
|
drawCalls: snapshot.performance?.drawCalls,
|
|
9232
9979
|
fps: frameMs === void 0 || frameMs <= 0 ? void 0 : Math.round(1e3 / frameMs),
|
|
9233
9980
|
frameMs,
|
|
9981
|
+
...passSplit === void 0 || passSplit.length === 0 ? {} : { passes: passSplit.map(({ draws, kind, triangles }) => ({ draws, kind, triangles })) },
|
|
9234
9982
|
triangles: snapshot.performance?.triangles,
|
|
9235
9983
|
...frameMs === void 0 ? {} : { vsyncLocked: onVsyncInterval(frameMs) }
|
|
9236
9984
|
},
|
|
@@ -9282,6 +10030,14 @@ function renderablesLine(overview) {
|
|
|
9282
10030
|
const state = projection.projecting === true ? `projection batching ${projection.batches ?? 0} groups` : `projection standing down${projection.reasonCode === void 0 ? "" : ` (${projection.reasonCode})`}`;
|
|
9283
10031
|
return ` renderables ${projection.renderables.toLocaleString("en-US")} handed to the renderer \xB7 ${state}`;
|
|
9284
10032
|
}
|
|
10033
|
+
function passesLine(overview) {
|
|
10034
|
+
const passes = overview.render.passes;
|
|
10035
|
+
if (passes === void 0) return void 0;
|
|
10036
|
+
const parts = passes.map(
|
|
10037
|
+
(pass) => `${pass.kind} ${pass.draws.toLocaleString("en-US")} draws / ${pass.triangles.toLocaleString("en-US")} tris`
|
|
10038
|
+
);
|
|
10039
|
+
return ` passes ${parts.join(" \xB7 ")}`;
|
|
10040
|
+
}
|
|
9285
10041
|
function livenessLine(overview) {
|
|
9286
10042
|
const { liveness: state } = overview;
|
|
9287
10043
|
if (state.ticks === void 0 && state.moved === 0) return void 0;
|
|
@@ -9312,6 +10068,7 @@ function formatSceneOverview(overview) {
|
|
|
9312
10068
|
` scale ${scale.verdict}${scale.medianEntityScale === void 0 ? "" : ` (median ${scale.medianEntityScale}\xD7, largest ${scale.largestEntityScale}\xD7)`}`,
|
|
9313
10069
|
` render ${render.drawCalls === void 0 ? "draw calls not observed" : `${render.drawCalls} draw calls`} \xB7 ${render.triangles === void 0 ? "triangles not observed" : `${render.triangles.toLocaleString("en-US")} triangles`}${render.frameMs === void 0 ? " \xB7 frame time not observed" : ` \xB7 ${render.frameMs.toFixed(1)} ms/frame (${render.fps} fps)`}`,
|
|
9314
10070
|
renderablesLine(overview),
|
|
10071
|
+
passesLine(overview),
|
|
9315
10072
|
...overview.room === void 0 ? [] : formatRoomLines(overview.room),
|
|
9316
10073
|
livenessLine(overview),
|
|
9317
10074
|
` gameplay ${gameplay.states} states \xB7 ${gameplay.clipsAdvancing.length === 0 ? "no clips advancing" : `clips ${gameplay.clipsAdvancing.join(", ")}`}${tags.length === 0 ? "" : ` \xB7 tags ${tags.join(", ")}`}`,
|
|
@@ -9474,6 +10231,184 @@ installThreePlaytestBridge({
|
|
|
9474
10231
|
}
|
|
9475
10232
|
return { created };
|
|
9476
10233
|
}
|
|
10234
|
+
var DEFAULT_XVFB_SCREEN = "1600x900x24";
|
|
10235
|
+
var HOST_DISPLAY_ENV = "TN_PLAYTEST_HOST_DISPLAY";
|
|
10236
|
+
var STRIPPED_WAYLAND_VARS = ["WAYLAND_DISPLAY", "WAYLAND_SOCKET", "XDG_SESSION_TYPE"];
|
|
10237
|
+
var X11_SOCKET_DIR = "/tmp/.X11-unix";
|
|
10238
|
+
function decideDisplayStrategy(input) {
|
|
10239
|
+
if (input.platform !== "linux") return { kind: "host" };
|
|
10240
|
+
const privateXvfb = {
|
|
10241
|
+
kind: "private-xvfb",
|
|
10242
|
+
screen: input.env.TN_XVFB_SCREEN ?? DEFAULT_XVFB_SCREEN
|
|
10243
|
+
};
|
|
10244
|
+
if (!hostDisplayRequested(input.env)) return privateXvfb;
|
|
10245
|
+
const display = input.env.DISPLAY;
|
|
10246
|
+
if (display !== void 0 && display.length > 0 && (input.displaySocketExists ?? x11SocketExists)(display)) {
|
|
10247
|
+
return { display, kind: "existing" };
|
|
10248
|
+
}
|
|
10249
|
+
return privateXvfb;
|
|
10250
|
+
}
|
|
10251
|
+
function hostDisplayRequested(env) {
|
|
10252
|
+
const value = env[HOST_DISPLAY_ENV];
|
|
10253
|
+
return value === "1" || value?.toLowerCase() === "true";
|
|
10254
|
+
}
|
|
10255
|
+
function x11SocketExists(display) {
|
|
10256
|
+
const number = displayNumber(display);
|
|
10257
|
+
return number === void 0 ? false : existsSync(join(X11_SOCKET_DIR, `X${number}`));
|
|
10258
|
+
}
|
|
10259
|
+
function displayNumber(display) {
|
|
10260
|
+
const parsed = Number.parseInt(display.replace(/^:/u, ""), 10);
|
|
10261
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
10262
|
+
}
|
|
10263
|
+
function childEnvForDisplay(env, display) {
|
|
10264
|
+
const child = { ...env };
|
|
10265
|
+
for (const name of STRIPPED_WAYLAND_VARS) delete child[name];
|
|
10266
|
+
child.DISPLAY = display;
|
|
10267
|
+
return child;
|
|
10268
|
+
}
|
|
10269
|
+
function runNeedsPixels(config, scenario) {
|
|
10270
|
+
if (config.headless !== true) return true;
|
|
10271
|
+
const takesScreenshot = scenario.artifacts?.screenshots !== false || scenario.steps.some(({ screenshot }) => screenshot !== void 0);
|
|
10272
|
+
const evaluatesVisual = (scenario.assert?.visual?.length ?? 0) > 0;
|
|
10273
|
+
return takesScreenshot || evaluatesVisual || scenario.assert?.framebufferCoverage !== void 0;
|
|
10274
|
+
}
|
|
10275
|
+
async function provideDisplay(options = {}) {
|
|
10276
|
+
const env = options.env ?? process.env;
|
|
10277
|
+
const platform = options.platform ?? process.platform;
|
|
10278
|
+
const strategy = decideDisplayStrategy({
|
|
10279
|
+
displaySocketExists: options.displaySocketExists,
|
|
10280
|
+
env,
|
|
10281
|
+
platform
|
|
10282
|
+
});
|
|
10283
|
+
if (strategy.kind === "host") {
|
|
10284
|
+
return {
|
|
10285
|
+
compositor: void 0,
|
|
10286
|
+
display: void 0,
|
|
10287
|
+
env: { ...env },
|
|
10288
|
+
release: async () => void 0,
|
|
10289
|
+
strategy
|
|
10290
|
+
};
|
|
10291
|
+
}
|
|
10292
|
+
if (strategy.kind === "existing") {
|
|
10293
|
+
return {
|
|
10294
|
+
compositor: void 0,
|
|
10295
|
+
display: strategy.display,
|
|
10296
|
+
env: childEnvForDisplay(env, strategy.display),
|
|
10297
|
+
release: async () => void 0,
|
|
10298
|
+
strategy
|
|
10299
|
+
};
|
|
10300
|
+
}
|
|
10301
|
+
const commandExists2 = options.commandExists ?? defaultCommandExists;
|
|
10302
|
+
if (!commandExists2("Xvfb")) {
|
|
10303
|
+
throw new Error(
|
|
10304
|
+
"No usable X display is available and Xvfb is not installed, so this pixel-producing run cannot start (Debian/Ubuntu 'xvfb', Arch 'xorg-server-xvfb', Fedora 'xorg-x11-server-Xvfb'). Refusing to render blind."
|
|
10305
|
+
);
|
|
10306
|
+
}
|
|
10307
|
+
const spawnProcess = options.spawnProcess ?? spawn;
|
|
10308
|
+
const xvfb = spawnProcess("Xvfb", [
|
|
10309
|
+
"-displayfd",
|
|
10310
|
+
"3",
|
|
10311
|
+
"-nolisten",
|
|
10312
|
+
"tcp",
|
|
10313
|
+
// COMPOSITE and SHAPE are what a compositing manager needs before it can blend anything, and
|
|
10314
|
+
// the native desktop runtime refuses to attach its UI overlay to a display without one. Xvfb
|
|
10315
|
+
// does not enable them by default, so every native UI run on a private display reported
|
|
10316
|
+
// `TN_UI_OVERLAY:{"attached":false,"reason":"no compositing manager is running"}` — including
|
|
10317
|
+
// the starter template's own shipped native-playtests/react-hud scenario, which failed out of
|
|
10318
|
+
// the box on a freshly scaffolded project. A browser run does not care either way.
|
|
10319
|
+
"+extension",
|
|
10320
|
+
"COMPOSITE",
|
|
10321
|
+
"+extension",
|
|
10322
|
+
"SHAPE",
|
|
10323
|
+
"-screen",
|
|
10324
|
+
"0",
|
|
10325
|
+
strategy.screen
|
|
10326
|
+
], { stdio: ["ignore", "ignore", "pipe", "pipe"] });
|
|
10327
|
+
xvfb.on?.("error", () => void 0);
|
|
10328
|
+
try {
|
|
10329
|
+
const number = await readXvfbDisplayNumber(xvfb);
|
|
10330
|
+
const display = `:${number}`;
|
|
10331
|
+
const compositor = await startCompositor(display, { commandExists: commandExists2, env, spawnProcess });
|
|
10332
|
+
return {
|
|
10333
|
+
compositor: compositor?.name,
|
|
10334
|
+
display,
|
|
10335
|
+
env: childEnvForDisplay(env, display),
|
|
10336
|
+
release: async () => {
|
|
10337
|
+
if (compositor !== void 0) await stopChild(compositor.child);
|
|
10338
|
+
await stopChild(xvfb);
|
|
10339
|
+
},
|
|
10340
|
+
strategy
|
|
10341
|
+
};
|
|
10342
|
+
} catch (error) {
|
|
10343
|
+
await stopChild(xvfb);
|
|
10344
|
+
throw error;
|
|
10345
|
+
}
|
|
10346
|
+
}
|
|
10347
|
+
var COMPOSITORS = [
|
|
10348
|
+
{ args: ["-n"], name: "xcompmgr" },
|
|
10349
|
+
{ args: [], name: "picom" },
|
|
10350
|
+
{ args: [], name: "compton" }
|
|
10351
|
+
];
|
|
10352
|
+
var COMPOSITOR_SETTLE_MS = 250;
|
|
10353
|
+
async function startCompositor(display, options) {
|
|
10354
|
+
const choice = COMPOSITORS.find(({ name }) => options.commandExists(name));
|
|
10355
|
+
if (choice === void 0) return void 0;
|
|
10356
|
+
const child = options.spawnProcess(choice.name, [...choice.args], {
|
|
10357
|
+
env: { ...options.env, DISPLAY: display },
|
|
10358
|
+
stdio: "ignore"
|
|
10359
|
+
});
|
|
10360
|
+
let spawnFailed = false;
|
|
10361
|
+
child.on?.("error", () => {
|
|
10362
|
+
spawnFailed = true;
|
|
10363
|
+
});
|
|
10364
|
+
await new Promise((settle) => setTimeout(settle, COMPOSITOR_SETTLE_MS));
|
|
10365
|
+
if (spawnFailed) return void 0;
|
|
10366
|
+
if ((child.exitCode ?? null) !== null || (child.signalCode ?? null) !== null) return void 0;
|
|
10367
|
+
return { child, name: choice.name };
|
|
10368
|
+
}
|
|
10369
|
+
var XVFB_DISPLAY_TIMEOUT_MS = 1e4;
|
|
10370
|
+
async function readXvfbDisplayNumber(xvfb) {
|
|
10371
|
+
const report = xvfb.stdio[3];
|
|
10372
|
+
if (report === null || report === void 0 || typeof report.on !== "function") {
|
|
10373
|
+
throw new Error("Xvfb was spawned without a display-report descriptor to read.");
|
|
10374
|
+
}
|
|
10375
|
+
const stream = report;
|
|
10376
|
+
return new Promise((resolveDisplay, rejectDisplay) => {
|
|
10377
|
+
let settled = false;
|
|
10378
|
+
const finish = (settle) => {
|
|
10379
|
+
if (settled) return;
|
|
10380
|
+
settled = true;
|
|
10381
|
+
clearTimeout(timer);
|
|
10382
|
+
stream.removeListener("data", onData);
|
|
10383
|
+
stream.removeListener("close", onClose);
|
|
10384
|
+
settle();
|
|
10385
|
+
};
|
|
10386
|
+
const onData = (chunk) => {
|
|
10387
|
+
const number = Number.parseInt(String(chunk).trim(), 10);
|
|
10388
|
+
if (Number.isInteger(number) && number >= 0) finish(() => resolveDisplay(number));
|
|
10389
|
+
};
|
|
10390
|
+
const onClose = () => finish(() => rejectDisplay(new Error("Xvfb exited before it reported a display.")));
|
|
10391
|
+
const timer = setTimeout(() => finish(() => {
|
|
10392
|
+
rejectDisplay(new Error(`Xvfb did not report a display within ${XVFB_DISPLAY_TIMEOUT_MS}ms.`));
|
|
10393
|
+
}), XVFB_DISPLAY_TIMEOUT_MS);
|
|
10394
|
+
stream.on("data", onData);
|
|
10395
|
+
stream.on("close", onClose);
|
|
10396
|
+
});
|
|
10397
|
+
}
|
|
10398
|
+
async function stopChild(child) {
|
|
10399
|
+
const exitedAlready = () => (child.exitCode ?? null) !== null || (child.signalCode ?? null) !== null;
|
|
10400
|
+
if (exitedAlready()) return;
|
|
10401
|
+
child.kill("SIGTERM");
|
|
10402
|
+
const started = Date.now();
|
|
10403
|
+
while (Date.now() - started < 1e3 && !exitedAlready()) {
|
|
10404
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 25));
|
|
10405
|
+
}
|
|
10406
|
+
if (!exitedAlready()) child.kill("SIGKILL");
|
|
10407
|
+
}
|
|
10408
|
+
function defaultCommandExists(command) {
|
|
10409
|
+
const paths = (process.env.PATH ?? "").split(":").filter((segment) => segment.length > 0);
|
|
10410
|
+
return paths.some((directory) => existsSync(join(directory, command)));
|
|
10411
|
+
}
|
|
9477
10412
|
|
|
9478
10413
|
// src/runner/pipeline-cache-observations.ts
|
|
9479
10414
|
var marker = "TN_PIPELINE_CACHE:";
|
|
@@ -10415,14 +11350,24 @@ var FRAME_BUDGET_MARKER = "TN_FRAME_BUDGET:";
|
|
|
10415
11350
|
var PROJECTION_MARKER = "TN_PROJECTION:";
|
|
10416
11351
|
var HOST_GAP_MARKER = "TN_HOST_GAP:";
|
|
10417
11352
|
var HITCH_MARKER = "TN_FRAME_HITCH:";
|
|
11353
|
+
var SLOW_PHASE_MARKER = "TN_SLOW_PHASE:";
|
|
11354
|
+
var PRESENTS_TICK_MARKER = "TN_PRESENTS_TICK:";
|
|
11355
|
+
var PRESENTS_REACHED_DISPLAY_RATIO = 0.95;
|
|
10418
11356
|
function rankExactReasons(exact) {
|
|
10419
11357
|
return Object.entries(exact).filter(([, count]) => typeof count === "number" && count > 0).map(([reason, count]) => ({ count, reason })).sort((left, right) => right.count - left.count || (left.reason < right.reason ? -1 : 1));
|
|
10420
11358
|
}
|
|
10421
11359
|
var PRESENT_MODE_PATTERN = /Present mode: (\S+ \(vsync=(?:true|false)\))/u;
|
|
11360
|
+
function isPresentGap(payload) {
|
|
11361
|
+
const candidate = payload;
|
|
11362
|
+
return Number.isFinite(candidate.gapMs) && Number.isFinite(candidate.uptimeMs) && candidate.window === void 0;
|
|
11363
|
+
}
|
|
10422
11364
|
function parsePerformanceMarkers(text) {
|
|
10423
11365
|
const budgets = [];
|
|
10424
11366
|
const budgetPayloads = /* @__PURE__ */ new Set();
|
|
10425
11367
|
const hitches = [];
|
|
11368
|
+
const presentGaps = [];
|
|
11369
|
+
const presents = [];
|
|
11370
|
+
const slowPhases = [];
|
|
10426
11371
|
const hitchPayloads = /* @__PURE__ */ new Set();
|
|
10427
11372
|
const hostGaps = [];
|
|
10428
11373
|
const projections = [];
|
|
@@ -10443,13 +11388,27 @@ function parsePerformanceMarkers(text) {
|
|
|
10443
11388
|
const payload = JSON.stringify(hitch);
|
|
10444
11389
|
if (!hitchPayloads.has(payload)) {
|
|
10445
11390
|
hitchPayloads.add(payload);
|
|
10446
|
-
|
|
11391
|
+
if (isPresentGap(hitch)) {
|
|
11392
|
+
presentGaps.push(hitch);
|
|
11393
|
+
} else {
|
|
11394
|
+
if (!Number.isFinite(hitch.maxMs)) {
|
|
11395
|
+
throw new Error(
|
|
11396
|
+
`TN_PERF_MARKER_MALFORMED: a ${HITCH_MARKER} line carries neither a present gap (gapMs) nor a window's maxMs: ${line.trim()}`
|
|
11397
|
+
);
|
|
11398
|
+
}
|
|
11399
|
+
hitches.push(hitch);
|
|
11400
|
+
}
|
|
10447
11401
|
}
|
|
10448
11402
|
}
|
|
11403
|
+
const tick = parseMarkerLine(line, PRESENTS_TICK_MARKER);
|
|
11404
|
+
if (tick !== void 0) presents.push(tick);
|
|
11405
|
+
const slowPhase = parseMarkerLine(line, SLOW_PHASE_MARKER);
|
|
11406
|
+
if (slowPhase !== void 0) slowPhases.push(slowPhase);
|
|
10449
11407
|
const hostGap = parseMarkerLine(line, HOST_GAP_MARKER);
|
|
10450
11408
|
if (hostGap !== void 0) hostGaps.push(hostGap);
|
|
10451
11409
|
const projection = parseMarkerLine(line, PROJECTION_MARKER);
|
|
10452
11410
|
if (projection !== void 0) {
|
|
11411
|
+
assertProjectionTimings(projection);
|
|
10453
11412
|
const payload = JSON.stringify(projection);
|
|
10454
11413
|
if (!projectionPayloads.has(payload)) {
|
|
10455
11414
|
projectionPayloads.add(payload);
|
|
@@ -10459,7 +11418,36 @@ function parsePerformanceMarkers(text) {
|
|
|
10459
11418
|
const mode = PRESENT_MODE_PATTERN.exec(line);
|
|
10460
11419
|
if (mode?.[1] !== void 0) presentMode = mode[1];
|
|
10461
11420
|
}
|
|
10462
|
-
return {
|
|
11421
|
+
return {
|
|
11422
|
+
budgets,
|
|
11423
|
+
hitches,
|
|
11424
|
+
hostGaps,
|
|
11425
|
+
pipelineEvents,
|
|
11426
|
+
pipelineCaches: parsePipelineCacheObservations(text),
|
|
11427
|
+
presentGaps,
|
|
11428
|
+
presentMode,
|
|
11429
|
+
presents,
|
|
11430
|
+
projections,
|
|
11431
|
+
slowPhases
|
|
11432
|
+
};
|
|
11433
|
+
}
|
|
11434
|
+
var PROJECTION_TIMING_KEYS = ["compileMs", "reconcileMs", "lastReconcileMs", "maxReconcileMs"];
|
|
11435
|
+
function assertProjectionTimings(projection) {
|
|
11436
|
+
const timings = projection.timings;
|
|
11437
|
+
if (timings === void 0) return;
|
|
11438
|
+
if (typeof timings !== "object" || timings === null) {
|
|
11439
|
+
throw new Error(
|
|
11440
|
+
`TN_PERF_MARKER_MALFORMED: a TN_PROJECTION line carried a non-object timings (${JSON.stringify(timings)}).`
|
|
11441
|
+
);
|
|
11442
|
+
}
|
|
11443
|
+
for (const key of PROJECTION_TIMING_KEYS) {
|
|
11444
|
+
const value = timings[key];
|
|
11445
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
11446
|
+
throw new Error(
|
|
11447
|
+
`TN_PERF_MARKER_MALFORMED: a TN_PROJECTION line carried timings.${key} = ${JSON.stringify(value)} \u2014 a timing must be a finite number.`
|
|
11448
|
+
);
|
|
11449
|
+
}
|
|
11450
|
+
}
|
|
10463
11451
|
}
|
|
10464
11452
|
function parseMarkerLine(line, marker2) {
|
|
10465
11453
|
const start = line.indexOf(marker2);
|
|
@@ -10474,11 +11462,27 @@ function parseMarkerLine(line, marker2) {
|
|
|
10474
11462
|
);
|
|
10475
11463
|
}
|
|
10476
11464
|
}
|
|
10477
|
-
function assessPerfMarkers(parse, bounds, source) {
|
|
11465
|
+
function assessPerfMarkers(parse, bounds, source, display) {
|
|
10478
11466
|
const discardCount = parse.budgets.length > 1 ? 1 : 0;
|
|
10479
11467
|
const discardedWindows = parse.budgets.slice(0, discardCount).map(({ window: window2 }) => window2);
|
|
10480
11468
|
const steady = parse.budgets.slice(discardCount);
|
|
10481
11469
|
const violations = [];
|
|
11470
|
+
const unassessableWindows = [];
|
|
11471
|
+
const tick = parse.presents.at(-1);
|
|
11472
|
+
const presentsRatio = tick === void 0 || !Number.isFinite(tick.frames) || tick.frames <= 0 || !Number.isFinite(tick.presents) ? void 0 : tick.presents / tick.frames;
|
|
11473
|
+
const windowsCarryPresents = parse.budgets.length > 0 && parse.budgets.every((window2) => Number.isFinite(window2.presents));
|
|
11474
|
+
const unvouchableBy = () => {
|
|
11475
|
+
if (windowsCarryPresents) return display?.virtual === true ? `a ${display.strategy} display` : void 0;
|
|
11476
|
+
if (presentsRatio !== void 0 && presentsRatio < PRESENTS_REACHED_DISPLAY_RATIO) {
|
|
11477
|
+
return `the host presented ${tick?.presents} of ${tick?.frames} loop frames` + (tick?.capHz === void 0 ? "" : ` (cap ${tick.capHz} Hz)`);
|
|
11478
|
+
}
|
|
11479
|
+
return display?.virtual === true ? `a ${display.strategy} display` : void 0;
|
|
11480
|
+
};
|
|
11481
|
+
const unvouchable = unvouchableBy();
|
|
11482
|
+
const virtualDisplay = unvouchable !== void 0 && bounds.allowVirtualDisplay !== true;
|
|
11483
|
+
if (virtualDisplay && bounds.minFps !== void 0) {
|
|
11484
|
+
violations.push({ bound: bounds.minFps, code: "TN_PERF_VIRTUAL_DISPLAY", observed: void 0, window: -1 });
|
|
11485
|
+
}
|
|
10482
11486
|
if (steady.length < bounds.requireWindows) {
|
|
10483
11487
|
violations.push({ bound: bounds.requireWindows, code: "TN_PERF_WINDOWS_MISSING", observed: steady.length, window: -1 });
|
|
10484
11488
|
}
|
|
@@ -10491,19 +11495,47 @@ function assessPerfMarkers(parse, bounds, source) {
|
|
|
10491
11495
|
violations.push({ bound: bounds.maxFrameMsP95, code: "TN_PERF_MAX_FRAME_P95", observed: frameP95, window: window2.window });
|
|
10492
11496
|
}
|
|
10493
11497
|
}
|
|
10494
|
-
if (bounds.minFps !== void 0 &&
|
|
10495
|
-
|
|
11498
|
+
if (bounds.minFps !== void 0 && !virtualDisplay) {
|
|
11499
|
+
const rate = window2.presentedFps;
|
|
11500
|
+
if (rate !== void 0) {
|
|
11501
|
+
if (rate < bounds.minFps)
|
|
11502
|
+
violations.push({ bound: bounds.minFps, code: "TN_PERF_MIN_FPS", observed: rate, window: window2.window });
|
|
11503
|
+
} else if (window2.presents === void 0) {
|
|
11504
|
+
if (window2.fps < bounds.minFps)
|
|
11505
|
+
violations.push({ bound: bounds.minFps, code: "TN_PERF_MIN_FPS", observed: window2.fps, window: window2.window });
|
|
11506
|
+
} else {
|
|
11507
|
+
unassessableWindows.push(window2.window);
|
|
11508
|
+
}
|
|
10496
11509
|
}
|
|
10497
11510
|
}
|
|
11511
|
+
if (unassessableWindows.length > 0 && unassessableWindows.length === steady.length && bounds.minFps !== void 0) {
|
|
11512
|
+
violations.push({
|
|
11513
|
+
bound: bounds.minFps,
|
|
11514
|
+
code: "TN_PERF_BOUNDS_NOT_ASSESSABLE",
|
|
11515
|
+
observed: void 0,
|
|
11516
|
+
window: -1
|
|
11517
|
+
});
|
|
11518
|
+
}
|
|
10498
11519
|
return {
|
|
10499
11520
|
budgets: parse.budgets,
|
|
10500
11521
|
discardedWindows,
|
|
11522
|
+
...display !== void 0 || unvouchable !== void 0 ? {
|
|
11523
|
+
display: {
|
|
11524
|
+
fpsSuppressed: virtualDisplay,
|
|
11525
|
+
...unvouchable === void 0 ? {} : { reason: unvouchable },
|
|
11526
|
+
strategy: display?.strategy ?? "host",
|
|
11527
|
+
virtual: display?.virtual === true
|
|
11528
|
+
}
|
|
11529
|
+
} : {},
|
|
10501
11530
|
hitches: parse.hitches,
|
|
10502
11531
|
hostGaps: parse.hostGaps,
|
|
11532
|
+
presentGaps: parse.presentGaps,
|
|
11533
|
+
presents: parse.presents,
|
|
10503
11534
|
pipelineEvents: parse.pipelineEvents,
|
|
10504
11535
|
pipelineCaches: parse.pipelineCaches ?? [],
|
|
10505
11536
|
pass: violations.length === 0 && parse.budgets.length > 0,
|
|
10506
11537
|
presentMode: parse.presentMode,
|
|
11538
|
+
slowPhases: parse.slowPhases,
|
|
10507
11539
|
projections: parse.projections,
|
|
10508
11540
|
source,
|
|
10509
11541
|
violations
|
|
@@ -10511,13 +11543,16 @@ function assessPerfMarkers(parse, bounds, source) {
|
|
|
10511
11543
|
}
|
|
10512
11544
|
function parsePerfArgs(argv) {
|
|
10513
11545
|
const sources = { hostArgs: [] };
|
|
10514
|
-
const bounds = {
|
|
11546
|
+
const bounds = {
|
|
11547
|
+
requireWindows: 2
|
|
11548
|
+
};
|
|
10515
11549
|
let text = false;
|
|
10516
11550
|
let timeoutSeconds = 180;
|
|
10517
11551
|
for (let index = 0; index < argv.length; index += 1) {
|
|
10518
11552
|
const flag = argv[index];
|
|
10519
11553
|
const value = argv[index + 1];
|
|
10520
11554
|
if (flag === "--text") text = true;
|
|
11555
|
+
else if (flag === "--allow-virtual-display") bounds.allowVirtualDisplay = true;
|
|
10521
11556
|
else if (flag === "--file") {
|
|
10522
11557
|
sources.file = requireValue(flag, value);
|
|
10523
11558
|
index += 1;
|
|
@@ -10554,6 +11589,7 @@ function parsePerfArgs(argv) {
|
|
|
10554
11589
|
throw new PlaytestCliUsageError("threenative-playtest perf: --file, --executable and --logcat are mutually exclusive.");
|
|
10555
11590
|
}
|
|
10556
11591
|
return {
|
|
11592
|
+
allowVirtualDisplay: bounds.allowVirtualDisplay === true,
|
|
10557
11593
|
executable: sources.executable,
|
|
10558
11594
|
file: sources.file,
|
|
10559
11595
|
hostArgs: sources.hostArgs,
|
|
@@ -10580,8 +11616,8 @@ async function perfCommand(argv) {
|
|
|
10580
11616
|
const args = parsePerfArgs(argv);
|
|
10581
11617
|
try {
|
|
10582
11618
|
if (args.file !== void 0) {
|
|
10583
|
-
const
|
|
10584
|
-
return emit(parsePerformanceMarkers(await readFile(
|
|
11619
|
+
const path2 = resolve(args.file);
|
|
11620
|
+
return emit(parsePerformanceMarkers(await readFile(path2, "utf8")), args, `file: ${path2}`);
|
|
10585
11621
|
}
|
|
10586
11622
|
if (args.logcatSerial !== void 0) {
|
|
10587
11623
|
return emit(parsePerformanceMarkers(await readLogcat(args.logcatSerial)), args, `logcat: ${args.logcatSerial}`);
|
|
@@ -10602,6 +11638,7 @@ async function perfCommand(argv) {
|
|
|
10602
11638
|
}
|
|
10603
11639
|
async function runExecutable(args, executable) {
|
|
10604
11640
|
const source = `executable: ${[executable, ...args.hostArgs].join(" ")}`;
|
|
11641
|
+
const strategy = decideDisplayStrategy({ env: process.env, platform: process.platform });
|
|
10605
11642
|
const child = spawn(executable, args.hostArgs, { stdio: ["ignore", "pipe", "pipe"] });
|
|
10606
11643
|
let collected = "";
|
|
10607
11644
|
let stopped = false;
|
|
@@ -10631,7 +11668,10 @@ async function runExecutable(args, executable) {
|
|
|
10631
11668
|
});
|
|
10632
11669
|
child.on("exit", () => {
|
|
10633
11670
|
clearTimeout(timeout);
|
|
10634
|
-
const code = emit(parsePerformanceMarkers(collected), args, source
|
|
11671
|
+
const code = emit(parsePerformanceMarkers(collected), args, source, {
|
|
11672
|
+
strategy: strategy.kind,
|
|
11673
|
+
virtual: strategy.kind === "private-xvfb"
|
|
11674
|
+
});
|
|
10635
11675
|
process.exitCode = code;
|
|
10636
11676
|
settleExit(code);
|
|
10637
11677
|
});
|
|
@@ -10645,8 +11685,8 @@ async function readLogcat(serial) {
|
|
|
10645
11685
|
});
|
|
10646
11686
|
return stdout;
|
|
10647
11687
|
}
|
|
10648
|
-
function emit(parse, args, source) {
|
|
10649
|
-
const report = assessPerfMarkers(parse, args, source);
|
|
11688
|
+
function emit(parse, args, source, display) {
|
|
11689
|
+
const report = assessPerfMarkers(parse, args, source, display);
|
|
10650
11690
|
const windowsMissing = report.violations.some(({ code }) => code === "TN_PERF_WINDOWS_MISSING");
|
|
10651
11691
|
const exitCode = windowsMissing ? 2 : report.pass ? 0 : 1;
|
|
10652
11692
|
process.stdout.write(args.text ? formatPerfReport(report) : `${JSON.stringify(report, null, 2)}
|
|
@@ -10654,6 +11694,13 @@ function emit(parse, args, source) {
|
|
|
10654
11694
|
process.exitCode = exitCode;
|
|
10655
11695
|
return exitCode;
|
|
10656
11696
|
}
|
|
11697
|
+
function describeSuppression(report) {
|
|
11698
|
+
const reason = report.display?.reason;
|
|
11699
|
+
if (reason !== void 0) {
|
|
11700
|
+
return reason.startsWith("the host presented") ? `${reason} \u2014 the loop's cadence, not the display's` : `this run painted on ${reason}, where the present wait lands inside the update phase`;
|
|
11701
|
+
}
|
|
11702
|
+
return "this run's frame rate could not be vouched for";
|
|
11703
|
+
}
|
|
10657
11704
|
function formatPerfReport(report) {
|
|
10658
11705
|
const lines = [`perf \u2014 ${report.budgets.length} window(s) from ${report.source}`];
|
|
10659
11706
|
lines.push(formatPipelineCacheObservations(report.pipelineCaches ?? []));
|
|
@@ -10680,15 +11727,21 @@ function formatPerfReport(report) {
|
|
|
10680
11727
|
"gpu: not reported \u2014 the meter emits nothing rather than zero when the device did not grant 'timestamp-query'. Check the TN_WEBGPU_FEATURES line in the same log for what it did grant."
|
|
10681
11728
|
);
|
|
10682
11729
|
}
|
|
11730
|
+
const fpsSuppressed = report.display?.fpsSuppressed === true;
|
|
11731
|
+
if (fpsSuppressed) {
|
|
11732
|
+
lines.push(
|
|
11733
|
+
`fps suppressed: ${describeSuppression(report)}, so the frame rate is not the one a player would read. The phase rows below are unaffected. Rerun on the host display with TN_PLAYTEST_HOST_DISPLAY=1 for a quotable frame rate, or pass --allow-virtual-display to accept the phase timings with it.`
|
|
11734
|
+
);
|
|
11735
|
+
}
|
|
10683
11736
|
lines.push(
|
|
10684
|
-
`window fps frame p50/p95 render p50/p95 hostGap p50/p95${anyGpu ? " gpu ms" : ""}`
|
|
11737
|
+
`window ${fpsSuppressed ? " " : "fps "}frame p50/p95 render p50/p95 hostGap p50/p95${anyGpu ? " gpu ms" : ""}`
|
|
10685
11738
|
);
|
|
10686
11739
|
for (const window2 of report.budgets) {
|
|
10687
11740
|
const label = report.discardedWindows.includes(window2.window) ? `${window2.window}*` : String(window2.window);
|
|
10688
11741
|
lines.push(
|
|
10689
11742
|
[
|
|
10690
11743
|
label.padEnd(7),
|
|
10691
|
-
window2.fps.toFixed(2).padEnd(7),
|
|
11744
|
+
fpsSuppressed ? "".padEnd(7) : (window2.presentedFps ?? (window2.presents === 0 ? 0 : window2.fps)).toFixed(2).padEnd(7),
|
|
10692
11745
|
summary(window2.frame).padEnd(16),
|
|
10693
11746
|
summary(window2.phases?.render).padEnd(16),
|
|
10694
11747
|
summary(window2.phases?.hostGap),
|
|
@@ -10699,6 +11752,12 @@ function formatPerfReport(report) {
|
|
|
10699
11752
|
);
|
|
10700
11753
|
}
|
|
10701
11754
|
if (report.discardedWindows.length > 0) lines.push("* discarded as startup (window 1 always lies)");
|
|
11755
|
+
const presentedNothing = report.budgets.filter((window2) => window2.presents === 0);
|
|
11756
|
+
if (presentedNothing.length > 0) {
|
|
11757
|
+
lines.push(
|
|
11758
|
+
`windows ${presentedNothing.map((window2) => window2.window).join(", ")} presented nothing in their loop frames: too short to contain a present, so their frame rate is unmeasured rather than zero`
|
|
11759
|
+
);
|
|
11760
|
+
}
|
|
10702
11761
|
lines.push(...formatProjection(report.projections));
|
|
10703
11762
|
const lastGap = report.hostGaps.at(-1);
|
|
10704
11763
|
if (lastGap !== void 0) {
|
|
@@ -10707,7 +11766,7 @@ function formatPerfReport(report) {
|
|
|
10707
11766
|
lines.push(` ${name.padEnd(16)}${segment.p50Ms.toFixed(3)}`);
|
|
10708
11767
|
}
|
|
10709
11768
|
}
|
|
10710
|
-
lines.push(...formatHitches(report.hitches));
|
|
11769
|
+
lines.push(...formatHitches(report.hitches, report.presentGaps, report.slowPhases));
|
|
10711
11770
|
for (const violation of report.violations) {
|
|
10712
11771
|
const observed = violation.observed === void 0 ? "absent" : round3(violation.observed).toString();
|
|
10713
11772
|
lines.push(`FAIL ${violation.code}: window ${violation.window} observed ${observed} against bound ${violation.bound}`);
|
|
@@ -10725,6 +11784,9 @@ function formatProjection(windows) {
|
|
|
10725
11784
|
const lines = [
|
|
10726
11785
|
last.projecting ? `scene projection: on (${last.reasonCode}); ${last.sourceRenderables} authored renderables, ${last.drawsPlanned} draws planned, ${measured} actual` : `scene projection: DECLINED (${last.reasonCode})${last.reason === void 0 ? "" : ` \u2014 ${last.reason}`}; ${last.sourceRenderables} authored renderables drawn one at a time`
|
|
10727
11786
|
];
|
|
11787
|
+
lines.push(
|
|
11788
|
+
last.timings === void 0 ? " reconcile: unreported \u2014 this TN_PROJECTION line predates the timing field" : ` reconcile: ${last.timings.lastReconcileMs.toFixed(3)} ms last frame, ${last.timings.reconcileMs.toFixed(3)} ms cumulative, ${last.timings.maxReconcileMs.toFixed(3)} ms worst`
|
|
11789
|
+
);
|
|
10728
11790
|
const ranked = rankExactReasons(last.exact);
|
|
10729
11791
|
if (last.exactObjects > 0 && ranked.length === 0) {
|
|
10730
11792
|
lines.push(
|
|
@@ -10740,11 +11802,39 @@ function formatProjection(windows) {
|
|
|
10740
11802
|
function summary(summaryValue) {
|
|
10741
11803
|
return summaryValue === void 0 ? "\u2014" : `${summaryValue.p50.toFixed(1)}/${summaryValue.p95.toFixed(1)}`;
|
|
10742
11804
|
}
|
|
10743
|
-
function
|
|
10744
|
-
|
|
10745
|
-
const
|
|
10746
|
-
|
|
10747
|
-
|
|
11805
|
+
function phasesWithinGap(gap, slowPhases) {
|
|
11806
|
+
const start = gap.uptimeMs - gap.gapMs;
|
|
11807
|
+
const overlapping = slowPhases.filter(
|
|
11808
|
+
(phase) => phase.atMs > start && phase.atMs - phase.ms < gap.uptimeMs
|
|
11809
|
+
);
|
|
11810
|
+
const innermost = overlapping.filter(
|
|
11811
|
+
(candidate) => !overlapping.some(
|
|
11812
|
+
(other) => other !== candidate && other.atMs <= candidate.atMs && other.atMs - other.ms >= candidate.atMs - candidate.ms
|
|
11813
|
+
)
|
|
11814
|
+
);
|
|
11815
|
+
const reportable = innermost.length > 0 ? innermost : overlapping;
|
|
11816
|
+
return [...reportable].sort((left, right) => right.ms - left.ms).slice(0, 3);
|
|
11817
|
+
}
|
|
11818
|
+
function describeGap(gap, slowPhases) {
|
|
11819
|
+
const phases = phasesWithinGap(gap, slowPhases);
|
|
11820
|
+
if (phases.length === 0) {
|
|
11821
|
+
return slowPhases.length === 0 ? "no slow phase reported in this log" : "no slow phase fell inside it";
|
|
11822
|
+
}
|
|
11823
|
+
return phases.map((phase) => `${phase.phase} ${phase.ms.toFixed(3)} ms`).join(", ");
|
|
11824
|
+
}
|
|
11825
|
+
function formatHitches(hitches, presentGaps = [], slowPhases = []) {
|
|
11826
|
+
const lines = [];
|
|
11827
|
+
if (presentGaps.length > 0) {
|
|
11828
|
+
const worst = Math.max(...presentGaps.map((gap) => gap.gapMs));
|
|
11829
|
+
const at = presentGaps.reduce((best, gap) => gap.gapMs >= best.gapMs ? gap : best);
|
|
11830
|
+
lines.push(
|
|
11831
|
+
`present gaps (${presentGaps.length}): worst ${worst.toFixed(3)} ms at uptime ${at.uptimeMs.toFixed(0)} ms \u2014 one frame each, reported by the frame budget's own hitch threshold`
|
|
11832
|
+
);
|
|
11833
|
+
for (const gap of presentGaps) lines.push(` gap ${gap.gapMs.toFixed(3)} ms at uptime ${gap.uptimeMs.toFixed(0)} ms: ${describeGap(gap, slowPhases)}`);
|
|
11834
|
+
}
|
|
11835
|
+
if (hitches.length === 0) return lines;
|
|
11836
|
+
const windows = `hitch windows (post-launch, ${hitches.length}): worst ${Math.max(...hitches.map((h) => h.maxMs)).toFixed(3)} ms`;
|
|
11837
|
+
lines.push(windows);
|
|
10748
11838
|
const named = hitches.filter((hitch) => (hitch.pipelineCompileCalls ?? 0) > 0);
|
|
10749
11839
|
if (named.length === 0) {
|
|
10750
11840
|
const anyField = hitches.some((hitch) => hitch.pipelineCompileCalls !== void 0);
|
|
@@ -10780,12 +11870,11 @@ async function waitForStartupReady(options) {
|
|
|
10780
11870
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
10781
11871
|
throw new Error(`TN_PLAYTEST_STARTUP_TIMEOUT_INVALID: ${String(options.timeoutMs)}`);
|
|
10782
11872
|
const deadline = now() + timeoutMs;
|
|
10783
|
-
const settled = (observation) => options.acceptCompileSettled === true && observation.compileSettled === true;
|
|
10784
11873
|
const aborted = options.aborted ?? (() => false);
|
|
10785
11874
|
if (aborted()) throw abortedDuringStartup();
|
|
10786
11875
|
const hostAlive = options.hostAlive ?? (async () => void 0);
|
|
10787
11876
|
let observed = await pollStartup(bridge);
|
|
10788
|
-
while (observed === BUSY || observed.phase !== "ready"
|
|
11877
|
+
while (observed === BUSY || observed.phase !== "ready") {
|
|
10789
11878
|
if (aborted()) throw abortedDuringStartup();
|
|
10790
11879
|
if (observed === BUSY && await hostAlive() === false) throw hostExitedDuringStartup();
|
|
10791
11880
|
if (now() >= deadline) {
|
|
@@ -10795,11 +11884,21 @@ async function waitForStartupReady(options) {
|
|
|
10795
11884
|
"Let the application reach startup readiness \u2014 check that its loading gate can complete headlessly \u2014 or remove the runtime.startup capability if it has no startup phase."
|
|
10796
11885
|
));
|
|
10797
11886
|
}
|
|
10798
|
-
|
|
11887
|
+
try {
|
|
11888
|
+
await pump();
|
|
11889
|
+
} catch (error) {
|
|
11890
|
+
if (error instanceof PlaytestBridgeError && error.diagnostic.code === "TN_PLAYTEST_OPERATION_TIMEOUT") {
|
|
11891
|
+
observed = BUSY;
|
|
11892
|
+
continue;
|
|
11893
|
+
}
|
|
11894
|
+
throw error;
|
|
11895
|
+
}
|
|
10799
11896
|
observed = await pollStartup(bridge);
|
|
10800
11897
|
}
|
|
10801
11898
|
return {
|
|
10802
|
-
|
|
11899
|
+
// A declared software lane reaches `ready` on the bounded window rather than on sustained
|
|
11900
|
+
// in-budget frames, so it is labelled for what it is: not a smoothness measurement.
|
|
11901
|
+
rule: options.declaredSoftware === true ? "compile-settled" : "sustained-frames",
|
|
10803
11902
|
startup: observed
|
|
10804
11903
|
};
|
|
10805
11904
|
}
|
|
@@ -10908,12 +12007,12 @@ async function waitForResource(options) {
|
|
|
10908
12007
|
if (options.advance !== void 0 && now() < deadline) await options.advance();
|
|
10909
12008
|
}
|
|
10910
12009
|
}
|
|
10911
|
-
function waitFailure(message, instruction,
|
|
12010
|
+
function waitFailure(message, instruction, path2) {
|
|
10912
12011
|
return new PlaytestBridgeError(playtestDiagnostic(
|
|
10913
12012
|
"TN_PLAYTEST_OBSERVATION_UNAVAILABLE",
|
|
10914
12013
|
message,
|
|
10915
12014
|
instruction,
|
|
10916
|
-
{ path }
|
|
12015
|
+
{ path: path2 }
|
|
10917
12016
|
));
|
|
10918
12017
|
}
|
|
10919
12018
|
function json(value) {
|
|
@@ -11056,6 +12155,9 @@ var DeviceMailboxTransport = class {
|
|
|
11056
12155
|
closed = false;
|
|
11057
12156
|
nextId = 1;
|
|
11058
12157
|
nextOrder = 1;
|
|
12158
|
+
// Calls that gave up before the host answered. The host still answers them, late, and that
|
|
12159
|
+
// answer is theirs, not an error in whichever call is waiting when it lands.
|
|
12160
|
+
abandonedIds = /* @__PURE__ */ new Set();
|
|
11059
12161
|
responseObserver;
|
|
11060
12162
|
setResponseObserver(observer) {
|
|
11061
12163
|
this.responseObserver = observer;
|
|
@@ -11065,6 +12167,7 @@ var DeviceMailboxTransport = class {
|
|
|
11065
12167
|
this.connected = false;
|
|
11066
12168
|
this.nextId = 1;
|
|
11067
12169
|
this.nextOrder = 1;
|
|
12170
|
+
this.abandonedIds.clear();
|
|
11068
12171
|
await this.mailbox.remove(this.paths.request);
|
|
11069
12172
|
await this.mailbox.remove(this.paths.response);
|
|
11070
12173
|
}
|
|
@@ -11108,16 +12211,18 @@ var DeviceMailboxTransport = class {
|
|
|
11108
12211
|
async waitForResponse(id, method, order, timeoutMs) {
|
|
11109
12212
|
const deadline = Date.now() + timeoutMs;
|
|
11110
12213
|
while (!this.closed && Date.now() < deadline) {
|
|
11111
|
-
const raw = await this.mailbox
|
|
12214
|
+
const raw = await readMailboxFile(this.mailbox, this.paths.response);
|
|
11112
12215
|
if (raw !== void 0) {
|
|
11113
12216
|
const response = parseResponse(raw);
|
|
11114
12217
|
this.responseObserver?.({ body: raw, method, order, requestId: response.id });
|
|
11115
12218
|
await this.mailbox.remove(this.paths.response);
|
|
11116
|
-
if (response.id
|
|
11117
|
-
|
|
12219
|
+
if (response.id === id) return response;
|
|
12220
|
+
if (this.abandonedIds.has(response.id)) continue;
|
|
12221
|
+
throw new Error(`Unexpected device response id '${response.id}'.`);
|
|
11118
12222
|
}
|
|
11119
12223
|
await delayUntil(deadline);
|
|
11120
12224
|
}
|
|
12225
|
+
this.abandonedIds.add(id);
|
|
11121
12226
|
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
11122
12227
|
"TN_PLAYTEST_OPERATION_TIMEOUT",
|
|
11123
12228
|
`Device mailbox operation '${id}' exceeded ${timeoutMs}ms.`,
|
|
@@ -11125,7 +12230,7 @@ var DeviceMailboxTransport = class {
|
|
|
11125
12230
|
));
|
|
11126
12231
|
}
|
|
11127
12232
|
async readResponse() {
|
|
11128
|
-
const raw = await this.mailbox
|
|
12233
|
+
const raw = await readMailboxFile(this.mailbox, this.paths.response);
|
|
11129
12234
|
return raw === void 0 ? void 0 : parseResponse(raw);
|
|
11130
12235
|
}
|
|
11131
12236
|
};
|
|
@@ -11133,9 +12238,12 @@ function androidMailboxPaths(packageName, root = `/sdcard/Android/data/${package
|
|
|
11133
12238
|
return deviceMailboxPaths(root);
|
|
11134
12239
|
}
|
|
11135
12240
|
function deviceTimeoutDiagnostic(diagnostic2, hostAlive, lastConsoleLines) {
|
|
11136
|
-
if (diagnostic2.code !== "TN_PLAYTEST_OPERATION_TIMEOUT") return diagnostic2;
|
|
11137
12241
|
if (hostAlive !== false) return diagnostic2;
|
|
11138
12242
|
const tail = lastConsoleLines.length === 0 ? "the host produced no further output" : `last host output: ${lastConsoleLines.map((line) => line.slice(0, 160)).join(" | ").slice(0, 1e3)}`;
|
|
12243
|
+
if (diagnostic2.code === "TN_PLAYTEST_STARTUP_HOST_EXITED") {
|
|
12244
|
+
return playtestDiagnostic(diagnostic2.code, `${diagnostic2.message} \u2014 ${tail}`, diagnostic2.fix.instruction);
|
|
12245
|
+
}
|
|
12246
|
+
if (diagnostic2.code !== "TN_PLAYTEST_OPERATION_TIMEOUT") return diagnostic2;
|
|
11139
12247
|
return playtestDiagnostic(
|
|
11140
12248
|
"TN_PLAYTEST_HOST_EXITED",
|
|
11141
12249
|
`${diagnostic2.message}; the host process has exited \u2014 ${tail}`,
|
|
@@ -11163,10 +12271,10 @@ function validateDeviceEndpoint(value) {
|
|
|
11163
12271
|
function parseResponse(value) {
|
|
11164
12272
|
const parsed = JSON.parse(value);
|
|
11165
12273
|
assertBounded(parsed);
|
|
11166
|
-
if (!
|
|
12274
|
+
if (!isRecord5(parsed) || typeof parsed.id !== "string") {
|
|
11167
12275
|
throw new Error("Device response must contain a string id.");
|
|
11168
12276
|
}
|
|
11169
|
-
if (parsed.error !== void 0 && (!
|
|
12277
|
+
if (parsed.error !== void 0 && (!isRecord5(parsed.error) || typeof parsed.error.message !== "string")) {
|
|
11170
12278
|
throw new Error("Device response error must contain a message.");
|
|
11171
12279
|
}
|
|
11172
12280
|
return parsed;
|
|
@@ -11193,13 +12301,25 @@ function sendJson(response, status, value) {
|
|
|
11193
12301
|
response.writeHead(status, { "content-length": Buffer.byteLength(body), "content-type": "application/json" });
|
|
11194
12302
|
response.end(body);
|
|
11195
12303
|
}
|
|
11196
|
-
function
|
|
12304
|
+
function isRecord5(value) {
|
|
11197
12305
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11198
12306
|
}
|
|
11199
12307
|
async function delayUntil(deadline) {
|
|
11200
12308
|
const remaining = deadline - Date.now();
|
|
11201
12309
|
if (remaining > 0) await new Promise((resolve13) => setTimeout(resolve13, Math.min(40, remaining)));
|
|
11202
12310
|
}
|
|
12311
|
+
var kMailboxLockCodes = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES"]);
|
|
12312
|
+
async function readMailboxFile(mailbox, path2) {
|
|
12313
|
+
try {
|
|
12314
|
+
return await mailbox.read(path2);
|
|
12315
|
+
} catch (error) {
|
|
12316
|
+
if (isMailboxLockError(error)) return void 0;
|
|
12317
|
+
throw error;
|
|
12318
|
+
}
|
|
12319
|
+
}
|
|
12320
|
+
function isMailboxLockError(error) {
|
|
12321
|
+
return typeof error === "object" && error !== null && "code" in error && kMailboxLockCodes.has(String(error.code));
|
|
12322
|
+
}
|
|
11203
12323
|
|
|
11204
12324
|
// src/runner/deviceSignal.ts
|
|
11205
12325
|
init_shared();
|
|
@@ -11861,204 +12981,70 @@ async function sampleElementVisibility(page, target) {
|
|
|
11861
12981
|
}
|
|
11862
12982
|
if (screenshot === void 0) {
|
|
11863
12983
|
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
11864
|
-
"TN_PLAYTEST_OBSERVATION_UNAVAILABLE",
|
|
11865
|
-
"The isolated visibility screenshot was not produced.",
|
|
11866
|
-
"Rerun the playtest after ensuring the page renderer remains available for screenshot capture."
|
|
11867
|
-
));
|
|
11868
|
-
}
|
|
11869
|
-
let rendered;
|
|
11870
|
-
try {
|
|
11871
|
-
rendered = containsPaintedPixels(screenshot);
|
|
11872
|
-
} catch (error) {
|
|
11873
|
-
const reason = error instanceof Error ? error.message : "the PNG could not be decoded";
|
|
11874
|
-
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
11875
|
-
"TN_PLAYTEST_OBSERVATION_UNAVAILABLE",
|
|
11876
|
-
`Could not decode the isolated visibility screenshot: ${reason}.`,
|
|
11877
|
-
"Rerun the playtest after ensuring screenshot capture returns a valid PNG."
|
|
11878
|
-
));
|
|
11879
|
-
}
|
|
11880
|
-
return {
|
|
11881
|
-
bounds: domSample.bounds,
|
|
11882
|
-
rendered
|
|
11883
|
-
};
|
|
11884
|
-
}
|
|
11885
|
-
function containsPaintedPixels(screenshot) {
|
|
11886
|
-
const png = PNG.sync.read(screenshot);
|
|
11887
|
-
for (let offset = 0; offset < png.data.length; offset += 4) {
|
|
11888
|
-
if ((png.data[offset + 3] ?? 0) > 0) return true;
|
|
11889
|
-
}
|
|
11890
|
-
return false;
|
|
11891
|
-
}
|
|
11892
|
-
async function sampleHud(page, assertions) {
|
|
11893
|
-
if (assertions.length === 0) return {};
|
|
11894
|
-
const snapshots = await page.evaluate((requestedAssertions) => Object.fromEntries(requestedAssertions.flatMap(({ id, path }) => {
|
|
11895
|
-
const element = path === void 0 ? document.getElementById(id) : (() => {
|
|
11896
|
-
try {
|
|
11897
|
-
return document.querySelector(path);
|
|
11898
|
-
} catch {
|
|
11899
|
-
return null;
|
|
11900
|
-
}
|
|
11901
|
-
})();
|
|
11902
|
-
if (element === null) return [];
|
|
11903
|
-
const text = element.textContent?.trim() ?? "";
|
|
11904
|
-
const rawValue = element.getAttribute("data-value");
|
|
11905
|
-
const value = rawValue === null ? void 0 : Number.isFinite(Number(rawValue)) ? Number(rawValue) : rawValue;
|
|
11906
|
-
const snapshot = value === void 0 ? text : value;
|
|
11907
|
-
return [[id, path === void 0 ? snapshot : { [path]: snapshot }]];
|
|
11908
|
-
})), assertions);
|
|
11909
|
-
for (const assertion of assertions) {
|
|
11910
|
-
if (assertion.visible === void 0 || !Object.hasOwn(snapshots, assertion.id)) continue;
|
|
11911
|
-
const visibility = await sampleElementVisibility(
|
|
11912
|
-
page,
|
|
11913
|
-
assertion.path === void 0 ? { id: assertion.id } : { selector: assertion.path }
|
|
11914
|
-
);
|
|
11915
|
-
const snapshot = snapshots[assertion.id];
|
|
11916
|
-
if (assertion.path === void 0) {
|
|
11917
|
-
snapshots[assertion.id] = { text: snapshot, visible: visibility.rendered };
|
|
11918
|
-
continue;
|
|
11919
|
-
}
|
|
11920
|
-
const pathSnapshot = typeof snapshot === "object" && snapshot !== null && !Array.isArray(snapshot) ? snapshot[assertion.path] : snapshot;
|
|
11921
|
-
snapshots[assertion.id] = { [assertion.path]: { text: pathSnapshot, visible: visibility.rendered } };
|
|
11922
|
-
}
|
|
11923
|
-
return snapshots;
|
|
11924
|
-
}
|
|
11925
|
-
|
|
11926
|
-
// src/runner/steps.ts
|
|
11927
|
-
init_browser();
|
|
11928
|
-
var DEFAULT_XVFB_SCREEN = "1600x900x24";
|
|
11929
|
-
var HOST_DISPLAY_ENV = "TN_PLAYTEST_HOST_DISPLAY";
|
|
11930
|
-
var STRIPPED_WAYLAND_VARS = ["WAYLAND_DISPLAY", "WAYLAND_SOCKET", "XDG_SESSION_TYPE"];
|
|
11931
|
-
var X11_SOCKET_DIR = "/tmp/.X11-unix";
|
|
11932
|
-
function decideDisplayStrategy(input) {
|
|
11933
|
-
if (input.platform !== "linux") return { kind: "host" };
|
|
11934
|
-
const privateXvfb = {
|
|
11935
|
-
kind: "private-xvfb",
|
|
11936
|
-
screen: input.env.TN_XVFB_SCREEN ?? DEFAULT_XVFB_SCREEN
|
|
11937
|
-
};
|
|
11938
|
-
if (!hostDisplayRequested(input.env)) return privateXvfb;
|
|
11939
|
-
const display = input.env.DISPLAY;
|
|
11940
|
-
if (display !== void 0 && display.length > 0 && (input.displaySocketExists ?? x11SocketExists)(display)) {
|
|
11941
|
-
return { display, kind: "existing" };
|
|
11942
|
-
}
|
|
11943
|
-
return privateXvfb;
|
|
11944
|
-
}
|
|
11945
|
-
function hostDisplayRequested(env) {
|
|
11946
|
-
const value = env[HOST_DISPLAY_ENV];
|
|
11947
|
-
return value === "1" || value?.toLowerCase() === "true";
|
|
11948
|
-
}
|
|
11949
|
-
function x11SocketExists(display) {
|
|
11950
|
-
const number = displayNumber(display);
|
|
11951
|
-
return number === void 0 ? false : existsSync(join(X11_SOCKET_DIR, `X${number}`));
|
|
11952
|
-
}
|
|
11953
|
-
function displayNumber(display) {
|
|
11954
|
-
const parsed = Number.parseInt(display.replace(/^:/u, ""), 10);
|
|
11955
|
-
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
11956
|
-
}
|
|
11957
|
-
function childEnvForDisplay(env, display) {
|
|
11958
|
-
const child = { ...env };
|
|
11959
|
-
for (const name of STRIPPED_WAYLAND_VARS) delete child[name];
|
|
11960
|
-
child.DISPLAY = display;
|
|
11961
|
-
return child;
|
|
11962
|
-
}
|
|
11963
|
-
function runNeedsPixels(config, scenario) {
|
|
11964
|
-
if (config.headless !== true) return true;
|
|
11965
|
-
const takesScreenshot = scenario.artifacts?.screenshots !== false || scenario.steps.some(({ screenshot }) => screenshot !== void 0);
|
|
11966
|
-
const evaluatesVisual = (scenario.assert?.visual?.length ?? 0) > 0;
|
|
11967
|
-
return takesScreenshot || evaluatesVisual || scenario.assert?.framebufferCoverage !== void 0;
|
|
11968
|
-
}
|
|
11969
|
-
async function provideDisplay(options = {}) {
|
|
11970
|
-
const env = options.env ?? process.env;
|
|
11971
|
-
const platform = options.platform ?? process.platform;
|
|
11972
|
-
const strategy = decideDisplayStrategy({
|
|
11973
|
-
displaySocketExists: options.displaySocketExists,
|
|
11974
|
-
env,
|
|
11975
|
-
platform
|
|
11976
|
-
});
|
|
11977
|
-
if (strategy.kind === "host") {
|
|
11978
|
-
return { display: void 0, env: { ...env }, release: async () => void 0, strategy };
|
|
11979
|
-
}
|
|
11980
|
-
if (strategy.kind === "existing") {
|
|
11981
|
-
return {
|
|
11982
|
-
display: strategy.display,
|
|
11983
|
-
env: childEnvForDisplay(env, strategy.display),
|
|
11984
|
-
release: async () => void 0,
|
|
11985
|
-
strategy
|
|
11986
|
-
};
|
|
11987
|
-
}
|
|
11988
|
-
const commandExists2 = options.commandExists ?? defaultCommandExists;
|
|
11989
|
-
if (!commandExists2("Xvfb")) {
|
|
11990
|
-
throw new Error(
|
|
11991
|
-
"No usable X display is available and Xvfb is not installed, so this pixel-producing run cannot start (Debian/Ubuntu 'xvfb', Arch 'xorg-server-xvfb', Fedora 'xorg-x11-server-Xvfb'). Refusing to render blind."
|
|
11992
|
-
);
|
|
11993
|
-
}
|
|
11994
|
-
const spawnProcess = options.spawnProcess ?? spawn;
|
|
11995
|
-
const xvfb = spawnProcess("Xvfb", [
|
|
11996
|
-
"-displayfd",
|
|
11997
|
-
"3",
|
|
11998
|
-
"-nolisten",
|
|
11999
|
-
"tcp",
|
|
12000
|
-
"-screen",
|
|
12001
|
-
"0",
|
|
12002
|
-
strategy.screen
|
|
12003
|
-
], { stdio: ["ignore", "ignore", "pipe", "pipe"] });
|
|
12004
|
-
xvfb.on?.("error", () => void 0);
|
|
12984
|
+
"TN_PLAYTEST_OBSERVATION_UNAVAILABLE",
|
|
12985
|
+
"The isolated visibility screenshot was not produced.",
|
|
12986
|
+
"Rerun the playtest after ensuring the page renderer remains available for screenshot capture."
|
|
12987
|
+
));
|
|
12988
|
+
}
|
|
12989
|
+
let rendered;
|
|
12005
12990
|
try {
|
|
12006
|
-
|
|
12007
|
-
const display = `:${number}`;
|
|
12008
|
-
return {
|
|
12009
|
-
display,
|
|
12010
|
-
env: childEnvForDisplay(env, display),
|
|
12011
|
-
release: () => stopXvfb(xvfb),
|
|
12012
|
-
strategy
|
|
12013
|
-
};
|
|
12991
|
+
rendered = containsPaintedPixels(screenshot);
|
|
12014
12992
|
} catch (error) {
|
|
12015
|
-
|
|
12016
|
-
throw
|
|
12993
|
+
const reason = error instanceof Error ? error.message : "the PNG could not be decoded";
|
|
12994
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
12995
|
+
"TN_PLAYTEST_OBSERVATION_UNAVAILABLE",
|
|
12996
|
+
`Could not decode the isolated visibility screenshot: ${reason}.`,
|
|
12997
|
+
"Rerun the playtest after ensuring screenshot capture returns a valid PNG."
|
|
12998
|
+
));
|
|
12017
12999
|
}
|
|
13000
|
+
return {
|
|
13001
|
+
bounds: domSample.bounds,
|
|
13002
|
+
rendered
|
|
13003
|
+
};
|
|
12018
13004
|
}
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
throw new Error("Xvfb was spawned without a display-report descriptor to read.");
|
|
13005
|
+
function containsPaintedPixels(screenshot) {
|
|
13006
|
+
const png = PNG.sync.read(screenshot);
|
|
13007
|
+
for (let offset = 0; offset < png.data.length; offset += 4) {
|
|
13008
|
+
if ((png.data[offset + 3] ?? 0) > 0) return true;
|
|
12024
13009
|
}
|
|
12025
|
-
|
|
12026
|
-
return new Promise((resolveDisplay, rejectDisplay) => {
|
|
12027
|
-
let settled = false;
|
|
12028
|
-
const finish = (settle) => {
|
|
12029
|
-
if (settled) return;
|
|
12030
|
-
settled = true;
|
|
12031
|
-
clearTimeout(timer);
|
|
12032
|
-
stream.removeListener("data", onData);
|
|
12033
|
-
stream.removeListener("close", onClose);
|
|
12034
|
-
settle();
|
|
12035
|
-
};
|
|
12036
|
-
const onData = (chunk) => {
|
|
12037
|
-
const number = Number.parseInt(String(chunk).trim(), 10);
|
|
12038
|
-
if (Number.isInteger(number) && number >= 0) finish(() => resolveDisplay(number));
|
|
12039
|
-
};
|
|
12040
|
-
const onClose = () => finish(() => rejectDisplay(new Error("Xvfb exited before it reported a display.")));
|
|
12041
|
-
const timer = setTimeout(() => finish(() => {
|
|
12042
|
-
rejectDisplay(new Error(`Xvfb did not report a display within ${XVFB_DISPLAY_TIMEOUT_MS}ms.`));
|
|
12043
|
-
}), XVFB_DISPLAY_TIMEOUT_MS);
|
|
12044
|
-
stream.on("data", onData);
|
|
12045
|
-
stream.on("close", onClose);
|
|
12046
|
-
});
|
|
13010
|
+
return false;
|
|
12047
13011
|
}
|
|
12048
|
-
async function
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
13012
|
+
async function sampleHud(page, assertions) {
|
|
13013
|
+
if (assertions.length === 0) return {};
|
|
13014
|
+
const snapshots = await page.evaluate((requestedAssertions) => Object.fromEntries(requestedAssertions.flatMap(({ id, path: path2 }) => {
|
|
13015
|
+
const element = path2 === void 0 ? document.getElementById(id) : (() => {
|
|
13016
|
+
try {
|
|
13017
|
+
return document.querySelector(path2);
|
|
13018
|
+
} catch {
|
|
13019
|
+
return null;
|
|
13020
|
+
}
|
|
13021
|
+
})();
|
|
13022
|
+
if (element === null) return [];
|
|
13023
|
+
const text = element.textContent?.trim() ?? "";
|
|
13024
|
+
const rawValue = element.getAttribute("data-value");
|
|
13025
|
+
const value = rawValue === null ? void 0 : Number.isFinite(Number(rawValue)) ? Number(rawValue) : rawValue;
|
|
13026
|
+
const snapshot = value === void 0 ? text : value;
|
|
13027
|
+
return [[id, path2 === void 0 ? snapshot : { [path2]: snapshot }]];
|
|
13028
|
+
})), assertions);
|
|
13029
|
+
for (const assertion of assertions) {
|
|
13030
|
+
if (assertion.visible === void 0 || !Object.hasOwn(snapshots, assertion.id)) continue;
|
|
13031
|
+
const visibility = await sampleElementVisibility(
|
|
13032
|
+
page,
|
|
13033
|
+
assertion.path === void 0 ? { id: assertion.id } : { selector: assertion.path }
|
|
13034
|
+
);
|
|
13035
|
+
const snapshot = snapshots[assertion.id];
|
|
13036
|
+
if (assertion.path === void 0) {
|
|
13037
|
+
snapshots[assertion.id] = { text: snapshot, visible: visibility.rendered };
|
|
13038
|
+
continue;
|
|
13039
|
+
}
|
|
13040
|
+
const pathSnapshot = typeof snapshot === "object" && snapshot !== null && !Array.isArray(snapshot) ? snapshot[assertion.path] : snapshot;
|
|
13041
|
+
snapshots[assertion.id] = { [assertion.path]: { text: pathSnapshot, visible: visibility.rendered } };
|
|
12055
13042
|
}
|
|
12056
|
-
|
|
12057
|
-
}
|
|
12058
|
-
function defaultCommandExists(command) {
|
|
12059
|
-
const paths = (process.env.PATH ?? "").split(":").filter((segment) => segment.length > 0);
|
|
12060
|
-
return paths.some((directory) => existsSync(join(directory, command)));
|
|
13043
|
+
return snapshots;
|
|
12061
13044
|
}
|
|
13045
|
+
|
|
13046
|
+
// src/runner/steps.ts
|
|
13047
|
+
init_browser();
|
|
12062
13048
|
var DEFAULT_COLUMNS = 32;
|
|
12063
13049
|
var DEFAULT_ROWS = 18;
|
|
12064
13050
|
var PROBE_KEY = "__THREENATIVE_FRAMEBUFFER_COVERAGE_PROBE__";
|
|
@@ -12910,6 +13896,7 @@ async function provideRunDisplay() {
|
|
|
12910
13896
|
const provided = await provideDisplay();
|
|
12911
13897
|
writeCaptureState({
|
|
12912
13898
|
captureDisplay: {
|
|
13899
|
+
...provided.compositor === void 0 ? {} : { compositor: provided.compositor },
|
|
12913
13900
|
...provided.display === void 0 ? {} : { display: provided.display },
|
|
12914
13901
|
...provided.strategy.kind === "private-xvfb" ? { screen: provided.strategy.screen } : {},
|
|
12915
13902
|
strategy: provided.strategy.kind
|
|
@@ -12921,10 +13908,17 @@ function writeCaptureState(payload) {
|
|
|
12921
13908
|
process.stderr.write(`${JSON.stringify(payload)}
|
|
12922
13909
|
`);
|
|
12923
13910
|
}
|
|
13911
|
+
function isJudgeMarkerRequestFailure(method, url, judgeMarkerUrl) {
|
|
13912
|
+
return method === "POST" && judgeMarkerUrl !== void 0 && url === judgeMarkerUrl;
|
|
13913
|
+
}
|
|
12924
13914
|
function addPreflightDiagnostic(report, diagnostic2) {
|
|
12925
13915
|
return diagnostic2 === void 0 ? report : { ...report, diagnostics: [diagnostic2, ...report.diagnostics] };
|
|
12926
13916
|
}
|
|
12927
|
-
|
|
13917
|
+
var SOFTWARE_DEVICE_LOSS = /TN_DEVICE_LOST|WebGPU Device Lost|A valid external Instance reference no longer exists|Instance dropped in popErrorScope/iu;
|
|
13918
|
+
function isSoftwareDeviceLossEntry(entry) {
|
|
13919
|
+
return (entry.type === "error" || entry.type === "assert" || entry.type === "pageerror") && SOFTWARE_DEVICE_LOSS.test(entry.text);
|
|
13920
|
+
}
|
|
13921
|
+
function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEntries, networkEntries, pathLength = void 0, hud = {}, runtimeReady = true, visual = void 0, labeledSamples = [], framebufferCoverage = void 0, capture = void 0, captureFailure = void 0, movementSamples = [], setup = void 0, deviceMetrics = void 0, movementBaselineSnapshot = void 0, startup = void 0, deviceLifecycle = void 0) {
|
|
12928
13922
|
const movementSample = isAnonymousMovementScenario(scenario) ? observedMovementSample(movementSamples) : void 0;
|
|
12929
13923
|
const entity = scenario.assert?.movement?.entity ?? scenario.subject ?? movementSample?.entity ?? "";
|
|
12930
13924
|
const wholeRunObserved = isAnonymousMovementScenario(scenario) ? false : entityPosition(beforeSnapshot, entity) !== void 0 && entityPosition(afterSnapshot, entity) !== void 0;
|
|
@@ -12939,6 +13933,10 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12939
13933
|
const movementDelta = beforePosition === void 0 || afterPosition === void 0 ? void 0 : subtract(afterPosition, beforePosition);
|
|
12940
13934
|
const distance = movementDelta === void 0 ? 0 : length(movementDelta);
|
|
12941
13935
|
const performanceSeries = scenario.assert?.performance === void 0 && scenario.assert?.parity === void 0 ? void 0 : afterSnapshot?.runtimeDiagnosticsSeries ?? beforeSnapshot?.runtimeDiagnosticsSeries;
|
|
13936
|
+
const softwareAdapter = capture?.rendererKind === "webgpu" ? softwareAdapterName(capture.adapter) : void 0;
|
|
13937
|
+
const softwareLane = config.allowSoftwareAdapter === true && softwareAdapter !== void 0;
|
|
13938
|
+
const deviceLossEntries = softwareLane ? consoleEntries.filter(isSoftwareDeviceLossEntry) : [];
|
|
13939
|
+
const observedConsoleEntries = deviceLossEntries.length === 0 ? consoleEntries : consoleEntries.filter((entry) => !isSoftwareDeviceLossEntry(entry));
|
|
12942
13940
|
const diagnostics = [];
|
|
12943
13941
|
if (runtimeReady === false && scenario.assert?.diagnostics?.runtimeReady === true) {
|
|
12944
13942
|
diagnostics.push({
|
|
@@ -12951,6 +13949,11 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12951
13949
|
const base = {
|
|
12952
13950
|
...afterPosition === void 0 ? {} : { after: { frame: scenario.steps.length, position: afterPosition, ...afterRotation === void 0 ? {} : { rotation: afterRotation }, tick: afterSnapshot?.clock.tick ?? 0 } },
|
|
12953
13951
|
...beforePosition === void 0 ? {} : { before: { frame: 0, position: beforePosition, ...beforeRotation === void 0 ? {} : { rotation: beforeRotation }, tick: beforeSnapshot?.clock.tick ?? 0 } },
|
|
13952
|
+
// The harness's own `adapter.info` reading, carried on the report the assertions are evaluated
|
|
13953
|
+
// against. An assertion that selects its expectation per adapter class needs the provenance
|
|
13954
|
+
// here, not only in the written artifact — reading it after evaluation meant every such
|
|
13955
|
+
// assertion saw no adapter and failed closed on a run that had a real one.
|
|
13956
|
+
...capture === void 0 ? {} : { capture },
|
|
12954
13957
|
diagnostics,
|
|
12955
13958
|
diagnosticsPolicy: resolveDiagnosticsPolicy(scenario.assert?.diagnostics, config.target),
|
|
12956
13959
|
distance,
|
|
@@ -12971,7 +13974,7 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12971
13974
|
// Honest placement reporting: what the scenario asked to override, and what applied.
|
|
12972
13975
|
...setup === void 0 ? {} : { setup },
|
|
12973
13976
|
observations: buildObservations({
|
|
12974
|
-
console:
|
|
13977
|
+
console: observedConsoleEntries,
|
|
12975
13978
|
...components === void 0 ? {} : { components },
|
|
12976
13979
|
...labeledSamples.length === 0 ? {} : {
|
|
12977
13980
|
componentSeries: labeledSamples.map(({ label, snapshot }) => ({ label, snapshots: snapshot.components ?? {}, tick: snapshot.clock.tick ?? 0 })),
|
|
@@ -12980,11 +13983,15 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12980
13983
|
signals: labeledSamples.flatMap(({ signals }) => signals)
|
|
12981
13984
|
},
|
|
12982
13985
|
hud,
|
|
13986
|
+
...deviceLifecycle === void 0 ? {} : { deviceLifecycle },
|
|
12983
13987
|
...deviceMetrics === void 0 ? {} : { deviceMetrics },
|
|
12984
13988
|
...framebufferCoverage === void 0 ? {} : { framebufferCoverage },
|
|
12985
13989
|
network: networkEntries,
|
|
12986
13990
|
...performanceSeries === void 0 ? {} : { performanceSeries },
|
|
12987
13991
|
...afterSnapshot?.pipelineCensus === void 0 && beforeSnapshot?.pipelineCensus === void 0 ? {} : { pipelineCensus: afterSnapshot?.pipelineCensus ?? beforeSnapshot?.pipelineCensus },
|
|
13992
|
+
// Like the pipeline census: a report about the frame it was requested on, kept whole. The
|
|
13993
|
+
// last sample wins, because a capture describes the world as the run left it.
|
|
13994
|
+
...afterSnapshot?.geometry === void 0 && beforeSnapshot?.geometry === void 0 ? {} : { geometry: afterSnapshot?.geometry ?? beforeSnapshot?.geometry },
|
|
12988
13995
|
...afterSnapshot?.renderChain === void 0 && beforeSnapshot?.renderChain === void 0 ? {} : { renderChain: afterSnapshot?.renderChain ?? beforeSnapshot?.renderChain },
|
|
12989
13996
|
resources: resourceObservations(beforeSnapshot, afterSnapshot),
|
|
12990
13997
|
// The room as the run left it, falling back to how it started. A scene assertion is about
|
|
@@ -13006,8 +14013,8 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
13006
14013
|
},
|
|
13007
14014
|
...afterSnapshot?.physicsDebugSeries === void 0 ? {} : { physicsDebugSeries: afterSnapshot.physicsDebugSeries },
|
|
13008
14015
|
...beforeSnapshot?.physicsDebugSeries?.[0]?.snapshot === void 0 ? {} : { physicsDebugBefore: beforeSnapshot.physicsDebugSeries[0].snapshot },
|
|
13009
|
-
runtimeDiagnostics: normalizedRuntimeDiagnostics(afterSnapshot, scenario,
|
|
13010
|
-
...beforeSnapshot === void 0 ? {} : { runtimeDiagnosticsBefore: normalizedRuntimeDiagnostics(beforeSnapshot, scenario,
|
|
14016
|
+
runtimeDiagnostics: normalizedRuntimeDiagnostics(afterSnapshot, scenario, observedConsoleEntries),
|
|
14017
|
+
...beforeSnapshot === void 0 ? {} : { runtimeDiagnosticsBefore: normalizedRuntimeDiagnostics(beforeSnapshot, scenario, observedConsoleEntries) },
|
|
13011
14018
|
...visual === void 0 ? {} : { visual }
|
|
13012
14019
|
})
|
|
13013
14020
|
};
|
|
@@ -13019,7 +14026,14 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
13019
14026
|
const assertionResults = [...evaluated.assertions, ...cameraResult === void 0 ? [] : [cameraResult]];
|
|
13020
14027
|
const trivialityOptOuts = collectTrivialityOptOuts(assertionResults);
|
|
13021
14028
|
const allDiagnostics = [...diagnostics, ...evaluated.diagnostics];
|
|
13022
|
-
|
|
14029
|
+
if (deviceLossEntries.length > 0) {
|
|
14030
|
+
allDiagnostics.push({
|
|
14031
|
+
code: "TN_PLAYTEST_SOFTWARE_DEVICE_LOST",
|
|
14032
|
+
message: `The software adapter '${softwareAdapter}' lost its WebGPU device during the run; ${deviceLossEntries.length} device-loss console error(s) were recorded instead of failing noConsoleErrors. This lane is not render evidence.`,
|
|
14033
|
+
severity: "warning",
|
|
14034
|
+
suggestion: "Expected on a CPU rasteriser when a frame outlasts the GPU process; rerun on a hardware adapter before reading any pixels."
|
|
14035
|
+
});
|
|
14036
|
+
}
|
|
13023
14037
|
if (softwareAdapter !== void 0 && config.allowSoftwareAdapter !== true) {
|
|
13024
14038
|
allDiagnostics.push({
|
|
13025
14039
|
code: "TN_PLAYTEST_SOFTWARE_ADAPTER",
|
|
@@ -13173,12 +14187,26 @@ function pageLifecycleDiagnostic(error, lifecycle, url) {
|
|
|
13173
14187
|
"The renderer process died mid-run, so no assertion after that point was observed. Re-run with a smaller scene or a hardware GPU; under a virtual display the software WebGPU path is the usual cause."
|
|
13174
14188
|
);
|
|
13175
14189
|
}
|
|
13176
|
-
const where = lifecycle.navigations.length === 0 ? "an unrecorded location" : `'${lifecycle.navigations.join("', '")}'`;
|
|
13177
14190
|
const observed = [
|
|
13178
14191
|
`page closed: ${lifecycle.closed}`,
|
|
13179
14192
|
`main-frame navigations: ${lifecycle.frameNavigations.length}`,
|
|
13180
14193
|
...lifecycle.tail.length === 0 ? [] : [`last console: ${lifecycle.tail.join(" | ")}`]
|
|
13181
14194
|
].join("; ");
|
|
14195
|
+
if (lifecycle.closed && lifecycle.navigations.length === 0) {
|
|
14196
|
+
return playtestDiagnostic(
|
|
14197
|
+
"TN_PLAYTEST_PAGE_CLOSED",
|
|
14198
|
+
`The page went away without navigating while the scenario was running at '${url}'; runner error: ${detail}. Observed: ${observed}.`,
|
|
14199
|
+
"Nothing moved the document: the page closed mid-run, so every observation after that point is missing. This is the machine rather than the game \u2014 check for a GPU stall, an out-of-memory kill, or another browser benchmark competing for the display, then re-run. Nothing in the scenario can fix it."
|
|
14200
|
+
);
|
|
14201
|
+
}
|
|
14202
|
+
if (!lifecycle.closed && lifecycle.navigations.length === 0) {
|
|
14203
|
+
return playtestDiagnostic(
|
|
14204
|
+
"TN_PLAYTEST_PAGE_CRASHED",
|
|
14205
|
+
`The renderer went away without navigating or closing while the scenario was running at '${url}'; runner error: ${detail}. Observed: ${observed}.`,
|
|
14206
|
+
"Nothing moved the document and nothing closed the page, so Playwright destroyed the execution context because the renderer itself is gone, and every observation after that point is missing. The events say how the page died, not why: read the console tail above for the last frame cost or device-loss line. A frame that cost seconds on a software adapter is what a hardware look costs there \u2014 check the adapter and the tier the run reported before re-running, and check for a GPU stall, a lost or out-of-memory device, or another browser benchmark competing for the display. No scenario step can fix this."
|
|
14207
|
+
);
|
|
14208
|
+
}
|
|
14209
|
+
const where = lifecycle.navigations.length === 0 ? "an unrecorded location" : `'${lifecycle.navigations.join("', '")}'`;
|
|
13182
14210
|
return playtestDiagnostic(
|
|
13183
14211
|
"TN_PLAYTEST_PAGE_NAVIGATED",
|
|
13184
14212
|
`The page navigated to ${where} while the scenario was running at '${url}'; runner error: ${detail}. Observed: ${observed}.`,
|
|
@@ -13359,9 +14387,28 @@ function removeStrandedProfiles(before, root = tmpdir()) {
|
|
|
13359
14387
|
}
|
|
13360
14388
|
return removed;
|
|
13361
14389
|
}
|
|
14390
|
+
async function startBrowserCpuProfile(page, outputPath) {
|
|
14391
|
+
const cdp = await page.context().newCDPSession(page);
|
|
14392
|
+
await cdp.send("Profiler.enable");
|
|
14393
|
+
await cdp.send("Profiler.start");
|
|
14394
|
+
return {
|
|
14395
|
+
async stop() {
|
|
14396
|
+
const { profile } = await cdp.send("Profiler.stop");
|
|
14397
|
+
await writeFile(outputPath, `${JSON.stringify(profile)}
|
|
14398
|
+
`);
|
|
14399
|
+
return outputPath;
|
|
14400
|
+
}
|
|
14401
|
+
};
|
|
14402
|
+
}
|
|
14403
|
+
function assertCpuProfileTargetSupported(target, cpuProfilePath) {
|
|
14404
|
+
if (cpuProfilePath === void 0) return;
|
|
14405
|
+
if (target === "browser" || target === "desktop") return;
|
|
14406
|
+
throw new Error(
|
|
14407
|
+
`TN_PLAYTEST_CPU_PROFILE_UNSUPPORTED: --cpu-prof is not supported on the ${target} target; use the browser or desktop target.`
|
|
14408
|
+
);
|
|
14409
|
+
}
|
|
13362
14410
|
|
|
13363
14411
|
// src/runner/runner.ts
|
|
13364
|
-
var SCREENSHOT_TIMEOUT_MS = 12e4;
|
|
13365
14412
|
var TOUCH_BROWSER_USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 8) AppleWebKit/537.36 Chrome/151.0 Mobile Safari/537.36";
|
|
13366
14413
|
function isTouchPrimaryBrowserScenario(scenario) {
|
|
13367
14414
|
if (!scenario.steps.some(({ pointers }) => pointers !== void 0)) return false;
|
|
@@ -13411,7 +14458,10 @@ async function runStandalonePlaytest(config, options = {}) {
|
|
|
13411
14458
|
async function runStandalonePlaytestInternal(config, options = {}) {
|
|
13412
14459
|
const usesFreePort = config.server !== void 0 && config.port === 0;
|
|
13413
14460
|
const activeConfig = usesFreePort ? await resolveManagedServerConfig(config) : config;
|
|
13414
|
-
const scenario =
|
|
14461
|
+
const scenario = withPerformanceBudget(
|
|
14462
|
+
await loadPlaytestScenario(activeConfig.projectPath, activeConfig.scenarioPath),
|
|
14463
|
+
activeConfig.performanceBudget
|
|
14464
|
+
);
|
|
13415
14465
|
const browserConfig = scenario.assert?.performance === void 0 ? activeConfig : {
|
|
13416
14466
|
...activeConfig,
|
|
13417
14467
|
browserArgs: [
|
|
@@ -13442,6 +14492,25 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13442
14492
|
await serverTeardownPromise;
|
|
13443
14493
|
};
|
|
13444
14494
|
let profilesBeforeLaunch;
|
|
14495
|
+
let cpuProfile;
|
|
14496
|
+
let cpuProfileStopped = false;
|
|
14497
|
+
const stopCpuProfile = async (failClosed) => {
|
|
14498
|
+
if (cpuProfile === void 0 || cpuProfileStopped) return;
|
|
14499
|
+
cpuProfileStopped = true;
|
|
14500
|
+
try {
|
|
14501
|
+
const written = await cpuProfile.stop();
|
|
14502
|
+
process.stderr.write(`${JSON.stringify({ cpuProfile: written })}
|
|
14503
|
+
`);
|
|
14504
|
+
} catch (error) {
|
|
14505
|
+
if (failClosed) {
|
|
14506
|
+
throw new Error(`TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED: ${error instanceof Error ? error.message : String(error)}`);
|
|
14507
|
+
}
|
|
14508
|
+
process.stderr.write(
|
|
14509
|
+
`${JSON.stringify({ diagnostics: [{ code: "TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED", message: error instanceof Error ? error.message : String(error), severity: "error" }] })}
|
|
14510
|
+
`
|
|
14511
|
+
);
|
|
14512
|
+
}
|
|
14513
|
+
};
|
|
13445
14514
|
const teardown = async (stopManagedServerOnTeardown = ownsServer) => {
|
|
13446
14515
|
teardownPromise ??= (async () => {
|
|
13447
14516
|
await teardownBrowserSession(page, context, browser, browserLaunch, options.remoteBrowser);
|
|
@@ -13539,7 +14608,12 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13539
14608
|
if (pageLifecycle.tail.length > 8) pageLifecycle.tail.shift();
|
|
13540
14609
|
});
|
|
13541
14610
|
page.on("pageerror", (error) => consoleEntries.push({ source: "page-error", text: error.stack || error.message, type: "pageerror" }));
|
|
13542
|
-
page.on("requestfailed", (request) =>
|
|
14611
|
+
page.on("requestfailed", (request) => {
|
|
14612
|
+
const method = request.method();
|
|
14613
|
+
const url = request.url();
|
|
14614
|
+
if (isJudgeMarkerRequestFailure(method, url, activeConfig.judgeMarkerUrl)) return;
|
|
14615
|
+
networkEntries.push({ method, url });
|
|
14616
|
+
});
|
|
13543
14617
|
const observedPage = page;
|
|
13544
14618
|
page.on("crash", () => {
|
|
13545
14619
|
pageLifecycle.crashed = true;
|
|
@@ -13568,8 +14642,8 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13568
14642
|
await waitFrames(page, scenario.warmupFrames);
|
|
13569
14643
|
const startupOutcome = bridge === void 0 || scenario.awaitStartup === false ? void 0 : await waitForStartupReady({
|
|
13570
14644
|
aborted: () => tearingDown,
|
|
13571
|
-
acceptCompileSettled: activeConfig.allowSoftwareAdapter === true,
|
|
13572
14645
|
bridge,
|
|
14646
|
+
declaredSoftware: activeConfig.allowSoftwareAdapter === true,
|
|
13573
14647
|
pump: () => waitFrames(activePage, 1)
|
|
13574
14648
|
});
|
|
13575
14649
|
const runtimeReady = await page.evaluate(
|
|
@@ -13586,13 +14660,15 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13586
14660
|
"entities",
|
|
13587
14661
|
"resources",
|
|
13588
14662
|
...scenario.assert?.aerodynamics === void 0 && scenario.assert?.contacts === void 0 && scenario.assert?.settled === void 0 ? [] : ["physicsDebugSeries"],
|
|
13589
|
-
...scenario.assert?.performance === void 0 ? [] : ["runtimeDiagnosticsSeries"],
|
|
14663
|
+
...scenario.assert?.performance === void 0 && scenario.assert?.parity === void 0 ? [] : ["runtimeDiagnosticsSeries"],
|
|
13590
14664
|
...scenario.assert?.renderChain === void 0 ? [] : ["renderChain"]
|
|
13591
14665
|
],
|
|
13592
14666
|
resources: resourceIds,
|
|
13593
14667
|
// One selector per assertion, in scenario order: the evaluator reads observation `i` for
|
|
13594
14668
|
// assertion `i`, so the mapping has to be positional and never deduplicated.
|
|
13595
|
-
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) }
|
|
14669
|
+
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) },
|
|
14670
|
+
// One armed capture per sample; absent means the bridge does no geometry work at all.
|
|
14671
|
+
...scenario.assert?.geometry === void 0 ? {} : { geometry: scenario.assert.geometry }
|
|
13596
14672
|
};
|
|
13597
14673
|
const labeledSamples = [];
|
|
13598
14674
|
const capturesAnonymousMovement = isAnonymousMovementScenario(scenario);
|
|
@@ -13732,6 +14808,9 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13732
14808
|
scenario.artifacts?.screenshots === "before-after" ? join(activeConfig.artifactDirectory, "before.png") : void 0
|
|
13733
14809
|
) : await capturePage("before.png", scenario.artifacts?.screenshots === "before-after" ? { path: join(activeConfig.artifactDirectory, "before.png") } : {}) : void 0;
|
|
13734
14810
|
let framebufferCoverage;
|
|
14811
|
+
if (activeConfig.cpuProfilePath !== void 0) {
|
|
14812
|
+
cpuProfile = await startBrowserCpuProfile(activePage, activeConfig.cpuProfilePath);
|
|
14813
|
+
}
|
|
13735
14814
|
for (const [index, step] of scenario.steps.entries()) {
|
|
13736
14815
|
const framebufferAssertion = scenario.assert?.framebufferCoverage;
|
|
13737
14816
|
if (framebufferAssertion !== void 0 && step.label === framebufferAssertion.window.startStep) {
|
|
@@ -13829,6 +14908,7 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13829
14908
|
network: networkEntries,
|
|
13830
14909
|
runtimeTrace: normalizedRuntimeDiagnostics(afterSnapshot, scenario, consoleEntries)
|
|
13831
14910
|
});
|
|
14911
|
+
await stopCpuProfile(true);
|
|
13832
14912
|
if (options.remoteBrowser === void 0) await context.close();
|
|
13833
14913
|
else await page.close();
|
|
13834
14914
|
return addPreflightDiagnostic(report, preflight);
|
|
@@ -13844,6 +14924,7 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13844
14924
|
} finally {
|
|
13845
14925
|
process.off("SIGINT", handleSignal);
|
|
13846
14926
|
process.off("SIGTERM", handleSignal);
|
|
14927
|
+
await stopCpuProfile(false);
|
|
13847
14928
|
await teardown();
|
|
13848
14929
|
await providedDisplay?.release().catch(() => void 0);
|
|
13849
14930
|
await captureLease?.release().catch(() => void 0);
|
|
@@ -13870,7 +14951,10 @@ async function runStandalonePlaytests(config) {
|
|
|
13870
14951
|
const activeConfig = usesFreePort ? await resolveManagedServerConfig(config) : config;
|
|
13871
14952
|
const scenarios = [];
|
|
13872
14953
|
for (const scenarioPath of scenarioPaths) {
|
|
13873
|
-
scenarios.push(
|
|
14954
|
+
scenarios.push(withPerformanceBudget(
|
|
14955
|
+
await loadPlaytestScenario(activeConfig.projectPath, scenarioPath),
|
|
14956
|
+
activeConfig.performanceBudget
|
|
14957
|
+
));
|
|
13874
14958
|
}
|
|
13875
14959
|
let server;
|
|
13876
14960
|
try {
|
|
@@ -13962,8 +15046,8 @@ async function analyzeFramebufferCoverageRecording(videoPath, artifactDirectory,
|
|
|
13962
15046
|
}
|
|
13963
15047
|
const gridSize = assertion.grid ?? DEFAULT_GRID;
|
|
13964
15048
|
const grids = [];
|
|
13965
|
-
for (const
|
|
13966
|
-
grids.push(sampleFramebufferCoverageVideoFrame(PNG.sync.read(await readFile(
|
|
15049
|
+
for (const path2 of framePaths) {
|
|
15050
|
+
grids.push(sampleFramebufferCoverageVideoFrame(PNG.sync.read(await readFile(path2)), box, gridSize));
|
|
13967
15051
|
}
|
|
13968
15052
|
const observation = boundarySource === "scenario-steps" ? analyzeScenarioBracketedCoverageFrames(grids, framePaths, assertion) : analyzeSampledCoverageFrames(grids, framePaths, assertion);
|
|
13969
15053
|
if (observation.firstViolation === void 0) return observation;
|
|
@@ -14041,8 +15125,8 @@ async function findVideoContentBoxFromFiles(framePaths) {
|
|
|
14041
15125
|
const firstPath = appPaths[0];
|
|
14042
15126
|
if (firstPath === void 0) return void 0;
|
|
14043
15127
|
const accumulator = createContentBoxAccumulator(PNG.sync.read(await readFile(firstPath)));
|
|
14044
|
-
for (const
|
|
14045
|
-
if (!accumulateContentBox(accumulator, PNG.sync.read(await readFile(
|
|
15128
|
+
for (const path2 of appPaths) {
|
|
15129
|
+
if (!accumulateContentBox(accumulator, PNG.sync.read(await readFile(path2)))) {
|
|
14046
15130
|
throw new Error("TN_PLAYTEST_FRAMEBUFFER_COVERAGE_VIDEO_SIZE_CHANGED");
|
|
14047
15131
|
}
|
|
14048
15132
|
}
|
|
@@ -14143,6 +15227,7 @@ function errorMessage2(error) {
|
|
|
14143
15227
|
}
|
|
14144
15228
|
|
|
14145
15229
|
// src/runner/androidRunner.ts
|
|
15230
|
+
init_adapter_class();
|
|
14146
15231
|
init_shared();
|
|
14147
15232
|
async function runAndroidPlaytest(config, dependencies = {}) {
|
|
14148
15233
|
config.endpoint ?? "http://127.0.0.1:41777/playtest";
|
|
@@ -14179,14 +15264,18 @@ async function runDevicePlaytest(config, target) {
|
|
|
14179
15264
|
return report;
|
|
14180
15265
|
}
|
|
14181
15266
|
async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
14182
|
-
const scenario =
|
|
15267
|
+
const scenario = withPerformanceBudget(
|
|
15268
|
+
await loadPlaytestScenario(config.projectPath, config.scenarioPath),
|
|
15269
|
+
config.performanceBudget
|
|
15270
|
+
);
|
|
14183
15271
|
await throwIfAborted(target);
|
|
14184
15272
|
await mkdir(config.artifactDirectory, { recursive: true });
|
|
14185
15273
|
await throwIfAborted(target);
|
|
14186
15274
|
const unsupported = unsupportedAssertion(
|
|
14187
15275
|
scenario,
|
|
14188
15276
|
target.name,
|
|
14189
|
-
typeof target.driver.tap === "function"
|
|
15277
|
+
typeof target.driver.tap === "function",
|
|
15278
|
+
canDriveAndroidLifecycle(target.driver)
|
|
14190
15279
|
);
|
|
14191
15280
|
if (unsupported !== void 0) return failureReport(config, scenario, unsupported, target.name);
|
|
14192
15281
|
if (target.name === "android" && scenario.assert?.framebufferCoverage !== void 0 && (typeof target.driver.startScreenRecording !== "function" || typeof target.driver.stopScreenRecording !== "function")) {
|
|
@@ -14249,8 +15338,8 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14249
15338
|
await throwIfAborted(target);
|
|
14250
15339
|
const attached = bridge;
|
|
14251
15340
|
const startupOutcome = scenario.awaitStartup === false ? void 0 : await waitForStartupReady({
|
|
14252
|
-
acceptCompileSettled: config.allowSoftwareAdapter === true,
|
|
14253
15341
|
bridge: attached,
|
|
15342
|
+
declaredSoftware: config.allowSoftwareAdapter === true,
|
|
14254
15343
|
// A device host can die mid-launch, and its mailbox then simply stops answering. Without
|
|
14255
15344
|
// this the wait reads that as a slow loading gate and burns its whole deadline; with it
|
|
14256
15345
|
// the report names the exit and carries the console tail that says why.
|
|
@@ -14266,12 +15355,21 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14266
15355
|
"diagnostics",
|
|
14267
15356
|
"entities",
|
|
14268
15357
|
"resources",
|
|
14269
|
-
...scenario.assert?.aerodynamics === void 0 && scenario.assert?.contacts === void 0 && scenario.assert?.settled === void 0 ? [] : ["physicsDebugSeries"]
|
|
15358
|
+
...scenario.assert?.aerodynamics === void 0 && scenario.assert?.contacts === void 0 && scenario.assert?.settled === void 0 ? [] : ["physicsDebugSeries"],
|
|
15359
|
+
// The same two fields the browser lane requests, for the same reason: the bridge answers
|
|
15360
|
+
// only what it was asked for, so a `performance`, `parity` or `renderChain` assertion on a
|
|
15361
|
+
// device or desktop target used to evaluate against an empty series and fail as
|
|
15362
|
+
// "unobserved" even though the handshake advertises `runtime.performance` and
|
|
15363
|
+
// `runtime.renderChain`.
|
|
15364
|
+
...scenario.assert?.performance === void 0 && scenario.assert?.parity === void 0 ? [] : ["runtimeDiagnosticsSeries"],
|
|
15365
|
+
...scenario.assert?.renderChain === void 0 ? [] : ["renderChain"]
|
|
14270
15366
|
],
|
|
14271
15367
|
resources: observedResourceIds(scenario),
|
|
14272
15368
|
// One selector per assertion in scenario order: the evaluator reads observation `i` for
|
|
14273
15369
|
// assertion `i`, so the mapping has to be positional and never deduplicated.
|
|
14274
|
-
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) }
|
|
15370
|
+
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) },
|
|
15371
|
+
// One armed capture per sample; absent means the bridge does no geometry work at all.
|
|
15372
|
+
...scenario.assert?.geometry === void 0 ? {} : { geometry: scenario.assert.geometry }
|
|
14275
15373
|
};
|
|
14276
15374
|
const before = await bridge.sample(sampleRequest);
|
|
14277
15375
|
const pathEntity = scenario.assert?.movement?.pathLength === void 0 ? void 0 : scenario.assert.movement.entity ?? scenario.subject;
|
|
@@ -14284,14 +15382,31 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14284
15382
|
const heldKeys = /* @__PURE__ */ new Set();
|
|
14285
15383
|
let pointerButtons = 0;
|
|
14286
15384
|
let pointerCount = 0;
|
|
15385
|
+
let pointerX = 0;
|
|
15386
|
+
let pointerY = 0;
|
|
15387
|
+
let pointerHeld = false;
|
|
15388
|
+
const lifecycle = scenario.steps.some((step) => step.lifecycle !== void 0) ? new DeviceLifecycleRecorder(
|
|
15389
|
+
target.driver,
|
|
15390
|
+
// Only a build that installed a physics plugin owns a step counter, and it says so by
|
|
15391
|
+
// advertising the capability. Anything else is reported as unmeasured, never as zero.
|
|
15392
|
+
attached.description.capabilities.includes("runtime.physics"),
|
|
15393
|
+
// The step count is an observation like any other, read through the same sample request
|
|
15394
|
+
// the rest of the run uses rather than a channel of its own.
|
|
15395
|
+
() => attached.sample(sampleRequest)
|
|
15396
|
+
) : void 0;
|
|
15397
|
+
if (lifecycle !== void 0) await lifecycle.launch();
|
|
14287
15398
|
for (const [index, step] of scenario.steps.entries()) {
|
|
14288
15399
|
await throwIfAborted(target);
|
|
15400
|
+
if (step.lifecycle !== void 0) {
|
|
15401
|
+
await lifecycle?.run(step.lifecycle, () => attached.advance(1));
|
|
15402
|
+
continue;
|
|
15403
|
+
}
|
|
14289
15404
|
const framebufferAssertion = scenario.assert?.framebufferCoverage;
|
|
14290
15405
|
if (target.name === "android" && framebufferAssertion !== void 0 && step.label === framebufferAssertion.window.startStep) {
|
|
14291
15406
|
try {
|
|
14292
15407
|
await target.driver.startScreenRecording?.();
|
|
14293
15408
|
coverageRecordingStarted = true;
|
|
14294
|
-
await
|
|
15409
|
+
await delay2(100);
|
|
14295
15410
|
} catch (error) {
|
|
14296
15411
|
framebufferCoverage = unreadableCoverageObservation(error);
|
|
14297
15412
|
}
|
|
@@ -14329,11 +15444,14 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14329
15444
|
if (step.pointerPosition !== void 0) {
|
|
14330
15445
|
const previousPointerButtons = pointerButtons;
|
|
14331
15446
|
pointerButtons = step.pointerPosition.buttons ?? pointerButtons;
|
|
15447
|
+
if (pointerButtons !== 0) pointerHeld = true;
|
|
15448
|
+
pointerX = step.pointerPosition.x * scenario.viewport.width;
|
|
15449
|
+
pointerY = step.pointerPosition.y * scenario.viewport.height;
|
|
14332
15450
|
await transport.call("input.pointer", {
|
|
14333
15451
|
buttons: pointerButtons,
|
|
14334
15452
|
type: pointerButtons === 0 ? "move" : previousPointerButtons === 0 ? "down" : "move",
|
|
14335
|
-
x:
|
|
14336
|
-
y:
|
|
15453
|
+
x: pointerX,
|
|
15454
|
+
y: pointerY
|
|
14337
15455
|
});
|
|
14338
15456
|
}
|
|
14339
15457
|
if (step.pointers !== void 0) {
|
|
@@ -14373,7 +15491,7 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14373
15491
|
if (coverageRecordingStarted) {
|
|
14374
15492
|
for (let frame = 0; frame < frames; frame += 1) {
|
|
14375
15493
|
await bridge.advance(1);
|
|
14376
|
-
await
|
|
15494
|
+
await delay2(100);
|
|
14377
15495
|
}
|
|
14378
15496
|
} else {
|
|
14379
15497
|
await bridge.advance(frames);
|
|
@@ -14407,9 +15525,10 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14407
15525
|
if (capturesAnonymousMovement) afterStep = await bridge.sample(sampleRequest);
|
|
14408
15526
|
}
|
|
14409
15527
|
}
|
|
14410
|
-
if (step.
|
|
15528
|
+
if (pointerHeld && step.release && step.kind !== "wait") {
|
|
14411
15529
|
pointerButtons = 0;
|
|
14412
|
-
|
|
15530
|
+
pointerHeld = false;
|
|
15531
|
+
await transport.call("input.pointer", { buttons: 0, type: "up", x: pointerX, y: pointerY });
|
|
14413
15532
|
}
|
|
14414
15533
|
if (step.pointers !== void 0 && step.release) {
|
|
14415
15534
|
await setDevicePointers(target, transport, [], scenario.viewport);
|
|
@@ -14465,13 +15584,18 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14465
15584
|
void 0,
|
|
14466
15585
|
labeledSamples,
|
|
14467
15586
|
framebufferCoverage,
|
|
14468
|
-
|
|
15587
|
+
// The adapter this machine reported, read by the engine's own `adapter.info` probe and
|
|
15588
|
+
// carried in the census snapshot. Without it a device run reached `capture === undefined`,
|
|
15589
|
+
// so every `assert.renderChain.perAdapter` failed closed on a run that had a real adapter —
|
|
15590
|
+
// the flat expectation was used against a tier the software branch would have accepted.
|
|
15591
|
+
nativeCaptureProvenance(after?.pipelineCensus ?? before?.pipelineCensus, target.name, scenario.viewport),
|
|
14469
15592
|
void 0,
|
|
14470
15593
|
movementSamples,
|
|
14471
15594
|
setupApplication2,
|
|
14472
15595
|
metrics?.observation(),
|
|
14473
15596
|
void 0,
|
|
14474
|
-
startupOutcome === void 0 ? void 0 : { ...startupOutcome.startup, rule: startupOutcome.rule }
|
|
15597
|
+
startupOutcome === void 0 ? void 0 : { ...startupOutcome.startup, rule: startupOutcome.rule },
|
|
15598
|
+
lifecycle?.observation()
|
|
14475
15599
|
);
|
|
14476
15600
|
await writeObservationArtifacts(config.artifactDirectory, scenario.artifacts, {
|
|
14477
15601
|
console: consoleEntries,
|
|
@@ -14487,7 +15611,7 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14487
15611
|
} catch (error) {
|
|
14488
15612
|
if (error instanceof PlaytestBridgeError) {
|
|
14489
15613
|
let diagnostic2 = error.diagnostic;
|
|
14490
|
-
if (diagnostic2.code === "TN_PLAYTEST_OPERATION_TIMEOUT") {
|
|
15614
|
+
if (diagnostic2.code === "TN_PLAYTEST_OPERATION_TIMEOUT" || diagnostic2.code === "TN_PLAYTEST_STARTUP_HOST_EXITED") {
|
|
14491
15615
|
const hostAlive = await target.driver.isAlive().catch(() => void 0);
|
|
14492
15616
|
const lastConsoleLines = hostAlive === false ? (await target.driver.captureConsole().catch(() => [])).slice(-6).map((entry) => entry.text) : [];
|
|
14493
15617
|
diagnostic2 = deviceTimeoutDiagnostic(diagnostic2, hostAlive, lastConsoleLines);
|
|
@@ -14533,9 +15657,9 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14533
15657
|
if (cleanupErrors.length > 0) cleanupState.error = cleanupFailure(cleanupErrors);
|
|
14534
15658
|
}
|
|
14535
15659
|
}
|
|
14536
|
-
async function captureDeviceScreenshot(target,
|
|
14537
|
-
await target.driver.screenshot(
|
|
14538
|
-
assertCaptureNotBlank(await readFile(
|
|
15660
|
+
async function captureDeviceScreenshot(target, path2) {
|
|
15661
|
+
await target.driver.screenshot(path2);
|
|
15662
|
+
assertCaptureNotBlank(await readFile(path2), path2);
|
|
14539
15663
|
}
|
|
14540
15664
|
function deviceMetricsRecorder(target) {
|
|
14541
15665
|
if (target.name !== "android") return void 0;
|
|
@@ -14557,16 +15681,16 @@ function cleanupFailure(errors) {
|
|
|
14557
15681
|
function createDeviceTransport(driver, endpoint, paths, operationTimeoutMs) {
|
|
14558
15682
|
if (isMailboxDriver(driver)) {
|
|
14559
15683
|
const mailbox = {
|
|
14560
|
-
read: (
|
|
14561
|
-
remove: (
|
|
14562
|
-
write: (
|
|
15684
|
+
read: (path2) => driver.readFile(path2),
|
|
15685
|
+
remove: (path2) => driver.removeFile(path2),
|
|
15686
|
+
write: (path2, contents) => driver.writeFile(path2, contents)
|
|
14563
15687
|
};
|
|
14564
15688
|
return new DeviceMailboxTransport(mailbox, paths, operationTimeoutMs);
|
|
14565
15689
|
}
|
|
14566
15690
|
return new DeviceBridgeTransport(endpoint);
|
|
14567
15691
|
}
|
|
14568
15692
|
async function setDevicePointers(target, transport, pointers, viewport) {
|
|
14569
|
-
if (target.name === "ios") {
|
|
15693
|
+
if (target.name === "ios" || target.name === "desktop") {
|
|
14570
15694
|
await transport.call("input.pointers", {
|
|
14571
15695
|
pointers: pointers.map((pointer) => ({
|
|
14572
15696
|
...pointer.buttons === void 0 ? {} : { buttons: pointer.buttons },
|
|
@@ -14640,7 +15764,203 @@ function androidKeyEventCode(key) {
|
|
|
14640
15764
|
function isMailboxDriver(driver) {
|
|
14641
15765
|
return typeof driver.readFile === "function" && typeof driver.removeFile === "function" && typeof driver.writeFile === "function";
|
|
14642
15766
|
}
|
|
14643
|
-
function
|
|
15767
|
+
function canDriveAndroidLifecycle(driver) {
|
|
15768
|
+
return typeof driver.background === "function" && typeof driver.foreground === "function" && typeof driver.rotate === "function" && typeof driver.lifecycleState === "function";
|
|
15769
|
+
}
|
|
15770
|
+
var ANDROID_LIFECYCLE_SETTLE_READS = 8;
|
|
15771
|
+
var ANDROID_LIFECYCLE_SETTLE_POLL_MS = 250;
|
|
15772
|
+
var ANDROID_LIFECYCLE_PAUSE_HOLD_MS = 1e3;
|
|
15773
|
+
var DeviceLifecycleRecorder = class {
|
|
15774
|
+
constructor(driver, countsPhysicsSteps, sample) {
|
|
15775
|
+
this.driver = driver;
|
|
15776
|
+
this.countsPhysicsSteps = countsPhysicsSteps;
|
|
15777
|
+
this.sample = sample;
|
|
15778
|
+
}
|
|
15779
|
+
driver;
|
|
15780
|
+
countsPhysicsSteps;
|
|
15781
|
+
sample;
|
|
15782
|
+
phases = [];
|
|
15783
|
+
startedAt = Date.now();
|
|
15784
|
+
physicsSteps = {
|
|
15785
|
+
afterAdvance: null,
|
|
15786
|
+
afterForeground: null,
|
|
15787
|
+
beforeBackground: null
|
|
15788
|
+
};
|
|
15789
|
+
pid = 0;
|
|
15790
|
+
/** The process the run launched, read before any step could change it. */
|
|
15791
|
+
async launch() {
|
|
15792
|
+
const state = await this.readDevice();
|
|
15793
|
+
if (state.pid === void 0) {
|
|
15794
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15795
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_UNOBSERVED",
|
|
15796
|
+
"`pidof` reports no process for the package this run launched, so there is no app session to follow.",
|
|
15797
|
+
"Launch the activity and confirm it is running before driving lifecycle steps; a lifecycle proof needs one live process to observe."
|
|
15798
|
+
));
|
|
15799
|
+
}
|
|
15800
|
+
this.pid = state.pid;
|
|
15801
|
+
}
|
|
15802
|
+
async run(step, advance) {
|
|
15803
|
+
const operation = step.operation;
|
|
15804
|
+
const rotation = step.operation === "rotate" ? step.rotation : void 0;
|
|
15805
|
+
const driver = this.driver;
|
|
15806
|
+
if (operation === "background") {
|
|
15807
|
+
this.physicsSteps.beforeBackground = await this.readPhysicsSteps();
|
|
15808
|
+
}
|
|
15809
|
+
try {
|
|
15810
|
+
if (operation === "background") await driver.background?.();
|
|
15811
|
+
else if (operation === "foreground") await driver.foreground?.();
|
|
15812
|
+
else await driver.rotate?.(rotation);
|
|
15813
|
+
} catch (error) {
|
|
15814
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15815
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_NOT_APPLIED",
|
|
15816
|
+
`The device did not apply the '${operation}' lifecycle operation: ${error instanceof Error ? error.message : String(error)}`,
|
|
15817
|
+
"Inspect the device for an orientation lock, a permission prompt or a system dialog over the app, then rerun the same scenario."
|
|
15818
|
+
));
|
|
15819
|
+
}
|
|
15820
|
+
if (operation === "foreground") {
|
|
15821
|
+
this.physicsSteps.afterForeground = await this.readPhysicsSteps();
|
|
15822
|
+
}
|
|
15823
|
+
if (operation !== "background") {
|
|
15824
|
+
await advance();
|
|
15825
|
+
this.physicsSteps.afterAdvance = await this.readPhysicsSteps();
|
|
15826
|
+
}
|
|
15827
|
+
const state = await this.read();
|
|
15828
|
+
this.requirePhaseEffect(operation, rotation, state);
|
|
15829
|
+
const settled = operation === "background" ? await this.readSettled(state) : void 0;
|
|
15830
|
+
const phase = settled?.state ?? state;
|
|
15831
|
+
this.phases.push({
|
|
15832
|
+
at: Date.now() - this.startedAt,
|
|
15833
|
+
focused: phase.focused,
|
|
15834
|
+
frames: phase.frames,
|
|
15835
|
+
...settled === void 0 ? {} : { framesPaused: settled.framesPaused },
|
|
15836
|
+
phase: operation,
|
|
15837
|
+
pid: phase.pid,
|
|
15838
|
+
...rotation === void 0 ? {} : { requestedRotation: rotation },
|
|
15839
|
+
...phase.windowRotation === void 0 ? {} : { windowRotation: phase.windowRotation }
|
|
15840
|
+
});
|
|
15841
|
+
}
|
|
15842
|
+
/**
|
|
15843
|
+
* The `background` phase's own claim: the surface stopped, so read the platform's frame counter
|
|
15844
|
+
* until it agrees. A backgrounded app that keeps rendering reports the truth —
|
|
15845
|
+
* `framesPaused: false`, for an assertion layer to bind to — rather than a settled value the
|
|
15846
|
+
* runner invented on its behalf.
|
|
15847
|
+
*
|
|
15848
|
+
* One unchanged count is not a paused surface. A renderer that is still drawing at 10 Hz answers
|
|
15849
|
+
* two quick reads with the same number, so a settling read followed by one equal read called a
|
|
15850
|
+
* live 10 Hz surface stopped — the exact claim this phase exists to make. The count therefore has
|
|
15851
|
+
* to hold still across a full second, and a count that moves resets the clock, so the settle is
|
|
15852
|
+
* bounded in wall time as well as in reads.
|
|
15853
|
+
*/
|
|
15854
|
+
async readSettled(initial) {
|
|
15855
|
+
let state = initial;
|
|
15856
|
+
let heldSince = Date.now();
|
|
15857
|
+
for (let read2 = 0; read2 < ANDROID_LIFECYCLE_SETTLE_READS; read2 += 1) {
|
|
15858
|
+
await delay2(ANDROID_LIFECYCLE_SETTLE_POLL_MS);
|
|
15859
|
+
const next = await this.read();
|
|
15860
|
+
if (next.frames !== state.frames) {
|
|
15861
|
+
heldSince = Date.now();
|
|
15862
|
+
state = next;
|
|
15863
|
+
continue;
|
|
15864
|
+
}
|
|
15865
|
+
if (Date.now() - heldSince >= ANDROID_LIFECYCLE_PAUSE_HOLD_MS) return { framesPaused: true, state: next };
|
|
15866
|
+
state = next;
|
|
15867
|
+
}
|
|
15868
|
+
return { framesPaused: false, state };
|
|
15869
|
+
}
|
|
15870
|
+
/**
|
|
15871
|
+
* The driver already waited for these readings; check them again here, because a phase is a
|
|
15872
|
+
* claim about the device and the claim is worth more than the command's exit code.
|
|
15873
|
+
*/
|
|
15874
|
+
requirePhaseEffect(operation, rotation, state) {
|
|
15875
|
+
if (state.focused !== (operation !== "background")) {
|
|
15876
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15877
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_NOT_APPLIED",
|
|
15878
|
+
`After the '${operation}' operation the device still reports the app as ${state.focused ? "focused" : "unfocused"}.`,
|
|
15879
|
+
"Inspect the device for an orientation lock, a permission prompt or a system dialog over the app, then rerun the same scenario."
|
|
15880
|
+
));
|
|
15881
|
+
}
|
|
15882
|
+
if (rotation !== void 0 && state.windowRotation !== rotation) {
|
|
15883
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15884
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_NOT_APPLIED",
|
|
15885
|
+
`The '${operation}' operation asked for rotation ${rotation} and the device's window reports ${String(state.windowRotation)}.`,
|
|
15886
|
+
"Inspect the device for an orientation lock or a fixed-orientation activity, then rerun the same scenario."
|
|
15887
|
+
));
|
|
15888
|
+
}
|
|
15889
|
+
}
|
|
15890
|
+
observation() {
|
|
15891
|
+
const background = this.phases.find(({ phase }) => phase === "background");
|
|
15892
|
+
const last = this.phases.at(-1);
|
|
15893
|
+
const { afterAdvance, afterForeground, beforeBackground } = this.physicsSteps;
|
|
15894
|
+
return {
|
|
15895
|
+
phases: this.phases,
|
|
15896
|
+
physics: this.countsPhysicsSteps ? {
|
|
15897
|
+
available: true,
|
|
15898
|
+
steps: { afterAdvance, afterForeground, beforeBackground },
|
|
15899
|
+
stepsAdvanced: afterForeground === null || afterAdvance === null ? null : afterAdvance > afterForeground,
|
|
15900
|
+
stepsPaused: beforeBackground === null || afterForeground === null ? null : afterForeground === beforeBackground
|
|
15901
|
+
} : {
|
|
15902
|
+
available: false,
|
|
15903
|
+
reason: "the bridge does not advertise runtime.physics, so this build installs no physics plugin and nothing counts simulation steps; install rapier() to measure physics continuity across a lifecycle"
|
|
15904
|
+
},
|
|
15905
|
+
render: {
|
|
15906
|
+
framesAdvanced: background === void 0 || last === void 0 ? null : last.frames > background.frames,
|
|
15907
|
+
framesPaused: background?.framesPaused ?? null
|
|
15908
|
+
},
|
|
15909
|
+
session: { pid: this.pid }
|
|
15910
|
+
};
|
|
15911
|
+
}
|
|
15912
|
+
/**
|
|
15913
|
+
* The runtime-owned simulation-step count, or nothing on a build that installs no physics plugin.
|
|
15914
|
+
*
|
|
15915
|
+
* Fails closed rather than reporting a zero: a bridge that advertises `runtime.physics` and
|
|
15916
|
+
* answers with no count, a string, or a negative number has not measured the simulation, and a
|
|
15917
|
+
* zero here would be indistinguishable from a game that genuinely never stepped.
|
|
15918
|
+
*/
|
|
15919
|
+
async readPhysicsSteps() {
|
|
15920
|
+
if (!this.countsPhysicsSteps) return null;
|
|
15921
|
+
const value = (await this.sample()).physicsSteps;
|
|
15922
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
15923
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15924
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_PHYSICS_UNOBSERVED",
|
|
15925
|
+
`The bridge advertises runtime.physics but reported ${JSON.stringify(value) ?? "no simulation-step count"} instead of one, so physics continuity cannot be recorded across the lifecycle.`,
|
|
15926
|
+
"Install rapier(), whose runtime.physics observation carries the step count taken at simulation.step, or drop the lifecycle steps. A count a game keeps in its own state is not a measurement, and an absent one is never read as a simulation that stood still."
|
|
15927
|
+
));
|
|
15928
|
+
}
|
|
15929
|
+
return value;
|
|
15930
|
+
}
|
|
15931
|
+
/** One device reading, in the process this run launched. A different pid is a failed run. */
|
|
15932
|
+
async read() {
|
|
15933
|
+
const state = await this.readDevice();
|
|
15934
|
+
if (state.pid !== this.pid) {
|
|
15935
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15936
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_SESSION_CHANGED",
|
|
15937
|
+
`The app process changed across the lifecycle: the run launched pid ${String(this.pid)} and the device now reports ${String(state.pid)}.`,
|
|
15938
|
+
"A lifecycle proof needs one process across background, foreground and rotation. Find what killed or relaunched the app before rerunning."
|
|
15939
|
+
));
|
|
15940
|
+
}
|
|
15941
|
+
return { ...state, pid: this.pid };
|
|
15942
|
+
}
|
|
15943
|
+
/** One complete device reading, or a named failure. Never a default. */
|
|
15944
|
+
async readDevice() {
|
|
15945
|
+
const state = await this.driver.lifecycleState?.();
|
|
15946
|
+
if (state?.frames === void 0) {
|
|
15947
|
+
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
15948
|
+
"TN_PLAYTEST_ANDROID_LIFECYCLE_UNOBSERVED",
|
|
15949
|
+
"The device reported no frame count for this process, so a lifecycle phase cannot be recorded.",
|
|
15950
|
+
"Run against a device that answers `dumpsys gfxinfo <package>` with a frame counter, or drop the lifecycle steps; an absent counter is never read as a paused surface."
|
|
15951
|
+
));
|
|
15952
|
+
}
|
|
15953
|
+
return { ...state, frames: state.frames };
|
|
15954
|
+
}
|
|
15955
|
+
};
|
|
15956
|
+
function unsupportedAssertion(scenario, target, hasPointerTransport, canDriveLifecycle) {
|
|
15957
|
+
if (scenario.steps.some((step) => step.lifecycle !== void 0) && (target !== "android" || !canDriveLifecycle)) {
|
|
15958
|
+
return unsupportedDiagnostic(
|
|
15959
|
+
"lifecycle steps",
|
|
15960
|
+
"Run lifecycle steps on --target android with the adb-backed driver. The browser, desktop and iOS lanes cannot background, foreground or rotate the app, and the phases this step reports have to be read off the device \u2014 a game-authored GameState would only restate what the scenario already said.",
|
|
15961
|
+
target
|
|
15962
|
+
);
|
|
15963
|
+
}
|
|
14644
15964
|
if (scenario.steps.some((step) => step.wheel !== void 0)) {
|
|
14645
15965
|
return unsupportedDiagnostic(
|
|
14646
15966
|
"wheel input steps",
|
|
@@ -14655,14 +15975,6 @@ function unsupportedAssertion(scenario, target, hasPointerTransport) {
|
|
|
14655
15975
|
target
|
|
14656
15976
|
);
|
|
14657
15977
|
}
|
|
14658
|
-
const hasMultiPointerInput = scenario.steps.some((step) => step.pointers !== void 0);
|
|
14659
|
-
if (hasMultiPointerInput && target === "desktop") {
|
|
14660
|
-
return unsupportedDiagnostic(
|
|
14661
|
-
"complete held-pointer input",
|
|
14662
|
-
"Run this scenario on --target browser or --target android; the desktop mailbox host exposes one pointer.",
|
|
14663
|
-
target
|
|
14664
|
-
);
|
|
14665
|
-
}
|
|
14666
15978
|
if (scenario.assert?.deviceMetrics !== void 0 && target !== "android") {
|
|
14667
15979
|
return unsupportedDiagnostic(
|
|
14668
15980
|
"device thermal and power assertions",
|
|
@@ -14723,7 +16035,7 @@ function unreadableCoverageObservation(error) {
|
|
|
14723
16035
|
windowStarted: false
|
|
14724
16036
|
};
|
|
14725
16037
|
}
|
|
14726
|
-
function
|
|
16038
|
+
function delay2(milliseconds) {
|
|
14727
16039
|
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
14728
16040
|
}
|
|
14729
16041
|
init_deviceMetrics();
|
|
@@ -14907,26 +16219,42 @@ function deviceFailure(serial, error) {
|
|
|
14907
16219
|
|
|
14908
16220
|
// src/runner/desktop.ts
|
|
14909
16221
|
init_capture();
|
|
16222
|
+
init_shared();
|
|
14910
16223
|
var SCREENSHOT_TIMEOUT_MS2 = 5e3;
|
|
14911
16224
|
var SCREENSHOT_REQUEST_FILE = "tn-playtest-screenshot-request.txt";
|
|
16225
|
+
function nativeScreenshotTimeoutMs(environment = process.env) {
|
|
16226
|
+
const configured = environment.TN_PLAYTEST_NATIVE_SCREENSHOT_TIMEOUT_MS;
|
|
16227
|
+
if (configured === void 0 || configured.trim().length === 0) return SCREENSHOT_TIMEOUT_MS2;
|
|
16228
|
+
const parsed = Number(configured);
|
|
16229
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : SCREENSHOT_TIMEOUT_MS2;
|
|
16230
|
+
}
|
|
14912
16231
|
var SCREENSHOT_REQUEST_TEMP_FILE = `${SCREENSHOT_REQUEST_FILE}.tmp`;
|
|
16232
|
+
var HOST_DIAGNOSTIC_LINE = /\[(?:Screenshot|Playtest)\]/u;
|
|
14913
16233
|
var LocalDeviceMailbox = class {
|
|
14914
|
-
async read(
|
|
16234
|
+
async read(path2) {
|
|
14915
16235
|
try {
|
|
14916
|
-
return await readFile(
|
|
16236
|
+
return await readFile(path2, "utf8");
|
|
14917
16237
|
} catch (error) {
|
|
14918
|
-
if (isMissingFile(error)) return void 0;
|
|
16238
|
+
if (isMissingFile(error) || isTransientMailboxLock(error)) return void 0;
|
|
14919
16239
|
throw error;
|
|
14920
16240
|
}
|
|
14921
16241
|
}
|
|
14922
|
-
async remove(
|
|
14923
|
-
|
|
16242
|
+
async remove(path2) {
|
|
16243
|
+
for (let retry = 0; ; retry += 1) {
|
|
16244
|
+
try {
|
|
16245
|
+
await rm(path2, { force: true });
|
|
16246
|
+
return;
|
|
16247
|
+
} catch (error) {
|
|
16248
|
+
if (retry >= 10 || !isTransientMailboxLock(error)) throw error;
|
|
16249
|
+
await delay3(20);
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
14924
16252
|
}
|
|
14925
|
-
async write(
|
|
14926
|
-
await mkdir(dirname(
|
|
14927
|
-
const temporary = `${
|
|
16253
|
+
async write(path2, contents) {
|
|
16254
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
16255
|
+
const temporary = `${path2}.tmp`;
|
|
14928
16256
|
await writeFile(temporary, contents, "utf8");
|
|
14929
|
-
await rename(temporary,
|
|
16257
|
+
await rename(temporary, path2);
|
|
14930
16258
|
}
|
|
14931
16259
|
};
|
|
14932
16260
|
var DesktopPlaytestDriver = class {
|
|
@@ -14986,33 +16314,51 @@ var DesktopPlaytestDriver = class {
|
|
|
14986
16314
|
throw error;
|
|
14987
16315
|
}
|
|
14988
16316
|
}
|
|
14989
|
-
async screenshot(
|
|
16317
|
+
async screenshot(path2) {
|
|
14990
16318
|
const root = this.mailboxRoot;
|
|
14991
16319
|
if (root === void 0) throw new Error("Desktop playtest mailbox is unavailable before prepare().");
|
|
14992
16320
|
if (!await this.isAlive()) throw new Error("Desktop playtest executable exited before screenshot capture.");
|
|
14993
|
-
await rm(
|
|
16321
|
+
await rm(path2, { force: true });
|
|
14994
16322
|
const request = join(root, SCREENSHOT_REQUEST_FILE);
|
|
14995
|
-
await new LocalDeviceMailbox().write(request,
|
|
14996
|
-
const
|
|
16323
|
+
await new LocalDeviceMailbox().write(request, path2);
|
|
16324
|
+
const pickupDeadline = Date.now() + (this.options.screenshotTimeoutMs ?? nativeScreenshotTimeoutMs());
|
|
16325
|
+
const deadline = pickupDeadline + SCREENSHOT_TIMEOUT_MS;
|
|
16326
|
+
let accepted = false;
|
|
14997
16327
|
let lastReadError;
|
|
14998
16328
|
while (Date.now() < deadline) {
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
return;
|
|
15003
|
-
} catch (error) {
|
|
15004
|
-
if (error instanceof Error && error.name === "CaptureGuardError") throw error;
|
|
15005
|
-
if (!isMissingFile(error)) lastReadError = error;
|
|
15006
|
-
}
|
|
16329
|
+
const readError = await tryReadDesktopScreenshot(path2);
|
|
16330
|
+
if (readError === void 0) return;
|
|
16331
|
+
lastReadError = readError;
|
|
15007
16332
|
if (!await this.isAlive()) {
|
|
15008
16333
|
throw new Error("Desktop playtest executable exited before screenshot capture.");
|
|
15009
16334
|
}
|
|
15010
|
-
|
|
16335
|
+
if (!accepted) {
|
|
16336
|
+
accepted = await new LocalDeviceMailbox().read(request) === void 0;
|
|
16337
|
+
if (!accepted && Date.now() >= pickupDeadline) break;
|
|
16338
|
+
}
|
|
16339
|
+
await delay3(25);
|
|
15011
16340
|
}
|
|
15012
16341
|
throw new Error(
|
|
15013
|
-
`TN_PLAYTEST_NATIVE_SCREENSHOT_UNAVAILABLE: ${
|
|
16342
|
+
`TN_PLAYTEST_NATIVE_SCREENSHOT_UNAVAILABLE: ${await this.describeScreenshotTimeout(request, lastReadError)}`
|
|
15014
16343
|
);
|
|
15015
16344
|
}
|
|
16345
|
+
/**
|
|
16346
|
+
* Why a screenshot produced no file. The host's own lines are the only place that answer is
|
|
16347
|
+
* written, and the request file's presence splits the failure in two: left behind means the host
|
|
16348
|
+
* never looked, consumed means it read the request and the capture never landed. A bounded tail,
|
|
16349
|
+
* never the whole log — a 40k-line dump is how a timeout becomes unreadable. The tail keeps the
|
|
16350
|
+
* host's tagged lines and the entries classified as errors, because the root cause (an EGL
|
|
16351
|
+
* failure, a texture that never arrived) is usually an untagged line the tag filter alone drops.
|
|
16352
|
+
*/
|
|
16353
|
+
async describeScreenshotTimeout(request, lastReadError) {
|
|
16354
|
+
this.flushOutput("stdout");
|
|
16355
|
+
this.flushOutput("stderr");
|
|
16356
|
+
const cause = lastReadError instanceof Error ? lastReadError.message : "request timed out";
|
|
16357
|
+
const requestState = await requestFileState(request);
|
|
16358
|
+
const diagnostic2 = this.consoleEntries.filter((entry) => entry.type === "error" || HOST_DIAGNOSTIC_LINE.test(entry.text));
|
|
16359
|
+
const tail = (diagnostic2.length > 0 ? diagnostic2 : this.consoleEntries).slice(-6).map((entry) => entry.text);
|
|
16360
|
+
return `${cause}; ${requestState}; native host output: ${tail.length > 0 ? tail.join(" | ") : "none captured"}`;
|
|
16361
|
+
}
|
|
15016
16362
|
async stop() {
|
|
15017
16363
|
const child = this.child;
|
|
15018
16364
|
if (child === void 0) return;
|
|
@@ -15051,13 +16397,25 @@ var DesktopPlaytestDriver = class {
|
|
|
15051
16397
|
}
|
|
15052
16398
|
}
|
|
15053
16399
|
};
|
|
16400
|
+
async function tryReadDesktopScreenshot(path2) {
|
|
16401
|
+
try {
|
|
16402
|
+
const png = await readFile(path2);
|
|
16403
|
+
assertCaptureNotBlank(png, path2);
|
|
16404
|
+
return void 0;
|
|
16405
|
+
} catch (error) {
|
|
16406
|
+
if (error instanceof Error && error.name === "CaptureGuardError") throw error;
|
|
16407
|
+
return isMissingFile(error) ? "request timed out" : error;
|
|
16408
|
+
}
|
|
16409
|
+
}
|
|
15054
16410
|
function desktopConsoleType(stream, line) {
|
|
15055
16411
|
const text = line.trimStart();
|
|
15056
16412
|
if (/^(?:\[error\]|(?:error|fatal):)/iu.test(text)) return "error";
|
|
15057
|
-
if (/^(?:\[warn(?:ing)?\]|warning:|MESA-EGL:\s*warning:|\*\* \([^)]*\): WARNING \*\*:)/iu.test(
|
|
16413
|
+
if (/^(?:\[warn(?:ing)?\]|warning:|MESA-EGL:\s*warning:|libEGL\s+warning:|\*\* \([^)]*\): WARNING \*\*:|\([^)]*\): dbind-WARNING \*\*:)/iu.test(
|
|
16414
|
+
text
|
|
16415
|
+
)) {
|
|
15058
16416
|
return "warning";
|
|
15059
16417
|
}
|
|
15060
|
-
if (/^Gtk-Message:/u.test(text)) return "log";
|
|
16418
|
+
if (/^ALSA lib\b|^\[Audio\] Failed to open audio device: ALSA:|^Gtk-Message:/u.test(text)) return "log";
|
|
15061
16419
|
return stream === "stderr" ? "error" : "log";
|
|
15062
16420
|
}
|
|
15063
16421
|
function terminateProcess(child, signal) {
|
|
@@ -15103,17 +16461,31 @@ function waitForExit(child, timeoutMs) {
|
|
|
15103
16461
|
function isProcessExited(child) {
|
|
15104
16462
|
return child.exitCode !== null || child.signalCode !== null;
|
|
15105
16463
|
}
|
|
15106
|
-
function
|
|
16464
|
+
function delay3(milliseconds) {
|
|
15107
16465
|
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
15108
16466
|
}
|
|
16467
|
+
function isTransientMailboxLock(error) {
|
|
16468
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
16469
|
+
return code === "EPERM" || code === "EBUSY";
|
|
16470
|
+
}
|
|
15109
16471
|
function isMissingFile(error) {
|
|
15110
16472
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
15111
16473
|
}
|
|
16474
|
+
async function requestFileState(path2) {
|
|
16475
|
+
try {
|
|
16476
|
+
await readFile(path2);
|
|
16477
|
+
return "request file still present";
|
|
16478
|
+
} catch (error) {
|
|
16479
|
+
if (isMissingFile(error)) return "request file consumed";
|
|
16480
|
+
return `request file unreadable: ${error instanceof Error ? error.message : String(error)}`;
|
|
16481
|
+
}
|
|
16482
|
+
}
|
|
15112
16483
|
|
|
15113
16484
|
// src/runner/desktopRunner.ts
|
|
15114
16485
|
init_shared();
|
|
15115
16486
|
function desktopHostArgs(config) {
|
|
15116
|
-
|
|
16487
|
+
const args = config.desktop?.hostArgs ?? [];
|
|
16488
|
+
return config.cpuProfilePath === void 0 ? args : [...args, `--cpu-prof=${config.cpuProfilePath}`];
|
|
15117
16489
|
}
|
|
15118
16490
|
async function runDesktopPlaytest(config, dependencies = {}) {
|
|
15119
16491
|
const executable = config.desktop?.executable;
|
|
@@ -15168,7 +16540,8 @@ async function runDesktopPlaytest(config, dependencies = {}) {
|
|
|
15168
16540
|
cwd: config.projectPath,
|
|
15169
16541
|
...providedDisplay === void 0 ? {} : { env: providedDisplay.env },
|
|
15170
16542
|
executable,
|
|
15171
|
-
mailboxRoot: root
|
|
16543
|
+
mailboxRoot: root,
|
|
16544
|
+
screenshotTimeoutMs: config.timeoutMs
|
|
15172
16545
|
});
|
|
15173
16546
|
transport = dependencies.transport ?? new DeviceMailboxTransport(
|
|
15174
16547
|
new LocalDeviceMailbox(),
|
|
@@ -15188,6 +16561,17 @@ async function runDesktopPlaytest(config, dependencies = {}) {
|
|
|
15188
16561
|
} catch (error) {
|
|
15189
16562
|
executionFailed = true;
|
|
15190
16563
|
executionError = error;
|
|
16564
|
+
if (driver !== void 0) {
|
|
16565
|
+
try {
|
|
16566
|
+
await mkdir(config.artifactDirectory, { recursive: true });
|
|
16567
|
+
await writeObservationArtifacts(config.artifactDirectory, void 0, {
|
|
16568
|
+
console: await driver.captureConsole(),
|
|
16569
|
+
network: [],
|
|
16570
|
+
runtimeTrace: void 0
|
|
16571
|
+
});
|
|
16572
|
+
} catch {
|
|
16573
|
+
}
|
|
16574
|
+
}
|
|
15191
16575
|
} finally {
|
|
15192
16576
|
process.off("SIGINT", handleSignal);
|
|
15193
16577
|
process.off("SIGTERM", handleSignal);
|
|
@@ -15240,6 +16624,22 @@ function cleanupFailure2(errors) {
|
|
|
15240
16624
|
return new AggregateError(errors, "Desktop playtest cleanup failed.");
|
|
15241
16625
|
}
|
|
15242
16626
|
var execFileAsync4 = promisify(execFile);
|
|
16627
|
+
var kIosCompactAppleRecord = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (Df|Db|A|I|E|F) +\S+\[\d+:[0-9a-f]+\] \[([^\]:]+):[^\]]+\]/u;
|
|
16628
|
+
var kIosExplicitErrorMarker = /\[error\]|\bFATAL\b|GPUValidationError|uncaught/iu;
|
|
16629
|
+
var kIosAppleFaultFailure = /\b(?:error|fail(?:ed|ure)?|abort(?:ed)?|crash(?:ed)?)\b/iu;
|
|
16630
|
+
var kIosTextError = /\[error\]|\b(?:Error|Fault|FATAL|FAILED|GPUValidationError|uncaught)\b/u;
|
|
16631
|
+
function classifyIosConsoleLine(text) {
|
|
16632
|
+
const compact = kIosCompactAppleRecord.exec(text);
|
|
16633
|
+
if (compact !== null) {
|
|
16634
|
+
if (kIosExplicitErrorMarker.test(text)) return "error";
|
|
16635
|
+
if (compact[2].startsWith("com.apple.")) {
|
|
16636
|
+
return compact[1] === "F" && kIosAppleFaultFailure.test(text) ? "error" : "log";
|
|
16637
|
+
}
|
|
16638
|
+
if (compact[1] === "E" || compact[1] === "F") return "error";
|
|
16639
|
+
return kIosTextError.test(text) ? "error" : "log";
|
|
16640
|
+
}
|
|
16641
|
+
return kIosTextError.test(text) ? "error" : "log";
|
|
16642
|
+
}
|
|
15243
16643
|
var XcrunIosDriver = class {
|
|
15244
16644
|
constructor(options, run2) {
|
|
15245
16645
|
this.options = options;
|
|
@@ -15276,6 +16676,8 @@ var XcrunIosDriver = class {
|
|
|
15276
16676
|
await this.prepareDevice(endpoint, mailboxRoot);
|
|
15277
16677
|
}
|
|
15278
16678
|
async captureConsole() {
|
|
16679
|
+
if (this.pid === void 0) throw new Error("iOS console capture requires a launched process.");
|
|
16680
|
+
const predicate = `processIdentifier == ${this.pid}`;
|
|
15279
16681
|
const output = this.options.transport === "simulator" ? await this.run([
|
|
15280
16682
|
"simctl",
|
|
15281
16683
|
"spawn",
|
|
@@ -15287,7 +16689,7 @@ var XcrunIosDriver = class {
|
|
|
15287
16689
|
"--last",
|
|
15288
16690
|
"5m",
|
|
15289
16691
|
"--predicate",
|
|
15290
|
-
|
|
16692
|
+
predicate
|
|
15291
16693
|
]) : await this.run([
|
|
15292
16694
|
"devicectl",
|
|
15293
16695
|
"device",
|
|
@@ -15298,12 +16700,9 @@ var XcrunIosDriver = class {
|
|
|
15298
16700
|
"--last",
|
|
15299
16701
|
"5m",
|
|
15300
16702
|
"--predicate",
|
|
15301
|
-
|
|
16703
|
+
predicate
|
|
15302
16704
|
]);
|
|
15303
|
-
return output.split(/\r?\n/u).filter((line) =>
|
|
15304
|
-
text,
|
|
15305
|
-
type: /\b(?:Error|Fault|FATAL|FAILED|GPUValidationError)\b/u.test(text) ? "error" : "log"
|
|
15306
|
-
}));
|
|
16705
|
+
return output.split(/\r?\n/u).filter((line) => line.trim().length > 0).map((text) => ({ text, type: classifyIosConsoleLine(text) }));
|
|
15307
16706
|
}
|
|
15308
16707
|
async isAlive() {
|
|
15309
16708
|
if (this.pid === void 0) return false;
|
|
@@ -15319,25 +16718,25 @@ var XcrunIosDriver = class {
|
|
|
15319
16718
|
return false;
|
|
15320
16719
|
}
|
|
15321
16720
|
}
|
|
15322
|
-
async screenshot(
|
|
16721
|
+
async screenshot(path2) {
|
|
15323
16722
|
if (this.options.transport === "simulator") {
|
|
15324
|
-
await this.run(["simctl", "io", this.device(), "screenshot",
|
|
16723
|
+
await this.run(["simctl", "io", this.device(), "screenshot", path2]);
|
|
15325
16724
|
return;
|
|
15326
16725
|
}
|
|
15327
|
-
await this.run(["devicectl", "device", "capture", "screen", "--device", this.device(), "--destination",
|
|
16726
|
+
await this.run(["devicectl", "device", "capture", "screen", "--device", this.device(), "--destination", path2]);
|
|
15328
16727
|
}
|
|
15329
|
-
async readFile(
|
|
15330
|
-
|
|
16728
|
+
async readFile(path2) {
|
|
16729
|
+
path2 = this.mailboxPath(path2);
|
|
15331
16730
|
if (this.options.transport === "simulator") {
|
|
15332
16731
|
try {
|
|
15333
|
-
return await readFile(
|
|
16732
|
+
return await readFile(path2, "utf8");
|
|
15334
16733
|
} catch (error) {
|
|
15335
16734
|
if (error.code === "ENOENT") return void 0;
|
|
15336
16735
|
throw error;
|
|
15337
16736
|
}
|
|
15338
16737
|
}
|
|
15339
16738
|
const directory = await mkdtemp(join(tmpdir(), "threenative-devicectl-read-"));
|
|
15340
|
-
const destination = join(directory, basename(
|
|
16739
|
+
const destination = join(directory, basename(path2));
|
|
15341
16740
|
try {
|
|
15342
16741
|
await this.run([
|
|
15343
16742
|
"devicectl",
|
|
@@ -15351,7 +16750,7 @@ var XcrunIosDriver = class {
|
|
|
15351
16750
|
"--domain-identifier",
|
|
15352
16751
|
this.options.bundleId,
|
|
15353
16752
|
"--source",
|
|
15354
|
-
|
|
16753
|
+
path2,
|
|
15355
16754
|
"--destination",
|
|
15356
16755
|
destination
|
|
15357
16756
|
]);
|
|
@@ -15364,16 +16763,16 @@ var XcrunIosDriver = class {
|
|
|
15364
16763
|
await rm(directory, { force: true, recursive: true });
|
|
15365
16764
|
}
|
|
15366
16765
|
}
|
|
15367
|
-
async removeFile(
|
|
16766
|
+
async removeFile(path2) {
|
|
15368
16767
|
if (this.mailboxRoot === void 0) return;
|
|
15369
|
-
|
|
16768
|
+
path2 = this.mailboxPath(path2);
|
|
15370
16769
|
if (this.options.transport === "simulator") {
|
|
15371
|
-
await unlink(
|
|
16770
|
+
await unlink(path2).catch((error) => {
|
|
15372
16771
|
if (error.code !== "ENOENT") throw error;
|
|
15373
16772
|
});
|
|
15374
16773
|
return;
|
|
15375
16774
|
}
|
|
15376
|
-
this.suppressedResponse = await this.readFile(
|
|
16775
|
+
this.suppressedResponse = await this.readFile(path2);
|
|
15377
16776
|
}
|
|
15378
16777
|
async stop() {
|
|
15379
16778
|
if (this.options.transport === "simulator") {
|
|
@@ -15390,17 +16789,17 @@ var XcrunIosDriver = class {
|
|
|
15390
16789
|
]).catch(() => void 0);
|
|
15391
16790
|
}
|
|
15392
16791
|
}
|
|
15393
|
-
async writeFile(
|
|
15394
|
-
|
|
16792
|
+
async writeFile(path2, contents) {
|
|
16793
|
+
path2 = this.mailboxPath(path2);
|
|
15395
16794
|
if (this.options.transport === "simulator") {
|
|
15396
|
-
await mkdir(dirname(
|
|
15397
|
-
const temporary = `${
|
|
16795
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
16796
|
+
const temporary = `${path2}.incoming-${process.pid}-${Date.now()}`;
|
|
15398
16797
|
await writeFile(temporary, contents, "utf8");
|
|
15399
|
-
await rename(temporary,
|
|
16798
|
+
await rename(temporary, path2);
|
|
15400
16799
|
return;
|
|
15401
16800
|
}
|
|
15402
16801
|
const directory = await mkdtemp(join(tmpdir(), "threenative-devicectl-write-"));
|
|
15403
|
-
const source = join(directory, basename(
|
|
16802
|
+
const source = join(directory, basename(path2));
|
|
15404
16803
|
try {
|
|
15405
16804
|
await writeFile(source, contents, "utf8");
|
|
15406
16805
|
await this.run([
|
|
@@ -15417,7 +16816,7 @@ var XcrunIosDriver = class {
|
|
|
15417
16816
|
"--source",
|
|
15418
16817
|
source,
|
|
15419
16818
|
"--destination",
|
|
15420
|
-
|
|
16819
|
+
path2
|
|
15421
16820
|
]);
|
|
15422
16821
|
} finally {
|
|
15423
16822
|
await rm(directory, { force: true, recursive: true });
|
|
@@ -15488,11 +16887,8 @@ var XcrunIosDriver = class {
|
|
|
15488
16887
|
device() {
|
|
15489
16888
|
return this.options.device ?? "booted";
|
|
15490
16889
|
}
|
|
15491
|
-
|
|
15492
|
-
return
|
|
15493
|
-
}
|
|
15494
|
-
mailboxPath(path) {
|
|
15495
|
-
return this.mailboxRoot === void 0 ? path : join(this.mailboxRoot, basename(path));
|
|
16890
|
+
mailboxPath(path2) {
|
|
16891
|
+
return this.mailboxRoot === void 0 ? path2 : join(this.mailboxRoot, basename(path2));
|
|
15496
16892
|
}
|
|
15497
16893
|
};
|
|
15498
16894
|
function parseLaunchedPid(output) {
|
|
@@ -15529,33 +16925,33 @@ async function runIosPlaytest(config, dependencies = {}) {
|
|
|
15529
16925
|
init_scenario();
|
|
15530
16926
|
var SCENARIO_VIEWPORT = { height: 720, width: 1280 };
|
|
15531
16927
|
var FINAL_STEP_LABEL = "replay-final";
|
|
15532
|
-
function recordNumber(value,
|
|
16928
|
+
function recordNumber(value, path2, integer = false) {
|
|
15533
16929
|
if (typeof value !== "number" || !Number.isFinite(value) || integer && !Number.isInteger(value))
|
|
15534
|
-
throw invalidScenario(
|
|
16930
|
+
throw invalidScenario(path2, `${path2} must be a finite${integer ? " integer" : " number"}.`);
|
|
15535
16931
|
return value;
|
|
15536
16932
|
}
|
|
15537
|
-
function recordString(value,
|
|
15538
|
-
if (typeof value !== "string" || value.length === 0) throw invalidScenario(
|
|
16933
|
+
function recordString(value, path2) {
|
|
16934
|
+
if (typeof value !== "string" || value.length === 0) throw invalidScenario(path2, `${path2} must be a non-empty string.`);
|
|
15539
16935
|
return value;
|
|
15540
16936
|
}
|
|
15541
|
-
function recordObject(value,
|
|
16937
|
+
function recordObject(value, path2) {
|
|
15542
16938
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
15543
|
-
throw invalidScenario(
|
|
16939
|
+
throw invalidScenario(path2, `${path2} must be an object.`);
|
|
15544
16940
|
return value;
|
|
15545
16941
|
}
|
|
15546
|
-
function recordTuple(value,
|
|
16942
|
+
function recordTuple(value, path2) {
|
|
15547
16943
|
if (!Array.isArray(value) || value.length !== 3 || !value.every((item) => typeof item === "number" && Number.isFinite(item)))
|
|
15548
|
-
throw invalidScenario(
|
|
16944
|
+
throw invalidScenario(path2, `${path2} must be a finite three-number tuple.`);
|
|
15549
16945
|
return value;
|
|
15550
16946
|
}
|
|
15551
|
-
function recordPointer(value,
|
|
16947
|
+
function recordPointer(value, path2) {
|
|
15552
16948
|
if (!Array.isArray(value) || value.length !== 5 || !value.every((item) => typeof item === "number" && Number.isFinite(item)))
|
|
15553
|
-
throw invalidScenario(
|
|
16949
|
+
throw invalidScenario(path2, `${path2} must be [x, y, buttons, viewport width, viewport height].`);
|
|
15554
16950
|
const pointer = value;
|
|
15555
16951
|
if (!Number.isInteger(pointer[2]) || pointer[2] < 0 || (pointer[2] & -8) !== 0)
|
|
15556
|
-
throw invalidScenario(
|
|
16952
|
+
throw invalidScenario(path2, `${path2} buttons must use left, right, or middle buttons only.`);
|
|
15557
16953
|
if (!Number.isInteger(pointer[3]) || pointer[3] < 1 || !Number.isInteger(pointer[4]) || pointer[4] < 1)
|
|
15558
|
-
throw invalidScenario(
|
|
16954
|
+
throw invalidScenario(path2, `${path2} viewport dimensions must be positive integers.`);
|
|
15559
16955
|
return pointer;
|
|
15560
16956
|
}
|
|
15561
16957
|
function validateRecording(value, scenarioPath) {
|
|
@@ -15794,30 +17190,30 @@ function parseAudioArgs(argv) {
|
|
|
15794
17190
|
}
|
|
15795
17191
|
var CLIP_KEYS = /* @__PURE__ */ new Set(["bands", "loop", "path", "peakMax", "seamMaxRatio", "silenceRms"]);
|
|
15796
17192
|
var MANIFEST_KEYS = /* @__PURE__ */ new Set(["clips", "version"]);
|
|
15797
|
-
function parseAudioManifest(text,
|
|
17193
|
+
function parseAudioManifest(text, path2) {
|
|
15798
17194
|
let raw;
|
|
15799
17195
|
try {
|
|
15800
17196
|
raw = JSON.parse(text);
|
|
15801
17197
|
} catch (error) {
|
|
15802
17198
|
const message = error instanceof Error ? error.message : String(error);
|
|
15803
|
-
throw new PlaytestCliUsageError(`audio: ${
|
|
17199
|
+
throw new PlaytestCliUsageError(`audio: ${path2} is not valid JSON: ${message}`);
|
|
15804
17200
|
}
|
|
15805
|
-
if (!
|
|
15806
|
-
rejectUnknown(raw, MANIFEST_KEYS,
|
|
17201
|
+
if (!isRecord6(raw)) throw new PlaytestCliUsageError(`audio: ${path2} must be a JSON object.`);
|
|
17202
|
+
rejectUnknown(raw, MANIFEST_KEYS, path2, "manifest");
|
|
15807
17203
|
if (raw.version !== 1)
|
|
15808
17204
|
throw new PlaytestCliUsageError(
|
|
15809
|
-
`audio: ${
|
|
17205
|
+
`audio: ${path2} declares version ${JSON.stringify(raw.version)}; this inspector implements version 1.`
|
|
15810
17206
|
);
|
|
15811
17207
|
if (!Array.isArray(raw.clips))
|
|
15812
|
-
throw new PlaytestCliUsageError(`audio: ${
|
|
17208
|
+
throw new PlaytestCliUsageError(`audio: ${path2} must carry a "clips" array.`);
|
|
15813
17209
|
if (raw.clips.length === 0)
|
|
15814
17210
|
throw new PlaytestCliUsageError(
|
|
15815
|
-
`audio: ${
|
|
17211
|
+
`audio: ${path2} declares no clips; a manifest must assert at least one clip.`
|
|
15816
17212
|
);
|
|
15817
17213
|
const seen = /* @__PURE__ */ new Set();
|
|
15818
17214
|
const clips = raw.clips.map((entry, index) => {
|
|
15819
|
-
const where = `${
|
|
15820
|
-
if (!
|
|
17215
|
+
const where = `${path2} clips[${String(index)}]`;
|
|
17216
|
+
if (!isRecord6(entry)) throw new PlaytestCliUsageError(`audio: ${where} must be an object.`);
|
|
15821
17217
|
rejectUnknown(entry, CLIP_KEYS, where, "clip");
|
|
15822
17218
|
const clipPath = entry.path;
|
|
15823
17219
|
if (typeof clipPath !== "string" || clipPath.length === 0)
|
|
@@ -15845,7 +17241,7 @@ function parseAudioManifest(text, path) {
|
|
|
15845
17241
|
return { clips, version: 1 };
|
|
15846
17242
|
}
|
|
15847
17243
|
function parseBands(raw, where) {
|
|
15848
|
-
if (!
|
|
17244
|
+
if (!isRecord6(raw)) throw new PlaytestCliUsageError(`audio: ${where} "bands" must be an object.`);
|
|
15849
17245
|
const bands = {};
|
|
15850
17246
|
for (const [name, bound] of Object.entries(raw)) {
|
|
15851
17247
|
if (!BAND_NAMES.includes(name)) {
|
|
@@ -15853,7 +17249,7 @@ function parseBands(raw, where) {
|
|
|
15853
17249
|
`audio: ${where} names band "${name}"; the measured bands are ${BAND_NAMES.join(", ")}.`
|
|
15854
17250
|
);
|
|
15855
17251
|
}
|
|
15856
|
-
if (!
|
|
17252
|
+
if (!isRecord6(bound))
|
|
15857
17253
|
throw new PlaytestCliUsageError(`audio: ${where} band "${name}" must be an object.`);
|
|
15858
17254
|
rejectUnknown(bound, /* @__PURE__ */ new Set(["max", "min"]), `${where} band "${name}"`, "bound");
|
|
15859
17255
|
const min = bound.min === void 0 ? void 0 : percent(bound.min, `${where} band "${name}" min`);
|
|
@@ -15896,7 +17292,7 @@ function positive(value, where) {
|
|
|
15896
17292
|
throw new PlaytestCliUsageError(`audio: ${where} must be a finite positive number.`);
|
|
15897
17293
|
return value;
|
|
15898
17294
|
}
|
|
15899
|
-
function
|
|
17295
|
+
function isRecord6(value) {
|
|
15900
17296
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15901
17297
|
}
|
|
15902
17298
|
function analyseSamples(channels, sampleRate) {
|
|
@@ -16001,9 +17397,9 @@ function measureSeam(channels, sampleRate) {
|
|
|
16001
17397
|
wrap
|
|
16002
17398
|
};
|
|
16003
17399
|
}
|
|
16004
|
-
function checkClip(
|
|
17400
|
+
function checkClip(path2, analysis, expectation) {
|
|
16005
17401
|
const checks = [];
|
|
16006
|
-
const label = (name) => `${
|
|
17402
|
+
const label = (name) => `${path2} ${name}`;
|
|
16007
17403
|
const silenceRms = expectation.silenceRms ?? DEFAULT_SILENCE_RMS;
|
|
16008
17404
|
if (analysis.rms < silenceRms) {
|
|
16009
17405
|
checks.push({
|
|
@@ -16112,7 +17508,7 @@ function formatAudioReport(report) {
|
|
|
16112
17508
|
if (pictures.length > 0) {
|
|
16113
17509
|
lines.push("");
|
|
16114
17510
|
lines.push("spectrograms:");
|
|
16115
|
-
for (const { path, spectrogram } of pictures) lines.push(` ${
|
|
17511
|
+
for (const { path: path2, spectrogram } of pictures) lines.push(` ${path2} -> ${String(spectrogram)}`);
|
|
16116
17512
|
}
|
|
16117
17513
|
const failed = report.checks.filter(({ status }) => status === "fail").length;
|
|
16118
17514
|
lines.push("");
|
|
@@ -16377,16 +17773,16 @@ async function inspectAudio(args) {
|
|
|
16377
17773
|
if (args.dir !== void 0) checks.push(await coverageCheck(args.root, args.dir, manifest.clips));
|
|
16378
17774
|
return { checks, clips, pass: !checks.some(({ status }) => status === "fail") };
|
|
16379
17775
|
}
|
|
16380
|
-
async function readManifest(
|
|
17776
|
+
async function readManifest(path2) {
|
|
16381
17777
|
try {
|
|
16382
|
-
return await readFile(
|
|
17778
|
+
return await readFile(path2, "utf8");
|
|
16383
17779
|
} catch {
|
|
16384
|
-
throw new PlaytestCliUsageError(`audio: cannot read the expectation manifest at ${
|
|
17780
|
+
throw new PlaytestCliUsageError(`audio: cannot read the expectation manifest at ${path2}.`);
|
|
16385
17781
|
}
|
|
16386
17782
|
}
|
|
16387
17783
|
async function coverageCheck(root, dir, clips) {
|
|
16388
17784
|
const base = resolve(root, dir);
|
|
16389
|
-
const declared = new Set(clips.map(({ path }) => resolve(root,
|
|
17785
|
+
const declared = new Set(clips.map(({ path: path2 }) => resolve(root, path2)));
|
|
16390
17786
|
let found;
|
|
16391
17787
|
try {
|
|
16392
17788
|
found = (await readdir(base, { recursive: true, withFileTypes: true })).filter((entry) => entry.isFile() && AUDIO_EXTENSIONS.has(extname(entry.name).toLowerCase())).map((entry) => resolve(entry.parentPath, entry.name));
|
|
@@ -16398,7 +17794,7 @@ async function coverageCheck(root, dir, clips) {
|
|
|
16398
17794
|
status: "fail"
|
|
16399
17795
|
};
|
|
16400
17796
|
}
|
|
16401
|
-
const undeclared = found.filter((
|
|
17797
|
+
const undeclared = found.filter((path2) => !declared.has(path2)).map((path2) => relative(root, path2));
|
|
16402
17798
|
if (undeclared.length > 0) {
|
|
16403
17799
|
return {
|
|
16404
17800
|
detail: `${String(undeclared.length)} audio file(s) in ${dir} are not declared: ${undeclared.sort().join(", ")}`,
|
|
@@ -16422,8 +17818,8 @@ async function assertDecoder() {
|
|
|
16422
17818
|
);
|
|
16423
17819
|
}
|
|
16424
17820
|
}
|
|
16425
|
-
async function decodeAudio(
|
|
16426
|
-
const wav = await run("ffmpeg", ["-v", "error", "-i",
|
|
17821
|
+
async function decodeAudio(path2) {
|
|
17822
|
+
const wav = await run("ffmpeg", ["-v", "error", "-i", path2, "-c:a", "pcm_f32le", "-f", "wav", "-"]);
|
|
16427
17823
|
return parseWav(wav);
|
|
16428
17824
|
}
|
|
16429
17825
|
function parseWav(wav) {
|
|
@@ -17151,6 +18547,20 @@ function classifyRunnerError(error, options = {}) {
|
|
|
17151
18547
|
};
|
|
17152
18548
|
}
|
|
17153
18549
|
const message = error instanceof Error ? error.message : String(error);
|
|
18550
|
+
if (message.startsWith("TN_PLAYTEST_BUILD_REPORT_STALE")) {
|
|
18551
|
+
return diagnostic(
|
|
18552
|
+
"TN_PLAYTEST_BUILD_REPORT_STALE",
|
|
18553
|
+
message,
|
|
18554
|
+
"Rebuild the artifact, or point --build-report at the build this run is exercising; a budget measured on other bytes bounds nothing."
|
|
18555
|
+
);
|
|
18556
|
+
}
|
|
18557
|
+
if (message.startsWith("TN_PLAYTEST_BUILD_REPORT_INVALID")) {
|
|
18558
|
+
return diagnostic(
|
|
18559
|
+
"TN_PLAYTEST_BUILD_REPORT_INVALID",
|
|
18560
|
+
message,
|
|
18561
|
+
"Regenerate the report with `threenative build`; a hand-edited or foreign report cannot be adopted."
|
|
18562
|
+
);
|
|
18563
|
+
}
|
|
17154
18564
|
if (message.startsWith("TN_PLAYTEST_DEVICE_FAILED")) {
|
|
17155
18565
|
return diagnostic(
|
|
17156
18566
|
"TN_PLAYTEST_DEVICE_FAILED",
|
|
@@ -17158,6 +18568,20 @@ function classifyRunnerError(error, options = {}) {
|
|
|
17158
18568
|
"Confirm adb can reach the requested serial and Android Chrome exposes its CDP socket, then rerun."
|
|
17159
18569
|
);
|
|
17160
18570
|
}
|
|
18571
|
+
if (message.startsWith("TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED")) {
|
|
18572
|
+
return diagnostic(
|
|
18573
|
+
"TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED",
|
|
18574
|
+
message,
|
|
18575
|
+
"Point --cpu-prof at a writable path; the run is not green without the profile it was asked for."
|
|
18576
|
+
);
|
|
18577
|
+
}
|
|
18578
|
+
if (message.startsWith("TN_PLAYTEST_CPU_PROFILE_UNSUPPORTED")) {
|
|
18579
|
+
return diagnostic(
|
|
18580
|
+
"TN_PLAYTEST_CPU_PROFILE_UNSUPPORTED",
|
|
18581
|
+
message,
|
|
18582
|
+
"Run --cpu-prof on the browser or desktop target, where the profile can be produced."
|
|
18583
|
+
);
|
|
18584
|
+
}
|
|
17161
18585
|
if (message.startsWith("browserType.launch")) {
|
|
17162
18586
|
return diagnostic(
|
|
17163
18587
|
"TN_PLAYTEST_BROWSER_UNAVAILABLE",
|
|
@@ -17291,7 +18715,8 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
17291
18715
|
if (argv[0] === "record-to-scenario") {
|
|
17292
18716
|
return await recordToScenarioCommand(argv.slice(1));
|
|
17293
18717
|
}
|
|
17294
|
-
config = parseStandalonePlaytestArgs(argv);
|
|
18718
|
+
config = await resolveBuildReport(parseStandalonePlaytestArgs(argv));
|
|
18719
|
+
assertCpuProfileTargetSupported(config.target ?? "browser", config.cpuProfilePath);
|
|
17295
18720
|
const scenarioPaths = config.scenarioPaths ?? [config.scenarioPath];
|
|
17296
18721
|
const reports = config.target === "browser" ? config.device === void 0 ? await runStandalonePlaytests(config) : await runAndroidBrowserPlaytests(config) : await runDevicePlaytests(config, scenarioPaths);
|
|
17297
18722
|
const output = reports.length === 1 ? reports[0] : { pass: reports.every(({ pass }) => pass), reports };
|
|
@@ -17375,8 +18800,8 @@ function diagnostic(code, message, instruction) {
|
|
|
17375
18800
|
function scenarioUnreadable(message, options) {
|
|
17376
18801
|
const cwd = options.cwd ?? process.cwd();
|
|
17377
18802
|
const candidate = options.scenarioPath ?? /Playtest scenario ['"]([^'"]+)['"]/u.exec(message)?.[1] ?? /(?:open|read) ['"]([^'"]+)['"]/u.exec(message)?.[1];
|
|
17378
|
-
const
|
|
17379
|
-
const printedPath =
|
|
18803
|
+
const path2 = candidate === void 0 ? void 0 : resolve(cwd, candidate);
|
|
18804
|
+
const printedPath = path2 ?? "the requested scenario path";
|
|
17380
18805
|
return diagnostic(
|
|
17381
18806
|
"TN_PLAYTEST_SCENARIO_UNREADABLE",
|
|
17382
18807
|
`${message} Resolved absolute path: ${printedPath}.`,
|