@threenative/playtest 0.3.3 → 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-Bpy15z5f.d.ts → diagnostics-BXhYI2sc.d.ts} +389 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +206 -41
- package/dist/protocol.d.ts +7 -0
- package/dist/runner/cli.d.ts +2 -2
- package/dist/runner/cli.js +1192 -298
- package/dist/runner/index.d.ts +71 -240
- package/dist/runner/index.js +1651 -971
- package/dist/{shared-eFOF5bZO.d.ts → shared-CHIDDJpp.d.ts} +38 -5
- package/dist/three/index.d.ts +10 -1
- package/dist/three/index.js +11 -6
- 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);
|
|
@@ -891,7 +909,8 @@ var init_assertion_schema = __esm({
|
|
|
891
909
|
{ description: "Exact render-chain quality tier required after the chain applies.", name: "tier", type: "string" },
|
|
892
910
|
{ description: "Stage ids to include, exclude, or find as an ordered subsequence in the applied chain.", name: "stages", type: "object" },
|
|
893
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" },
|
|
894
|
-
{ 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" }
|
|
895
914
|
],
|
|
896
915
|
cardinality: "object",
|
|
897
916
|
kind: "renderChain",
|
|
@@ -1809,7 +1828,7 @@ var init_families_observation = __esm({
|
|
|
1809
1828
|
function jsonByteLength(value) {
|
|
1810
1829
|
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1811
1830
|
}
|
|
1812
|
-
function assertJsonSafe(value,
|
|
1831
|
+
function assertJsonSafe(value, path2 = "$") {
|
|
1813
1832
|
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1814
1833
|
return;
|
|
1815
1834
|
}
|
|
@@ -1817,19 +1836,19 @@ function assertJsonSafe(value, path = "$") {
|
|
|
1817
1836
|
if (Number.isFinite(value)) {
|
|
1818
1837
|
return;
|
|
1819
1838
|
}
|
|
1820
|
-
throw new TypeError(`${
|
|
1839
|
+
throw new TypeError(`${path2} must contain only finite JSON numbers.`);
|
|
1821
1840
|
}
|
|
1822
1841
|
if (Array.isArray(value)) {
|
|
1823
|
-
value.forEach((item, index) => assertJsonSafe(item, `${
|
|
1842
|
+
value.forEach((item, index) => assertJsonSafe(item, `${path2}[${index}]`));
|
|
1824
1843
|
return;
|
|
1825
1844
|
}
|
|
1826
1845
|
if (typeof value === "object") {
|
|
1827
1846
|
for (const [key, item] of Object.entries(value)) {
|
|
1828
|
-
assertJsonSafe(item, `${
|
|
1847
|
+
assertJsonSafe(item, `${path2}.${key}`);
|
|
1829
1848
|
}
|
|
1830
1849
|
return;
|
|
1831
1850
|
}
|
|
1832
|
-
throw new TypeError(`${
|
|
1851
|
+
throw new TypeError(`${path2} must be JSON-safe.`);
|
|
1833
1852
|
}
|
|
1834
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;
|
|
1835
1854
|
var init_protocol = __esm({
|
|
@@ -1880,7 +1899,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1880
1899
|
const maxObservedTriangles = triangles.length === 0 ? void 0 : Math.max(...triangles);
|
|
1881
1900
|
const results = [];
|
|
1882
1901
|
const diagnostics = [];
|
|
1883
|
-
const
|
|
1902
|
+
const path2 = `${sourcePath ?? "playtest"}/observations.json/performanceSeries`;
|
|
1884
1903
|
const samplesPass = validSamples;
|
|
1885
1904
|
results.push({
|
|
1886
1905
|
details: { sampleCount: samples.length, valid: validSamples },
|
|
@@ -1891,7 +1910,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1891
1910
|
diagnostics.push({
|
|
1892
1911
|
code: "TN_PLAYTEST_PERFORMANCE_SAMPLES_MISSING",
|
|
1893
1912
|
message: samples.length === 0 ? "Performance assertion received no render samples." : "Performance assertion received an invalid render sample series.",
|
|
1894
|
-
observedRuntimePath:
|
|
1913
|
+
observedRuntimePath: path2,
|
|
1895
1914
|
severity: "error",
|
|
1896
1915
|
sourcePath,
|
|
1897
1916
|
suggestion: "Run the scenario against the real render loop and keep the performance bridge provider installed."
|
|
@@ -1902,7 +1921,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1902
1921
|
if (!pass) diagnostics.push({
|
|
1903
1922
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1904
1923
|
message: `${id} expected at most ${expected} ${unit}, observed ${actual ?? "unavailable"}.`,
|
|
1905
|
-
observedRuntimePath:
|
|
1924
|
+
observedRuntimePath: path2,
|
|
1906
1925
|
severity: "error",
|
|
1907
1926
|
sourcePath,
|
|
1908
1927
|
suggestion: "Inspect the recorded frame-cost series and reduce the authored scene cost that owns the regression."
|
|
@@ -1937,7 +1956,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1937
1956
|
if (!pass) diagnostics.push({
|
|
1938
1957
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1939
1958
|
message: `performance.minFps expected at least ${assertion.minFps} fps, observed ${observed2 ?? "unavailable"}.`,
|
|
1940
|
-
observedRuntimePath:
|
|
1959
|
+
observedRuntimePath: path2,
|
|
1941
1960
|
severity: "error",
|
|
1942
1961
|
sourcePath,
|
|
1943
1962
|
suggestion: "Read the TN_FRAME_BUDGET marker for this run: it names which frame phase owns the time."
|
|
@@ -1956,7 +1975,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1956
1975
|
if (!pass) diagnostics.push({
|
|
1957
1976
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1958
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}.`,
|
|
1959
|
-
observedRuntimePath:
|
|
1978
|
+
observedRuntimePath: path2,
|
|
1960
1979
|
severity: "error",
|
|
1961
1980
|
sourcePath,
|
|
1962
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."
|
|
@@ -1989,7 +2008,7 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1989
2008
|
if (!pass) diagnostics.push({
|
|
1990
2009
|
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1991
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}.`,
|
|
1992
|
-
observedRuntimePath:
|
|
2011
|
+
observedRuntimePath: path2,
|
|
1993
2012
|
severity: "error",
|
|
1994
2013
|
sourcePath,
|
|
1995
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."
|
|
@@ -3873,34 +3892,169 @@ var init_world_gameplay = __esm({
|
|
|
3873
3892
|
}
|
|
3874
3893
|
});
|
|
3875
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
|
+
|
|
3876
4027
|
// src/evaluators/render-chain.ts
|
|
3877
4028
|
function emitRenderChain(ctx) {
|
|
3878
4029
|
const assertion = ctx.scenarioAssertions.renderChain;
|
|
3879
4030
|
if (assertion === void 0) return;
|
|
3880
4031
|
const observed = ctx.input.report.observations?.renderChain;
|
|
3881
|
-
|
|
3882
|
-
|
|
4032
|
+
const selected = selectExpectation(ctx, assertion);
|
|
4033
|
+
const expected = selected.expectation;
|
|
4034
|
+
if (expected.tier !== void 0) {
|
|
4035
|
+
const pass = observed?.tier === expected.tier;
|
|
3883
4036
|
ctx.assertions.push({
|
|
3884
|
-
details: { expected:
|
|
4037
|
+
details: { ...selected.provenance, expected: expected.tier, observed: observed?.tier },
|
|
3885
4038
|
id: "renderChain.tier",
|
|
3886
4039
|
pass
|
|
3887
4040
|
});
|
|
3888
4041
|
if (!pass) {
|
|
3889
4042
|
ctx.diagnostics.push({
|
|
3890
4043
|
code: observed === void 0 ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_TIER_FAILED",
|
|
3891
|
-
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}'.`,
|
|
3892
4045
|
observedRuntimePath: "observations.json/renderChain/tier",
|
|
3893
4046
|
severity: "error",
|
|
3894
4047
|
suggestion: "Install the RenderChain through the renderer seam and keep its marker callback connected to the playtest bridge."
|
|
3895
4048
|
});
|
|
3896
4049
|
}
|
|
3897
4050
|
}
|
|
3898
|
-
const stageAssertion =
|
|
4051
|
+
const stageAssertion = expected.stages;
|
|
3899
4052
|
if (stageAssertion !== void 0) {
|
|
3900
4053
|
const observedStages = observed?.stages;
|
|
3901
4054
|
if (stageAssertion.includes !== void 0) {
|
|
3902
4055
|
emitStageCheck(
|
|
3903
4056
|
ctx,
|
|
4057
|
+
selected.provenance,
|
|
3904
4058
|
observedStages,
|
|
3905
4059
|
"includes",
|
|
3906
4060
|
stageAssertion.includes,
|
|
@@ -3910,6 +4064,7 @@ function emitRenderChain(ctx) {
|
|
|
3910
4064
|
if (stageAssertion.excludes !== void 0) {
|
|
3911
4065
|
emitStageCheck(
|
|
3912
4066
|
ctx,
|
|
4067
|
+
selected.provenance,
|
|
3913
4068
|
observedStages,
|
|
3914
4069
|
"excludes",
|
|
3915
4070
|
stageAssertion.excludes,
|
|
@@ -3919,6 +4074,7 @@ function emitRenderChain(ctx) {
|
|
|
3919
4074
|
if (stageAssertion.order !== void 0) {
|
|
3920
4075
|
emitStageCheck(
|
|
3921
4076
|
ctx,
|
|
4077
|
+
selected.provenance,
|
|
3922
4078
|
observedStages,
|
|
3923
4079
|
"order",
|
|
3924
4080
|
stageAssertion.order,
|
|
@@ -3926,7 +4082,7 @@ function emitRenderChain(ctx) {
|
|
|
3926
4082
|
);
|
|
3927
4083
|
}
|
|
3928
4084
|
}
|
|
3929
|
-
const contributionAssertion =
|
|
4085
|
+
const contributionAssertion = expected.contributions;
|
|
3930
4086
|
if (contributionAssertion !== void 0) {
|
|
3931
4087
|
const observedContributions = observed?.contributions;
|
|
3932
4088
|
const pass = Array.isArray(observedContributions) && contributionAssertion.graphOutputChanged.every(
|
|
@@ -3934,6 +4090,7 @@ function emitRenderChain(ctx) {
|
|
|
3934
4090
|
);
|
|
3935
4091
|
ctx.assertions.push({
|
|
3936
4092
|
details: {
|
|
4093
|
+
...selected.provenance,
|
|
3937
4094
|
expected: contributionAssertion.graphOutputChanged,
|
|
3938
4095
|
observed: observedContributions
|
|
3939
4096
|
},
|
|
@@ -3950,14 +4107,15 @@ function emitRenderChain(ctx) {
|
|
|
3950
4107
|
});
|
|
3951
4108
|
}
|
|
3952
4109
|
}
|
|
3953
|
-
if (
|
|
4110
|
+
if (expected.velocity !== void 0) {
|
|
3954
4111
|
const rejectionFraction = observed?.velocity.rejectionFraction;
|
|
3955
4112
|
const measurementFrame = observed?.velocity.measurementFrame;
|
|
3956
4113
|
const hasMeasurement = rejectionFraction !== void 0 && Number.isFinite(rejectionFraction) && typeof measurementFrame === "number" && Number.isInteger(measurementFrame) && measurementFrame >= 0;
|
|
3957
|
-
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <=
|
|
4114
|
+
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <= expected.velocity.maxRejectionFraction;
|
|
3958
4115
|
ctx.assertions.push({
|
|
3959
4116
|
details: {
|
|
3960
|
-
|
|
4117
|
+
...selected.provenance,
|
|
4118
|
+
expected: expected.velocity.maxRejectionFraction,
|
|
3961
4119
|
measurementFrame,
|
|
3962
4120
|
observed: rejectionFraction
|
|
3963
4121
|
},
|
|
@@ -3967,17 +4125,47 @@ function emitRenderChain(ctx) {
|
|
|
3967
4125
|
if (!pass) {
|
|
3968
4126
|
ctx.diagnostics.push({
|
|
3969
4127
|
code: observed === void 0 || !hasMeasurement ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_REJECTION_FAILED",
|
|
3970
|
-
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}.`,
|
|
3971
4129
|
observedRuntimePath: "observations.json/renderChain/velocity/rejectionFraction",
|
|
3972
4130
|
severity: "error",
|
|
3973
4131
|
suggestion: "Publish the temporal stage's measured rejection fraction on the same render-chain marker used for tier reporting."
|
|
3974
4132
|
});
|
|
3975
4133
|
}
|
|
3976
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
|
+
}
|
|
3977
4149
|
}
|
|
3978
|
-
function
|
|
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
|
+
};
|
|
4165
|
+
}
|
|
4166
|
+
function emitStageCheck(ctx, provenance, observed, kind, expected, pass) {
|
|
3979
4167
|
ctx.assertions.push({
|
|
3980
|
-
details: { expected, observed },
|
|
4168
|
+
details: { ...provenance, expected, observed },
|
|
3981
4169
|
id: `renderChain.stages.${kind}`,
|
|
3982
4170
|
pass
|
|
3983
4171
|
});
|
|
@@ -4001,6 +4189,7 @@ function isOrderedSubsequence(expected, observed) {
|
|
|
4001
4189
|
}
|
|
4002
4190
|
var init_render_chain = __esm({
|
|
4003
4191
|
"src/evaluators/render-chain.ts"() {
|
|
4192
|
+
init_adapter_class();
|
|
4004
4193
|
}
|
|
4005
4194
|
});
|
|
4006
4195
|
|
|
@@ -4815,7 +5004,8 @@ var init_generated_assertion_validators = __esm({
|
|
|
4815
5004
|
"tier": (value) => typeof value === "string" && value.trim() !== "",
|
|
4816
5005
|
"stages": (value) => isRecord2(value),
|
|
4817
5006
|
"contributions": (value) => isRecord2(value),
|
|
4818
|
-
"velocity": (value) => isRecord2(value)
|
|
5007
|
+
"velocity": (value) => isRecord2(value),
|
|
5008
|
+
"perAdapter": (value) => isRecord2(value)
|
|
4819
5009
|
})
|
|
4820
5010
|
});
|
|
4821
5011
|
}
|
|
@@ -5115,6 +5305,33 @@ function validateParityAssertion(value, scenarioPath, objectPath) {
|
|
|
5115
5305
|
}
|
|
5116
5306
|
function validateRenderChainAssertion(value, scenarioPath, objectPath) {
|
|
5117
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) {
|
|
5118
5335
|
const tier = record4.tier;
|
|
5119
5336
|
if (tier !== void 0 && tier !== "high" && tier !== "medium" && tier !== "low" && tier !== "off") {
|
|
5120
5337
|
throw invalidScenario(scenarioPath, `'${objectPath}.tier' must be high, medium, low, or off, received ${describeValue(tier)}.`);
|
|
@@ -5673,32 +5890,28 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
5673
5890
|
`assert.${kind}${suffix}.runtime`
|
|
5674
5891
|
);
|
|
5675
5892
|
}
|
|
5676
|
-
if (kind === "renderChain"
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
scenarioPath,
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
scenarioPath,
|
|
5689
|
-
`assert.${kind}${suffix}.contributions`
|
|
5690
|
-
);
|
|
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
|
+
}
|
|
5691
5905
|
}
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
scenarioPath,
|
|
5697
|
-
|
|
5698
|
-
);
|
|
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
|
+
}
|
|
5699
5912
|
}
|
|
5700
5913
|
}
|
|
5701
|
-
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;
|
|
5702
5915
|
var init_schema_accessors = __esm({
|
|
5703
5916
|
"src/scenario/schema-accessors.ts"() {
|
|
5704
5917
|
init_assertions();
|
|
@@ -5710,6 +5923,11 @@ var init_schema_accessors = __esm({
|
|
|
5710
5923
|
SCENE_FLAGS = ["cameraClearsScene", "fogClearsScene", "litMaterialsAreLit"];
|
|
5711
5924
|
SCENE_NODE_SELECTOR_KEYS = ["limit", "name", "nameContains", "pathContains", "type"];
|
|
5712
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
|
+
};
|
|
5713
5931
|
}
|
|
5714
5932
|
});
|
|
5715
5933
|
|
|
@@ -6007,6 +6225,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6007
6225
|
"holdFrames",
|
|
6008
6226
|
"holdTicks",
|
|
6009
6227
|
"kind",
|
|
6228
|
+
"lifecycle",
|
|
6010
6229
|
"overlayMessage",
|
|
6011
6230
|
"pitch",
|
|
6012
6231
|
"pointerPosition",
|
|
@@ -6056,9 +6275,9 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6056
6275
|
const holdTicks = positiveInteger(value.holdTicks);
|
|
6057
6276
|
const waitFrames2 = positiveInteger(value.waitFrames);
|
|
6058
6277
|
const waitTicks = positiveInteger(value.waitTicks);
|
|
6059
|
-
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;
|
|
6060
6279
|
if (value.kind !== void 0 && kind === void 0) {
|
|
6061
|
-
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'.`);
|
|
6062
6281
|
}
|
|
6063
6282
|
const at = validateClickTarget(value.at, scenarioPath, index);
|
|
6064
6283
|
const target = validateAimTarget(value.target, scenarioPath, index);
|
|
@@ -6072,6 +6291,10 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6072
6291
|
if (isRecord3(value.window)) {
|
|
6073
6292
|
rejectUnknownKeys(value.window, ["height", "operation", "width"], scenarioPath, `steps[${index}].window`);
|
|
6074
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);
|
|
6075
6298
|
if (kind !== "click" && (at !== void 0 || value.at !== void 0)) {
|
|
6076
6299
|
throw invalidStep(scenarioPath, `Scenario step ${index} declares at, which belongs to kind 'click'.`);
|
|
6077
6300
|
}
|
|
@@ -6138,8 +6361,38 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6138
6361
|
if (value.window !== void 0 && window2 === void 0) {
|
|
6139
6362
|
throw invalidStep(scenarioPath, `Scenario step ${index} window must define minimize, restore, or resize with positive width and height.`);
|
|
6140
6363
|
}
|
|
6141
|
-
if (
|
|
6142
|
-
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.`);
|
|
6143
6396
|
}
|
|
6144
6397
|
if (value.holdFrames !== void 0 && holdFrames === void 0) {
|
|
6145
6398
|
throw invalidStep(scenarioPath, `Scenario step ${index} holdFrames must be a positive integer.`);
|
|
@@ -6168,6 +6421,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6168
6421
|
...holdTicks === void 0 ? {} : { holdTicks },
|
|
6169
6422
|
...typeof value.label === "string" ? { label: value.label } : {},
|
|
6170
6423
|
...at === void 0 ? {} : { at },
|
|
6424
|
+
...lifecycle === void 0 ? {} : { lifecycle },
|
|
6171
6425
|
...overlayMessage === void 0 ? {} : { overlayMessage },
|
|
6172
6426
|
...pitch === void 0 ? {} : { pitch },
|
|
6173
6427
|
...pointerPosition === void 0 ? {} : { pointerPosition },
|
|
@@ -6184,6 +6438,22 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6184
6438
|
...window2 === void 0 ? {} : { window: window2 }
|
|
6185
6439
|
};
|
|
6186
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
|
+
}
|
|
6187
6457
|
function validateResourceWait(value, scenarioPath, index) {
|
|
6188
6458
|
const objectPath = `steps[${index}].waitForResource`;
|
|
6189
6459
|
if (!isRecord3(value)) {
|
|
@@ -6205,8 +6475,8 @@ function validateResourceWait(value, scenarioPath, index) {
|
|
|
6205
6475
|
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.lte must be a finite number.`);
|
|
6206
6476
|
}
|
|
6207
6477
|
const id = requireString(value, "id", scenarioPath, objectPath);
|
|
6208
|
-
const
|
|
6209
|
-
if (
|
|
6478
|
+
const path2 = requireString(value, "path", scenarioPath, objectPath);
|
|
6479
|
+
if (path2.split(".").some((part) => part.length === 0)) {
|
|
6210
6480
|
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.path must be a non-empty dot path.`);
|
|
6211
6481
|
}
|
|
6212
6482
|
return {
|
|
@@ -6214,7 +6484,7 @@ function validateResourceWait(value, scenarioPath, index) {
|
|
|
6214
6484
|
...gte === void 0 ? {} : { gte },
|
|
6215
6485
|
id,
|
|
6216
6486
|
...lte === void 0 ? {} : { lte },
|
|
6217
|
-
path
|
|
6487
|
+
path: path2
|
|
6218
6488
|
};
|
|
6219
6489
|
}
|
|
6220
6490
|
function validateClickTarget(value, scenarioPath, index) {
|
|
@@ -6249,17 +6519,17 @@ function validateAimTarget(value, scenarioPath, stepIndex) {
|
|
|
6249
6519
|
return { x, z };
|
|
6250
6520
|
}
|
|
6251
6521
|
function validatePointer(value, scenarioPath, stepIndex, pointerIndex) {
|
|
6252
|
-
const
|
|
6253
|
-
if (!isRecord3(value)) throw invalidStep(scenarioPath, `${
|
|
6254
|
-
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);
|
|
6255
6525
|
if (!Number.isInteger(value.id) || value.id < 1) {
|
|
6256
|
-
throw invalidStep(scenarioPath, `${
|
|
6526
|
+
throw invalidStep(scenarioPath, `${path2}.id must be a positive integer.`);
|
|
6257
6527
|
}
|
|
6258
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) {
|
|
6259
|
-
throw invalidStep(scenarioPath, `${
|
|
6529
|
+
throw invalidStep(scenarioPath, `${path2} must define normalized x and y values from 0 through 1.`);
|
|
6260
6530
|
}
|
|
6261
6531
|
if (value.buttons !== void 0 && (!Number.isInteger(value.buttons) || value.buttons < 1)) {
|
|
6262
|
-
throw invalidStep(scenarioPath, `${
|
|
6532
|
+
throw invalidStep(scenarioPath, `${path2}.buttons must be a positive integer when present.`);
|
|
6263
6533
|
}
|
|
6264
6534
|
return {
|
|
6265
6535
|
...typeof value.buttons === "number" ? { buttons: value.buttons } : {},
|
|
@@ -6281,9 +6551,9 @@ function validateStepLabels(steps, assertions, scenarioPath) {
|
|
|
6281
6551
|
labels.add(step.label);
|
|
6282
6552
|
}
|
|
6283
6553
|
if (assertions === void 0) return;
|
|
6284
|
-
const requireLabel = (label,
|
|
6554
|
+
const requireLabel = (label, path2) => {
|
|
6285
6555
|
if (label !== void 0 && !labels.has(label)) {
|
|
6286
|
-
throw invalidScenario(scenarioPath, `Assertion '${
|
|
6556
|
+
throw invalidScenario(scenarioPath, `Assertion '${path2}' names step label '${label}', but no scenario step defines it.`);
|
|
6287
6557
|
}
|
|
6288
6558
|
};
|
|
6289
6559
|
for (const [index, assertion] of (assertions.resources ?? []).entries()) {
|
|
@@ -6709,6 +6979,7 @@ var init_schema_validate = __esm({
|
|
|
6709
6979
|
"holdTicks",
|
|
6710
6980
|
"kind",
|
|
6711
6981
|
"label",
|
|
6982
|
+
"lifecycle",
|
|
6712
6983
|
"overlayMessage",
|
|
6713
6984
|
"pitch",
|
|
6714
6985
|
"pointerPosition",
|
|
@@ -6892,73 +7163,6 @@ var init_scenario = __esm({
|
|
|
6892
7163
|
}
|
|
6893
7164
|
});
|
|
6894
7165
|
|
|
6895
|
-
// src/runner/browser.ts
|
|
6896
|
-
var browser_exports = {};
|
|
6897
|
-
__export(browser_exports, {
|
|
6898
|
-
PERFORMANCE_BROWSER_ARGS: () => PERFORMANCE_BROWSER_ARGS,
|
|
6899
|
-
WEBGPU_BROWSER_ARGS: () => WEBGPU_BROWSER_ARGS,
|
|
6900
|
-
reconcileBrowserPointers: () => reconcileBrowserPointers,
|
|
6901
|
-
resolveBrowserArguments: () => resolveBrowserArguments,
|
|
6902
|
-
softwareAdapterName: () => softwareAdapterName
|
|
6903
|
-
});
|
|
6904
|
-
function resolveBrowserArguments(browserArgs) {
|
|
6905
|
-
return [...browserArgs ?? []];
|
|
6906
|
-
}
|
|
6907
|
-
function softwareAdapterName(adapter) {
|
|
6908
|
-
if (adapter === void 0) return void 0;
|
|
6909
|
-
for (const value of Object.values(adapter)) {
|
|
6910
|
-
if (typeof value === "string" && SOFTWARE_ADAPTER.test(value)) return value;
|
|
6911
|
-
}
|
|
6912
|
-
return void 0;
|
|
6913
|
-
}
|
|
6914
|
-
function reconcileBrowserPointers(previous, next) {
|
|
6915
|
-
const normalized = new Map(next.map((pointer) => [pointer.id, {
|
|
6916
|
-
buttons: pointer.buttons ?? 1,
|
|
6917
|
-
id: pointer.id,
|
|
6918
|
-
x: pointer.x,
|
|
6919
|
-
y: pointer.y
|
|
6920
|
-
}]));
|
|
6921
|
-
const previousPrimary = previous.keys().next().value;
|
|
6922
|
-
const nextPrimary = normalized.keys().next().value;
|
|
6923
|
-
const changes = [];
|
|
6924
|
-
for (const pointer of previous.values()) {
|
|
6925
|
-
if (!normalized.has(pointer.id)) {
|
|
6926
|
-
changes.push({ isPrimary: pointer.id === previousPrimary, pointer: { ...pointer, buttons: 0 }, type: "pointerup" });
|
|
6927
|
-
}
|
|
6928
|
-
}
|
|
6929
|
-
for (const pointer of normalized.values()) {
|
|
6930
|
-
const old = previous.get(pointer.id);
|
|
6931
|
-
if (old === void 0) {
|
|
6932
|
-
changes.push({ isPrimary: pointer.id === nextPrimary, pointer, type: "pointerdown" });
|
|
6933
|
-
} else if (old.x !== pointer.x || old.y !== pointer.y || old.buttons !== pointer.buttons) {
|
|
6934
|
-
changes.push({ isPrimary: pointer.id === nextPrimary, pointer, type: "pointermove" });
|
|
6935
|
-
}
|
|
6936
|
-
}
|
|
6937
|
-
return changes;
|
|
6938
|
-
}
|
|
6939
|
-
var WEBGPU_BROWSER_ARGS, PERFORMANCE_BROWSER_ARGS, SOFTWARE_ADAPTER;
|
|
6940
|
-
var init_browser = __esm({
|
|
6941
|
-
"src/runner/browser.ts"() {
|
|
6942
|
-
WEBGPU_BROWSER_ARGS = [
|
|
6943
|
-
"--ozone-platform=x11",
|
|
6944
|
-
"--enable-unsafe-webgpu",
|
|
6945
|
-
"--disable-gpu-sandbox",
|
|
6946
|
-
"--ignore-gpu-blocklist",
|
|
6947
|
-
// Without this Chromium never reaches the Vulkan driver on Linux and silently serves WebGPU
|
|
6948
|
-
// from SwiftShader, its CPU rasteriser. Nothing errors: the adapter answers, the run
|
|
6949
|
-
// proceeds, and the results are a software renderer's. Measured on an RTX 2080 under Xvfb,
|
|
6950
|
-
// `adapter.info` reads `swiftshader / google` without the flag and `turing / nvidia` with it,
|
|
6951
|
-
// which is the difference between blank captures and a rendered frame.
|
|
6952
|
-
"--enable-features=Vulkan"
|
|
6953
|
-
];
|
|
6954
|
-
PERFORMANCE_BROWSER_ARGS = [
|
|
6955
|
-
"--disable-frame-rate-limit",
|
|
6956
|
-
"--disable-gpu-vsync"
|
|
6957
|
-
];
|
|
6958
|
-
SOFTWARE_ADAPTER = /swiftshader|llvmpipe|lavapipe|softwarerasterizer|software adapter|basic render/i;
|
|
6959
|
-
}
|
|
6960
|
-
});
|
|
6961
|
-
|
|
6962
7166
|
// src/runner/deviceMetrics.ts
|
|
6963
7167
|
function parseDeviceBattery(output) {
|
|
6964
7168
|
const source = String(output);
|
|
@@ -7354,7 +7558,7 @@ var init_observationFields = __esm({
|
|
|
7354
7558
|
"startup",
|
|
7355
7559
|
"visual"
|
|
7356
7560
|
];
|
|
7357
|
-
HOST_PLAYTEST_OBSERVATION_FIELDS = ["deviceMetrics"];
|
|
7561
|
+
HOST_PLAYTEST_OBSERVATION_FIELDS = ["deviceLifecycle", "deviceMetrics"];
|
|
7358
7562
|
}
|
|
7359
7563
|
});
|
|
7360
7564
|
|
|
@@ -7458,9 +7662,9 @@ function setupRequest(scenario) {
|
|
|
7458
7662
|
}))
|
|
7459
7663
|
},
|
|
7460
7664
|
...scenario.setup?.resources === void 0 ? {} : {
|
|
7461
|
-
resources: scenario.setup.resources.map(({ id, path, value }) => ({
|
|
7665
|
+
resources: scenario.setup.resources.map(({ id, path: path2, value }) => ({
|
|
7462
7666
|
id,
|
|
7463
|
-
...
|
|
7667
|
+
...path2 === void 0 ? {} : { path: path2 },
|
|
7464
7668
|
value
|
|
7465
7669
|
}))
|
|
7466
7670
|
}
|
|
@@ -7546,11 +7750,12 @@ function managedServerError(message, url, timeoutMs, output) {
|
|
|
7546
7750
|
"Run the server command directly, fix its first error, then rerun the same playtest command."
|
|
7547
7751
|
));
|
|
7548
7752
|
}
|
|
7549
|
-
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;
|
|
7550
7754
|
var init_shared = __esm({
|
|
7551
7755
|
"src/runner/shared.ts"() {
|
|
7552
7756
|
init_index();
|
|
7553
7757
|
UNHANDLED_REJECTION_PREFIX = "__THREENATIVE_PLAYTEST_UNHANDLED_REJECTION__:";
|
|
7758
|
+
SCREENSHOT_TIMEOUT_MS = 12e4;
|
|
7554
7759
|
MAX_FIXED_STEP_STARTUP_RETRIES = 120;
|
|
7555
7760
|
STOPPED_LOOP_ERROR = "Cannot advance a stopped loop.";
|
|
7556
7761
|
ManagedServerError = class extends Error {
|
|
@@ -7777,13 +7982,13 @@ function unavailableObservation(scenario) {
|
|
|
7777
7982
|
reason: `Assertion '${entry.kind}' is not supported on target '${scenario.target}'.`
|
|
7778
7983
|
};
|
|
7779
7984
|
}
|
|
7780
|
-
for (const
|
|
7781
|
-
if (HOST_OBSERVATION_FIELD_SET.includes(
|
|
7782
|
-
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)) {
|
|
7783
7988
|
return {
|
|
7784
7989
|
assertion: entry.kind,
|
|
7785
|
-
path,
|
|
7786
|
-
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.`
|
|
7787
7992
|
};
|
|
7788
7993
|
}
|
|
7789
7994
|
}
|
|
@@ -7998,6 +8203,10 @@ var init_capture = __esm({
|
|
|
7998
8203
|
// src/runner/cli.ts
|
|
7999
8204
|
init_scenario();
|
|
8000
8205
|
|
|
8206
|
+
// src/runner/buildReport.ts
|
|
8207
|
+
init_assertion_schema();
|
|
8208
|
+
init_schema_accessors();
|
|
8209
|
+
|
|
8001
8210
|
// src/runner/config.ts
|
|
8002
8211
|
init_browser();
|
|
8003
8212
|
var PLAYTEST_FLAGS = {
|
|
@@ -8011,7 +8220,9 @@ var PLAYTEST_FLAGS = {
|
|
|
8011
8220
|
"--activity": { default: ".MystralActivity", summary: "Android launch activity", takesValue: true },
|
|
8012
8221
|
"--user": { default: "current foreground Android user", summary: "Android user id for force-stop and launch", takesValue: true },
|
|
8013
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 },
|
|
8014
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 },
|
|
8015
8226
|
"--no-screenshots": { default: "false", summary: "skip the before/after artifact frames; scenarios that assert on a frame still capture one", takesValue: false },
|
|
8016
8227
|
"--browser-arg": { allowDashValue: true, default: "none (repeatable)", repeatable: true, summary: "one additional Chromium argument", takesValue: true },
|
|
8017
8228
|
"--browser-recipe": { default: "none", summary: "named browser recipe (webgpu)", takesValue: true },
|
|
@@ -8021,6 +8232,7 @@ var PLAYTEST_FLAGS = {
|
|
|
8021
8232
|
"--executable": { default: "required for desktop", summary: "native desktop game executable", takesValue: true },
|
|
8022
8233
|
"--endpoint": { default: "http://127.0.0.1:41777/playtest", summary: "device bridge endpoint", takesValue: true },
|
|
8023
8234
|
"--headed": { default: "false", summary: "show the browser window", takesValue: false },
|
|
8235
|
+
"--judge-marker-url": { default: "none", summary: "judge-owned loopback marker URL whose POST failures are not network errors", takesValue: true },
|
|
8024
8236
|
// `allowDashValue` so a host flag can be passed as one: `--host-arg --ui` is the UI root the
|
|
8025
8237
|
// overlay serves, and the parser would otherwise read `--ui` as a playtest flag and reject it.
|
|
8026
8238
|
"--host-arg": { allowDashValue: true, default: "none", repeatable: true, summary: "argument passed to the native desktop host, repeatable", takesValue: true },
|
|
@@ -8121,6 +8333,16 @@ function formatUsage() {
|
|
|
8121
8333
|
" 1 assertions failed",
|
|
8122
8334
|
" 2 the run never reached assertions",
|
|
8123
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.",
|
|
8124
8346
|
""
|
|
8125
8347
|
].join("\n");
|
|
8126
8348
|
}
|
|
@@ -8167,6 +8389,18 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
8167
8389
|
}
|
|
8168
8390
|
const device = flags.get("--device")?.[0];
|
|
8169
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
|
+
}
|
|
8170
8404
|
if (target === "browser" && device !== void 0) {
|
|
8171
8405
|
if (browserRecipe !== void 0) {
|
|
8172
8406
|
throw new PlaytestCliUsageError("Android Chrome device runs cannot honor --browser-recipe; remove it.");
|
|
@@ -8190,9 +8424,17 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
8190
8424
|
throw new PlaytestCliUsageError(`Android --user must be numeric, got '${androidUser}'.`);
|
|
8191
8425
|
}
|
|
8192
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
|
+
}
|
|
8193
8434
|
const browserArgs = explicitBrowserArgs.length > 0 ? explicitBrowserArgs : browserRecipe === "webgpu" ? [...WEBGPU_BROWSER_ARGS] : [];
|
|
8194
8435
|
return {
|
|
8195
8436
|
...flags.get("--adb")?.[0] === void 0 ? {} : { adbPath: flags.get("--adb")[0] },
|
|
8437
|
+
...artifact === void 0 ? {} : { artifactPath: artifact },
|
|
8196
8438
|
...touchRotation === void 0 ? {} : { touchRotation },
|
|
8197
8439
|
// A scaffolded project's own `test` script is what a user runs, and it deliberately refuses a
|
|
8198
8440
|
// software adapter — nothing about that should change to suit a runner. But CI has no GPU and
|
|
@@ -8209,6 +8451,7 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
8209
8451
|
artifactDirectory: resolve(projectPath, flags.get("--artifacts")?.[0] ?? "artifacts/playtest"),
|
|
8210
8452
|
captureArtifactScreenshots: !argv.includes("--no-screenshots"),
|
|
8211
8453
|
...browserArgs.length === 0 ? {} : { browserArgs },
|
|
8454
|
+
...buildReport2 === void 0 ? {} : { buildReportPath: resolve(projectPath, buildReport2) },
|
|
8212
8455
|
...cpuProfilePath === void 0 ? {} : { cpuProfilePath: resolve(projectPath, cpuProfilePath) },
|
|
8213
8456
|
...device === void 0 ? {} : { device },
|
|
8214
8457
|
...executable === void 0 ? {} : {
|
|
@@ -8224,6 +8467,7 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
8224
8467
|
bundleId: flags.get("--bundle-id")?.[0] ?? "dev.threenative.runtime",
|
|
8225
8468
|
transport: iosTransport
|
|
8226
8469
|
},
|
|
8470
|
+
...judgeMarkerUrl === void 0 ? {} : { judgeMarkerUrl },
|
|
8227
8471
|
...flags.get("--mailbox-root")?.[0] === void 0 ? {} : { mailboxRoot: flags.get("--mailbox-root")[0] },
|
|
8228
8472
|
...serverCommand === void 0 ? effectivePort === void 0 ? {} : { port: effectivePort } : { port: effectivePort ?? 0 },
|
|
8229
8473
|
projectPath,
|
|
@@ -8339,6 +8583,191 @@ function isPlaytestFlag(value) {
|
|
|
8339
8583
|
return Object.prototype.hasOwnProperty.call(PLAYTEST_FLAGS, value);
|
|
8340
8584
|
}
|
|
8341
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
|
+
|
|
8342
8771
|
// src/runner/cli.ts
|
|
8343
8772
|
init_browser();
|
|
8344
8773
|
var CAPTURE_LOCK_TIMEOUT_MS_CONTESTED = 12e4;
|
|
@@ -8379,11 +8808,11 @@ function queueDirOf(lockRoot) {
|
|
|
8379
8808
|
return join(lockRoot, QUEUE_DIR_NAME);
|
|
8380
8809
|
}
|
|
8381
8810
|
function readHolder(lockDirectory) {
|
|
8382
|
-
const
|
|
8383
|
-
if (!existsSync(
|
|
8811
|
+
const path2 = join(lockDirectory, HOLDER_FILE);
|
|
8812
|
+
if (!existsSync(path2)) return void 0;
|
|
8384
8813
|
let raw;
|
|
8385
8814
|
try {
|
|
8386
|
-
raw = readFileSync(
|
|
8815
|
+
raw = readFileSync(path2, "utf8");
|
|
8387
8816
|
} catch {
|
|
8388
8817
|
return void 0;
|
|
8389
8818
|
}
|
|
@@ -8392,7 +8821,7 @@ function readHolder(lockDirectory) {
|
|
|
8392
8821
|
if (typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid)) throw new Error("bad pid");
|
|
8393
8822
|
return { ...parsed.command === void 0 ? {} : { command: parsed.command }, pid: parsed.pid, startedAt: String(parsed.startedAt ?? "") };
|
|
8394
8823
|
} catch {
|
|
8395
|
-
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.`);
|
|
8396
8825
|
}
|
|
8397
8826
|
}
|
|
8398
8827
|
var CaptureLockTimeoutError = class extends Error {
|
|
@@ -8542,6 +8971,8 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8542
8971
|
}
|
|
8543
8972
|
options;
|
|
8544
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;
|
|
8545
8976
|
adbPath;
|
|
8546
8977
|
screenrecord;
|
|
8547
8978
|
screenrecordError;
|
|
@@ -8551,6 +8982,8 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8551
8982
|
touchViewport;
|
|
8552
8983
|
user;
|
|
8553
8984
|
activeUser;
|
|
8985
|
+
/** Set by a lifecycle `rotate`, whose display lock `stop()` has to free on its own account. */
|
|
8986
|
+
lifecycleRotationLocked = false;
|
|
8554
8987
|
viewportPresented = false;
|
|
8555
8988
|
async prepare(endpoint, mailboxRoot, viewport) {
|
|
8556
8989
|
const url = new URL(endpoint);
|
|
@@ -8613,6 +9046,80 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8613
9046
|
async tap(x, y) {
|
|
8614
9047
|
await this.adb(tapCommand(x, y));
|
|
8615
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
|
+
}
|
|
8616
9123
|
/**
|
|
8617
9124
|
* Dismiss the soft keyboard and wait for it to actually be gone.
|
|
8618
9125
|
*
|
|
@@ -8639,14 +9146,14 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8639
9146
|
const output = await this.adb(["logcat", "-d", "-v", "brief"]);
|
|
8640
9147
|
return parseAndroidConsole(output);
|
|
8641
9148
|
}
|
|
8642
|
-
async screenshot(
|
|
9149
|
+
async screenshot(path2) {
|
|
8643
9150
|
const { stdout } = await execFileAsync(this.adbPath, [
|
|
8644
9151
|
...this.serialArgs(),
|
|
8645
9152
|
"exec-out",
|
|
8646
9153
|
"screencap",
|
|
8647
9154
|
"-p"
|
|
8648
9155
|
], { encoding: "buffer", maxBuffer: 32 * 1024 * 1024 });
|
|
8649
|
-
await writeFile(
|
|
9156
|
+
await writeFile(path2, stdout);
|
|
8650
9157
|
}
|
|
8651
9158
|
async startScreenRecording() {
|
|
8652
9159
|
if (this.screenrecord !== void 0) {
|
|
@@ -8677,7 +9184,7 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8677
9184
|
throw error;
|
|
8678
9185
|
}
|
|
8679
9186
|
}
|
|
8680
|
-
async stopScreenRecording(
|
|
9187
|
+
async stopScreenRecording(path2) {
|
|
8681
9188
|
const recorder = this.screenrecord;
|
|
8682
9189
|
if (recorder === void 0) {
|
|
8683
9190
|
throw new Error("TN_PLAYTEST_FRAMEBUFFER_COVERAGE_RECORDING_NOT_ACTIVE");
|
|
@@ -8688,8 +9195,8 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8688
9195
|
const pids = (await this.adb(["shell", "pidof", "screenrecord"]).catch(() => "")).trim().split(/\s+/u).filter((pid) => /^\d+$/u.test(pid));
|
|
8689
9196
|
for (const pid of pids) await this.adb(["shell", "kill", "-2", pid]);
|
|
8690
9197
|
await waitForProcessExit(recorder, 5e3);
|
|
8691
|
-
await this.adb(["pull", _AdbAndroidDriver.COVERAGE_VIDEO_PATH,
|
|
8692
|
-
if ((await stat(
|
|
9198
|
+
await this.adb(["pull", _AdbAndroidDriver.COVERAGE_VIDEO_PATH, path2]);
|
|
9199
|
+
if ((await stat(path2)).size === 0) {
|
|
8693
9200
|
throw new Error("TN_PLAYTEST_FRAMEBUFFER_COVERAGE_RECORDING_EMPTY");
|
|
8694
9201
|
}
|
|
8695
9202
|
} finally {
|
|
@@ -8761,21 +9268,25 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8761
9268
|
trackingIds: [...this.touchSlots.values()].map(({ trackingId }) => trackingId)
|
|
8762
9269
|
};
|
|
8763
9270
|
}
|
|
8764
|
-
async readFile(
|
|
9271
|
+
async readFile(path2) {
|
|
8765
9272
|
try {
|
|
8766
|
-
const contents = await this.adb(["exec-out", "cat",
|
|
9273
|
+
const contents = await this.adb(["exec-out", "cat", path2]);
|
|
8767
9274
|
return isMissingRemoteFileOutput(contents) ? void 0 : contents;
|
|
8768
9275
|
} catch (error) {
|
|
8769
9276
|
if (isMissingRemoteFile(error)) return void 0;
|
|
8770
9277
|
throw error;
|
|
8771
9278
|
}
|
|
8772
9279
|
}
|
|
8773
|
-
async removeFile(
|
|
8774
|
-
await this.adb(["shell", "rm", "-f",
|
|
9280
|
+
async removeFile(path2) {
|
|
9281
|
+
await this.adb(["shell", "rm", "-f", path2]);
|
|
8775
9282
|
}
|
|
8776
9283
|
async stop() {
|
|
8777
9284
|
await this.abortScreenRecording();
|
|
8778
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
|
+
}
|
|
8779
9290
|
if (this.viewportPresented) {
|
|
8780
9291
|
this.viewportPresented = false;
|
|
8781
9292
|
this.touchViewport = void 0;
|
|
@@ -8802,14 +9313,14 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8802
9313
|
if (/^[0-3]$/u.test(setting)) return Number(setting);
|
|
8803
9314
|
throw new Error("TN_PLAYTEST_ANDROID_ROTATION_UNKNOWN: dumpsys window, dumpsys input and user_rotation did not report 0 through 3.");
|
|
8804
9315
|
}
|
|
8805
|
-
async writeFile(
|
|
9316
|
+
async writeFile(path2, contents) {
|
|
8806
9317
|
const directory = await mkdtemp(join(tmpdir(), "threenative-adb-mailbox-"));
|
|
8807
9318
|
const localPath = join(directory, "payload.json");
|
|
8808
|
-
const remotePath = `${
|
|
9319
|
+
const remotePath = `${path2}.incoming-${process.pid}-${Date.now()}`;
|
|
8809
9320
|
try {
|
|
8810
9321
|
await writeFile(localPath, contents, "utf8");
|
|
8811
9322
|
await this.adb(["push", localPath, remotePath]);
|
|
8812
|
-
await this.adb(["shell", "mv", remotePath,
|
|
9323
|
+
await this.adb(["shell", "mv", remotePath, path2]);
|
|
8813
9324
|
} finally {
|
|
8814
9325
|
await rm(directory, { force: true, recursive: true });
|
|
8815
9326
|
await this.adb(["shell", "rm", "-f", remotePath]).catch(() => void 0);
|
|
@@ -8989,8 +9500,24 @@ function viewportPresentationObserved(override, expected, physical) {
|
|
|
8989
9500
|
return expected !== void 0 && (override === expected || override === void 0 && expected === `${physical.width}x${physical.height}`);
|
|
8990
9501
|
}
|
|
8991
9502
|
function touchRotationFromWindowDump(dump) {
|
|
9503
|
+
const rotation = windowRotationFromDump(dump);
|
|
9504
|
+
return rotation === void 0 ? void 0 : (4 - rotation) % 4;
|
|
9505
|
+
}
|
|
9506
|
+
function windowRotationFromDump(dump) {
|
|
8992
9507
|
const rotation = /\bmRotation=([0-3])\b/u.exec(dump)?.[1];
|
|
8993
|
-
return rotation === void 0 ? void 0 :
|
|
9508
|
+
return rotation === void 0 ? void 0 : Number(rotation);
|
|
9509
|
+
}
|
|
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);
|
|
8994
9521
|
}
|
|
8995
9522
|
function viewportPresentationCommands(viewport, physical) {
|
|
8996
9523
|
if (!(viewport.width > 0) || !(viewport.height > 0)) {
|
|
@@ -9060,6 +9587,9 @@ function discoverAdb(environment = process.env) {
|
|
|
9060
9587
|
"adb was not found. Install Android SDK Platform Tools, set ANDROID_HOME, or pass --adb /absolute/path/to/adb."
|
|
9061
9588
|
);
|
|
9062
9589
|
}
|
|
9590
|
+
function delay(milliseconds) {
|
|
9591
|
+
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
9592
|
+
}
|
|
9063
9593
|
|
|
9064
9594
|
// src/runner/doctor.ts
|
|
9065
9595
|
init_deviceMetrics();
|
|
@@ -10878,6 +11408,7 @@ function parsePerformanceMarkers(text) {
|
|
|
10878
11408
|
if (hostGap !== void 0) hostGaps.push(hostGap);
|
|
10879
11409
|
const projection = parseMarkerLine(line, PROJECTION_MARKER);
|
|
10880
11410
|
if (projection !== void 0) {
|
|
11411
|
+
assertProjectionTimings(projection);
|
|
10881
11412
|
const payload = JSON.stringify(projection);
|
|
10882
11413
|
if (!projectionPayloads.has(payload)) {
|
|
10883
11414
|
projectionPayloads.add(payload);
|
|
@@ -10900,6 +11431,24 @@ function parsePerformanceMarkers(text) {
|
|
|
10900
11431
|
slowPhases
|
|
10901
11432
|
};
|
|
10902
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
|
+
}
|
|
11451
|
+
}
|
|
10903
11452
|
function parseMarkerLine(line, marker2) {
|
|
10904
11453
|
const start = line.indexOf(marker2);
|
|
10905
11454
|
if (start === -1) return void 0;
|
|
@@ -11067,8 +11616,8 @@ async function perfCommand(argv) {
|
|
|
11067
11616
|
const args = parsePerfArgs(argv);
|
|
11068
11617
|
try {
|
|
11069
11618
|
if (args.file !== void 0) {
|
|
11070
|
-
const
|
|
11071
|
-
return emit(parsePerformanceMarkers(await readFile(
|
|
11619
|
+
const path2 = resolve(args.file);
|
|
11620
|
+
return emit(parsePerformanceMarkers(await readFile(path2, "utf8")), args, `file: ${path2}`);
|
|
11072
11621
|
}
|
|
11073
11622
|
if (args.logcatSerial !== void 0) {
|
|
11074
11623
|
return emit(parsePerformanceMarkers(await readLogcat(args.logcatSerial)), args, `logcat: ${args.logcatSerial}`);
|
|
@@ -11235,6 +11784,9 @@ function formatProjection(windows) {
|
|
|
11235
11784
|
const lines = [
|
|
11236
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`
|
|
11237
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
|
+
);
|
|
11238
11790
|
const ranked = rankExactReasons(last.exact);
|
|
11239
11791
|
if (last.exactObjects > 0 && ranked.length === 0) {
|
|
11240
11792
|
lines.push(
|
|
@@ -11318,12 +11870,11 @@ async function waitForStartupReady(options) {
|
|
|
11318
11870
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
11319
11871
|
throw new Error(`TN_PLAYTEST_STARTUP_TIMEOUT_INVALID: ${String(options.timeoutMs)}`);
|
|
11320
11872
|
const deadline = now() + timeoutMs;
|
|
11321
|
-
const settled = (observation) => options.acceptCompileSettled === true && observation.compileSettled === true;
|
|
11322
11873
|
const aborted = options.aborted ?? (() => false);
|
|
11323
11874
|
if (aborted()) throw abortedDuringStartup();
|
|
11324
11875
|
const hostAlive = options.hostAlive ?? (async () => void 0);
|
|
11325
11876
|
let observed = await pollStartup(bridge);
|
|
11326
|
-
while (observed === BUSY || observed.phase !== "ready"
|
|
11877
|
+
while (observed === BUSY || observed.phase !== "ready") {
|
|
11327
11878
|
if (aborted()) throw abortedDuringStartup();
|
|
11328
11879
|
if (observed === BUSY && await hostAlive() === false) throw hostExitedDuringStartup();
|
|
11329
11880
|
if (now() >= deadline) {
|
|
@@ -11333,11 +11884,21 @@ async function waitForStartupReady(options) {
|
|
|
11333
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."
|
|
11334
11885
|
));
|
|
11335
11886
|
}
|
|
11336
|
-
|
|
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
|
+
}
|
|
11337
11896
|
observed = await pollStartup(bridge);
|
|
11338
11897
|
}
|
|
11339
11898
|
return {
|
|
11340
|
-
|
|
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",
|
|
11341
11902
|
startup: observed
|
|
11342
11903
|
};
|
|
11343
11904
|
}
|
|
@@ -11446,12 +12007,12 @@ async function waitForResource(options) {
|
|
|
11446
12007
|
if (options.advance !== void 0 && now() < deadline) await options.advance();
|
|
11447
12008
|
}
|
|
11448
12009
|
}
|
|
11449
|
-
function waitFailure(message, instruction,
|
|
12010
|
+
function waitFailure(message, instruction, path2) {
|
|
11450
12011
|
return new PlaytestBridgeError(playtestDiagnostic(
|
|
11451
12012
|
"TN_PLAYTEST_OBSERVATION_UNAVAILABLE",
|
|
11452
12013
|
message,
|
|
11453
12014
|
instruction,
|
|
11454
|
-
{ path }
|
|
12015
|
+
{ path: path2 }
|
|
11455
12016
|
));
|
|
11456
12017
|
}
|
|
11457
12018
|
function json(value) {
|
|
@@ -11594,6 +12155,9 @@ var DeviceMailboxTransport = class {
|
|
|
11594
12155
|
closed = false;
|
|
11595
12156
|
nextId = 1;
|
|
11596
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();
|
|
11597
12161
|
responseObserver;
|
|
11598
12162
|
setResponseObserver(observer) {
|
|
11599
12163
|
this.responseObserver = observer;
|
|
@@ -11603,6 +12167,7 @@ var DeviceMailboxTransport = class {
|
|
|
11603
12167
|
this.connected = false;
|
|
11604
12168
|
this.nextId = 1;
|
|
11605
12169
|
this.nextOrder = 1;
|
|
12170
|
+
this.abandonedIds.clear();
|
|
11606
12171
|
await this.mailbox.remove(this.paths.request);
|
|
11607
12172
|
await this.mailbox.remove(this.paths.response);
|
|
11608
12173
|
}
|
|
@@ -11651,11 +12216,13 @@ var DeviceMailboxTransport = class {
|
|
|
11651
12216
|
const response = parseResponse(raw);
|
|
11652
12217
|
this.responseObserver?.({ body: raw, method, order, requestId: response.id });
|
|
11653
12218
|
await this.mailbox.remove(this.paths.response);
|
|
11654
|
-
if (response.id
|
|
11655
|
-
|
|
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}'.`);
|
|
11656
12222
|
}
|
|
11657
12223
|
await delayUntil(deadline);
|
|
11658
12224
|
}
|
|
12225
|
+
this.abandonedIds.add(id);
|
|
11659
12226
|
throw new PlaytestBridgeError(playtestDiagnostic(
|
|
11660
12227
|
"TN_PLAYTEST_OPERATION_TIMEOUT",
|
|
11661
12228
|
`Device mailbox operation '${id}' exceeded ${timeoutMs}ms.`,
|
|
@@ -11671,9 +12238,12 @@ function androidMailboxPaths(packageName, root = `/sdcard/Android/data/${package
|
|
|
11671
12238
|
return deviceMailboxPaths(root);
|
|
11672
12239
|
}
|
|
11673
12240
|
function deviceTimeoutDiagnostic(diagnostic2, hostAlive, lastConsoleLines) {
|
|
11674
|
-
if (diagnostic2.code !== "TN_PLAYTEST_OPERATION_TIMEOUT") return diagnostic2;
|
|
11675
12241
|
if (hostAlive !== false) return diagnostic2;
|
|
11676
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;
|
|
11677
12247
|
return playtestDiagnostic(
|
|
11678
12248
|
"TN_PLAYTEST_HOST_EXITED",
|
|
11679
12249
|
`${diagnostic2.message}; the host process has exited \u2014 ${tail}`,
|
|
@@ -11701,10 +12271,10 @@ function validateDeviceEndpoint(value) {
|
|
|
11701
12271
|
function parseResponse(value) {
|
|
11702
12272
|
const parsed = JSON.parse(value);
|
|
11703
12273
|
assertBounded(parsed);
|
|
11704
|
-
if (!
|
|
12274
|
+
if (!isRecord5(parsed) || typeof parsed.id !== "string") {
|
|
11705
12275
|
throw new Error("Device response must contain a string id.");
|
|
11706
12276
|
}
|
|
11707
|
-
if (parsed.error !== void 0 && (!
|
|
12277
|
+
if (parsed.error !== void 0 && (!isRecord5(parsed.error) || typeof parsed.error.message !== "string")) {
|
|
11708
12278
|
throw new Error("Device response error must contain a message.");
|
|
11709
12279
|
}
|
|
11710
12280
|
return parsed;
|
|
@@ -11731,7 +12301,7 @@ function sendJson(response, status, value) {
|
|
|
11731
12301
|
response.writeHead(status, { "content-length": Buffer.byteLength(body), "content-type": "application/json" });
|
|
11732
12302
|
response.end(body);
|
|
11733
12303
|
}
|
|
11734
|
-
function
|
|
12304
|
+
function isRecord5(value) {
|
|
11735
12305
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11736
12306
|
}
|
|
11737
12307
|
async function delayUntil(deadline) {
|
|
@@ -11739,9 +12309,9 @@ async function delayUntil(deadline) {
|
|
|
11739
12309
|
if (remaining > 0) await new Promise((resolve13) => setTimeout(resolve13, Math.min(40, remaining)));
|
|
11740
12310
|
}
|
|
11741
12311
|
var kMailboxLockCodes = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES"]);
|
|
11742
|
-
async function readMailboxFile(mailbox,
|
|
12312
|
+
async function readMailboxFile(mailbox, path2) {
|
|
11743
12313
|
try {
|
|
11744
|
-
return await mailbox.read(
|
|
12314
|
+
return await mailbox.read(path2);
|
|
11745
12315
|
} catch (error) {
|
|
11746
12316
|
if (isMailboxLockError(error)) return void 0;
|
|
11747
12317
|
throw error;
|
|
@@ -12441,10 +13011,10 @@ function containsPaintedPixels(screenshot) {
|
|
|
12441
13011
|
}
|
|
12442
13012
|
async function sampleHud(page, assertions) {
|
|
12443
13013
|
if (assertions.length === 0) return {};
|
|
12444
|
-
const snapshots = await page.evaluate((requestedAssertions) => Object.fromEntries(requestedAssertions.flatMap(({ id, path }) => {
|
|
12445
|
-
const element =
|
|
13014
|
+
const snapshots = await page.evaluate((requestedAssertions) => Object.fromEntries(requestedAssertions.flatMap(({ id, path: path2 }) => {
|
|
13015
|
+
const element = path2 === void 0 ? document.getElementById(id) : (() => {
|
|
12446
13016
|
try {
|
|
12447
|
-
return document.querySelector(
|
|
13017
|
+
return document.querySelector(path2);
|
|
12448
13018
|
} catch {
|
|
12449
13019
|
return null;
|
|
12450
13020
|
}
|
|
@@ -12454,7 +13024,7 @@ async function sampleHud(page, assertions) {
|
|
|
12454
13024
|
const rawValue = element.getAttribute("data-value");
|
|
12455
13025
|
const value = rawValue === null ? void 0 : Number.isFinite(Number(rawValue)) ? Number(rawValue) : rawValue;
|
|
12456
13026
|
const snapshot = value === void 0 ? text : value;
|
|
12457
|
-
return [[id,
|
|
13027
|
+
return [[id, path2 === void 0 ? snapshot : { [path2]: snapshot }]];
|
|
12458
13028
|
})), assertions);
|
|
12459
13029
|
for (const assertion of assertions) {
|
|
12460
13030
|
if (assertion.visible === void 0 || !Object.hasOwn(snapshots, assertion.id)) continue;
|
|
@@ -13338,14 +13908,17 @@ function writeCaptureState(payload) {
|
|
|
13338
13908
|
process.stderr.write(`${JSON.stringify(payload)}
|
|
13339
13909
|
`);
|
|
13340
13910
|
}
|
|
13911
|
+
function isJudgeMarkerRequestFailure(method, url, judgeMarkerUrl) {
|
|
13912
|
+
return method === "POST" && judgeMarkerUrl !== void 0 && url === judgeMarkerUrl;
|
|
13913
|
+
}
|
|
13341
13914
|
function addPreflightDiagnostic(report, diagnostic2) {
|
|
13342
13915
|
return diagnostic2 === void 0 ? report : { ...report, diagnostics: [diagnostic2, ...report.diagnostics] };
|
|
13343
13916
|
}
|
|
13344
|
-
var SOFTWARE_DEVICE_LOSS = /TN_DEVICE_LOST|WebGPU Device Lost|A valid external Instance reference no longer exists/iu;
|
|
13917
|
+
var SOFTWARE_DEVICE_LOSS = /TN_DEVICE_LOST|WebGPU Device Lost|A valid external Instance reference no longer exists|Instance dropped in popErrorScope/iu;
|
|
13345
13918
|
function isSoftwareDeviceLossEntry(entry) {
|
|
13346
13919
|
return (entry.type === "error" || entry.type === "assert" || entry.type === "pageerror") && SOFTWARE_DEVICE_LOSS.test(entry.text);
|
|
13347
13920
|
}
|
|
13348
|
-
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) {
|
|
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) {
|
|
13349
13922
|
const movementSample = isAnonymousMovementScenario(scenario) ? observedMovementSample(movementSamples) : void 0;
|
|
13350
13923
|
const entity = scenario.assert?.movement?.entity ?? scenario.subject ?? movementSample?.entity ?? "";
|
|
13351
13924
|
const wholeRunObserved = isAnonymousMovementScenario(scenario) ? false : entityPosition(beforeSnapshot, entity) !== void 0 && entityPosition(afterSnapshot, entity) !== void 0;
|
|
@@ -13376,6 +13949,11 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
13376
13949
|
const base = {
|
|
13377
13950
|
...afterPosition === void 0 ? {} : { after: { frame: scenario.steps.length, position: afterPosition, ...afterRotation === void 0 ? {} : { rotation: afterRotation }, tick: afterSnapshot?.clock.tick ?? 0 } },
|
|
13378
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 },
|
|
13379
13957
|
diagnostics,
|
|
13380
13958
|
diagnosticsPolicy: resolveDiagnosticsPolicy(scenario.assert?.diagnostics, config.target),
|
|
13381
13959
|
distance,
|
|
@@ -13405,6 +13983,7 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
13405
13983
|
signals: labeledSamples.flatMap(({ signals }) => signals)
|
|
13406
13984
|
},
|
|
13407
13985
|
hud,
|
|
13986
|
+
...deviceLifecycle === void 0 ? {} : { deviceLifecycle },
|
|
13408
13987
|
...deviceMetrics === void 0 ? {} : { deviceMetrics },
|
|
13409
13988
|
...framebufferCoverage === void 0 ? {} : { framebufferCoverage },
|
|
13410
13989
|
network: networkEntries,
|
|
@@ -13608,12 +14187,26 @@ function pageLifecycleDiagnostic(error, lifecycle, url) {
|
|
|
13608
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."
|
|
13609
14188
|
);
|
|
13610
14189
|
}
|
|
13611
|
-
const where = lifecycle.navigations.length === 0 ? "an unrecorded location" : `'${lifecycle.navigations.join("', '")}'`;
|
|
13612
14190
|
const observed = [
|
|
13613
14191
|
`page closed: ${lifecycle.closed}`,
|
|
13614
14192
|
`main-frame navigations: ${lifecycle.frameNavigations.length}`,
|
|
13615
14193
|
...lifecycle.tail.length === 0 ? [] : [`last console: ${lifecycle.tail.join(" | ")}`]
|
|
13616
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("', '")}'`;
|
|
13617
14210
|
return playtestDiagnostic(
|
|
13618
14211
|
"TN_PLAYTEST_PAGE_NAVIGATED",
|
|
13619
14212
|
`The page navigated to ${where} while the scenario was running at '${url}'; runner error: ${detail}. Observed: ${observed}.`,
|
|
@@ -13816,7 +14409,6 @@ function assertCpuProfileTargetSupported(target, cpuProfilePath) {
|
|
|
13816
14409
|
}
|
|
13817
14410
|
|
|
13818
14411
|
// src/runner/runner.ts
|
|
13819
|
-
var SCREENSHOT_TIMEOUT_MS = 12e4;
|
|
13820
14412
|
var TOUCH_BROWSER_USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 8) AppleWebKit/537.36 Chrome/151.0 Mobile Safari/537.36";
|
|
13821
14413
|
function isTouchPrimaryBrowserScenario(scenario) {
|
|
13822
14414
|
if (!scenario.steps.some(({ pointers }) => pointers !== void 0)) return false;
|
|
@@ -13866,7 +14458,10 @@ async function runStandalonePlaytest(config, options = {}) {
|
|
|
13866
14458
|
async function runStandalonePlaytestInternal(config, options = {}) {
|
|
13867
14459
|
const usesFreePort = config.server !== void 0 && config.port === 0;
|
|
13868
14460
|
const activeConfig = usesFreePort ? await resolveManagedServerConfig(config) : config;
|
|
13869
|
-
const scenario =
|
|
14461
|
+
const scenario = withPerformanceBudget(
|
|
14462
|
+
await loadPlaytestScenario(activeConfig.projectPath, activeConfig.scenarioPath),
|
|
14463
|
+
activeConfig.performanceBudget
|
|
14464
|
+
);
|
|
13870
14465
|
const browserConfig = scenario.assert?.performance === void 0 ? activeConfig : {
|
|
13871
14466
|
...activeConfig,
|
|
13872
14467
|
browserArgs: [
|
|
@@ -14013,7 +14608,12 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
14013
14608
|
if (pageLifecycle.tail.length > 8) pageLifecycle.tail.shift();
|
|
14014
14609
|
});
|
|
14015
14610
|
page.on("pageerror", (error) => consoleEntries.push({ source: "page-error", text: error.stack || error.message, type: "pageerror" }));
|
|
14016
|
-
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
|
+
});
|
|
14017
14617
|
const observedPage = page;
|
|
14018
14618
|
page.on("crash", () => {
|
|
14019
14619
|
pageLifecycle.crashed = true;
|
|
@@ -14042,8 +14642,8 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
14042
14642
|
await waitFrames(page, scenario.warmupFrames);
|
|
14043
14643
|
const startupOutcome = bridge === void 0 || scenario.awaitStartup === false ? void 0 : await waitForStartupReady({
|
|
14044
14644
|
aborted: () => tearingDown,
|
|
14045
|
-
acceptCompileSettled: activeConfig.allowSoftwareAdapter === true,
|
|
14046
14645
|
bridge,
|
|
14646
|
+
declaredSoftware: activeConfig.allowSoftwareAdapter === true,
|
|
14047
14647
|
pump: () => waitFrames(activePage, 1)
|
|
14048
14648
|
});
|
|
14049
14649
|
const runtimeReady = await page.evaluate(
|
|
@@ -14351,7 +14951,10 @@ async function runStandalonePlaytests(config) {
|
|
|
14351
14951
|
const activeConfig = usesFreePort ? await resolveManagedServerConfig(config) : config;
|
|
14352
14952
|
const scenarios = [];
|
|
14353
14953
|
for (const scenarioPath of scenarioPaths) {
|
|
14354
|
-
scenarios.push(
|
|
14954
|
+
scenarios.push(withPerformanceBudget(
|
|
14955
|
+
await loadPlaytestScenario(activeConfig.projectPath, scenarioPath),
|
|
14956
|
+
activeConfig.performanceBudget
|
|
14957
|
+
));
|
|
14355
14958
|
}
|
|
14356
14959
|
let server;
|
|
14357
14960
|
try {
|
|
@@ -14443,8 +15046,8 @@ async function analyzeFramebufferCoverageRecording(videoPath, artifactDirectory,
|
|
|
14443
15046
|
}
|
|
14444
15047
|
const gridSize = assertion.grid ?? DEFAULT_GRID;
|
|
14445
15048
|
const grids = [];
|
|
14446
|
-
for (const
|
|
14447
|
-
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));
|
|
14448
15051
|
}
|
|
14449
15052
|
const observation = boundarySource === "scenario-steps" ? analyzeScenarioBracketedCoverageFrames(grids, framePaths, assertion) : analyzeSampledCoverageFrames(grids, framePaths, assertion);
|
|
14450
15053
|
if (observation.firstViolation === void 0) return observation;
|
|
@@ -14522,8 +15125,8 @@ async function findVideoContentBoxFromFiles(framePaths) {
|
|
|
14522
15125
|
const firstPath = appPaths[0];
|
|
14523
15126
|
if (firstPath === void 0) return void 0;
|
|
14524
15127
|
const accumulator = createContentBoxAccumulator(PNG.sync.read(await readFile(firstPath)));
|
|
14525
|
-
for (const
|
|
14526
|
-
if (!accumulateContentBox(accumulator, PNG.sync.read(await readFile(
|
|
15128
|
+
for (const path2 of appPaths) {
|
|
15129
|
+
if (!accumulateContentBox(accumulator, PNG.sync.read(await readFile(path2)))) {
|
|
14527
15130
|
throw new Error("TN_PLAYTEST_FRAMEBUFFER_COVERAGE_VIDEO_SIZE_CHANGED");
|
|
14528
15131
|
}
|
|
14529
15132
|
}
|
|
@@ -14624,6 +15227,7 @@ function errorMessage2(error) {
|
|
|
14624
15227
|
}
|
|
14625
15228
|
|
|
14626
15229
|
// src/runner/androidRunner.ts
|
|
15230
|
+
init_adapter_class();
|
|
14627
15231
|
init_shared();
|
|
14628
15232
|
async function runAndroidPlaytest(config, dependencies = {}) {
|
|
14629
15233
|
config.endpoint ?? "http://127.0.0.1:41777/playtest";
|
|
@@ -14660,14 +15264,18 @@ async function runDevicePlaytest(config, target) {
|
|
|
14660
15264
|
return report;
|
|
14661
15265
|
}
|
|
14662
15266
|
async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
14663
|
-
const scenario =
|
|
15267
|
+
const scenario = withPerformanceBudget(
|
|
15268
|
+
await loadPlaytestScenario(config.projectPath, config.scenarioPath),
|
|
15269
|
+
config.performanceBudget
|
|
15270
|
+
);
|
|
14664
15271
|
await throwIfAborted(target);
|
|
14665
15272
|
await mkdir(config.artifactDirectory, { recursive: true });
|
|
14666
15273
|
await throwIfAborted(target);
|
|
14667
15274
|
const unsupported = unsupportedAssertion(
|
|
14668
15275
|
scenario,
|
|
14669
15276
|
target.name,
|
|
14670
|
-
typeof target.driver.tap === "function"
|
|
15277
|
+
typeof target.driver.tap === "function",
|
|
15278
|
+
canDriveAndroidLifecycle(target.driver)
|
|
14671
15279
|
);
|
|
14672
15280
|
if (unsupported !== void 0) return failureReport(config, scenario, unsupported, target.name);
|
|
14673
15281
|
if (target.name === "android" && scenario.assert?.framebufferCoverage !== void 0 && (typeof target.driver.startScreenRecording !== "function" || typeof target.driver.stopScreenRecording !== "function")) {
|
|
@@ -14730,8 +15338,8 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14730
15338
|
await throwIfAborted(target);
|
|
14731
15339
|
const attached = bridge;
|
|
14732
15340
|
const startupOutcome = scenario.awaitStartup === false ? void 0 : await waitForStartupReady({
|
|
14733
|
-
acceptCompileSettled: config.allowSoftwareAdapter === true,
|
|
14734
15341
|
bridge: attached,
|
|
15342
|
+
declaredSoftware: config.allowSoftwareAdapter === true,
|
|
14735
15343
|
// A device host can die mid-launch, and its mailbox then simply stops answering. Without
|
|
14736
15344
|
// this the wait reads that as a slow loading gate and burns its whole deadline; with it
|
|
14737
15345
|
// the report names the exit and carries the console tail that says why.
|
|
@@ -14777,14 +15385,28 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14777
15385
|
let pointerX = 0;
|
|
14778
15386
|
let pointerY = 0;
|
|
14779
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();
|
|
14780
15398
|
for (const [index, step] of scenario.steps.entries()) {
|
|
14781
15399
|
await throwIfAborted(target);
|
|
15400
|
+
if (step.lifecycle !== void 0) {
|
|
15401
|
+
await lifecycle?.run(step.lifecycle, () => attached.advance(1));
|
|
15402
|
+
continue;
|
|
15403
|
+
}
|
|
14782
15404
|
const framebufferAssertion = scenario.assert?.framebufferCoverage;
|
|
14783
15405
|
if (target.name === "android" && framebufferAssertion !== void 0 && step.label === framebufferAssertion.window.startStep) {
|
|
14784
15406
|
try {
|
|
14785
15407
|
await target.driver.startScreenRecording?.();
|
|
14786
15408
|
coverageRecordingStarted = true;
|
|
14787
|
-
await
|
|
15409
|
+
await delay2(100);
|
|
14788
15410
|
} catch (error) {
|
|
14789
15411
|
framebufferCoverage = unreadableCoverageObservation(error);
|
|
14790
15412
|
}
|
|
@@ -14869,7 +15491,7 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14869
15491
|
if (coverageRecordingStarted) {
|
|
14870
15492
|
for (let frame = 0; frame < frames; frame += 1) {
|
|
14871
15493
|
await bridge.advance(1);
|
|
14872
|
-
await
|
|
15494
|
+
await delay2(100);
|
|
14873
15495
|
}
|
|
14874
15496
|
} else {
|
|
14875
15497
|
await bridge.advance(frames);
|
|
@@ -14962,13 +15584,18 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14962
15584
|
void 0,
|
|
14963
15585
|
labeledSamples,
|
|
14964
15586
|
framebufferCoverage,
|
|
14965
|
-
|
|
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),
|
|
14966
15592
|
void 0,
|
|
14967
15593
|
movementSamples,
|
|
14968
15594
|
setupApplication2,
|
|
14969
15595
|
metrics?.observation(),
|
|
14970
15596
|
void 0,
|
|
14971
|
-
startupOutcome === void 0 ? void 0 : { ...startupOutcome.startup, rule: startupOutcome.rule }
|
|
15597
|
+
startupOutcome === void 0 ? void 0 : { ...startupOutcome.startup, rule: startupOutcome.rule },
|
|
15598
|
+
lifecycle?.observation()
|
|
14972
15599
|
);
|
|
14973
15600
|
await writeObservationArtifacts(config.artifactDirectory, scenario.artifacts, {
|
|
14974
15601
|
console: consoleEntries,
|
|
@@ -14984,7 +15611,7 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14984
15611
|
} catch (error) {
|
|
14985
15612
|
if (error instanceof PlaytestBridgeError) {
|
|
14986
15613
|
let diagnostic2 = error.diagnostic;
|
|
14987
|
-
if (diagnostic2.code === "TN_PLAYTEST_OPERATION_TIMEOUT") {
|
|
15614
|
+
if (diagnostic2.code === "TN_PLAYTEST_OPERATION_TIMEOUT" || diagnostic2.code === "TN_PLAYTEST_STARTUP_HOST_EXITED") {
|
|
14988
15615
|
const hostAlive = await target.driver.isAlive().catch(() => void 0);
|
|
14989
15616
|
const lastConsoleLines = hostAlive === false ? (await target.driver.captureConsole().catch(() => [])).slice(-6).map((entry) => entry.text) : [];
|
|
14990
15617
|
diagnostic2 = deviceTimeoutDiagnostic(diagnostic2, hostAlive, lastConsoleLines);
|
|
@@ -15030,9 +15657,9 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
15030
15657
|
if (cleanupErrors.length > 0) cleanupState.error = cleanupFailure(cleanupErrors);
|
|
15031
15658
|
}
|
|
15032
15659
|
}
|
|
15033
|
-
async function captureDeviceScreenshot(target,
|
|
15034
|
-
await target.driver.screenshot(
|
|
15035
|
-
assertCaptureNotBlank(await readFile(
|
|
15660
|
+
async function captureDeviceScreenshot(target, path2) {
|
|
15661
|
+
await target.driver.screenshot(path2);
|
|
15662
|
+
assertCaptureNotBlank(await readFile(path2), path2);
|
|
15036
15663
|
}
|
|
15037
15664
|
function deviceMetricsRecorder(target) {
|
|
15038
15665
|
if (target.name !== "android") return void 0;
|
|
@@ -15054,9 +15681,9 @@ function cleanupFailure(errors) {
|
|
|
15054
15681
|
function createDeviceTransport(driver, endpoint, paths, operationTimeoutMs) {
|
|
15055
15682
|
if (isMailboxDriver(driver)) {
|
|
15056
15683
|
const mailbox = {
|
|
15057
|
-
read: (
|
|
15058
|
-
remove: (
|
|
15059
|
-
write: (
|
|
15684
|
+
read: (path2) => driver.readFile(path2),
|
|
15685
|
+
remove: (path2) => driver.removeFile(path2),
|
|
15686
|
+
write: (path2, contents) => driver.writeFile(path2, contents)
|
|
15060
15687
|
};
|
|
15061
15688
|
return new DeviceMailboxTransport(mailbox, paths, operationTimeoutMs);
|
|
15062
15689
|
}
|
|
@@ -15137,7 +15764,203 @@ function androidKeyEventCode(key) {
|
|
|
15137
15764
|
function isMailboxDriver(driver) {
|
|
15138
15765
|
return typeof driver.readFile === "function" && typeof driver.removeFile === "function" && typeof driver.writeFile === "function";
|
|
15139
15766
|
}
|
|
15140
|
-
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
|
+
}
|
|
15141
15964
|
if (scenario.steps.some((step) => step.wheel !== void 0)) {
|
|
15142
15965
|
return unsupportedDiagnostic(
|
|
15143
15966
|
"wheel input steps",
|
|
@@ -15212,7 +16035,7 @@ function unreadableCoverageObservation(error) {
|
|
|
15212
16035
|
windowStarted: false
|
|
15213
16036
|
};
|
|
15214
16037
|
}
|
|
15215
|
-
function
|
|
16038
|
+
function delay2(milliseconds) {
|
|
15216
16039
|
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
15217
16040
|
}
|
|
15218
16041
|
init_deviceMetrics();
|
|
@@ -15396,34 +16219,42 @@ function deviceFailure(serial, error) {
|
|
|
15396
16219
|
|
|
15397
16220
|
// src/runner/desktop.ts
|
|
15398
16221
|
init_capture();
|
|
16222
|
+
init_shared();
|
|
15399
16223
|
var SCREENSHOT_TIMEOUT_MS2 = 5e3;
|
|
15400
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
|
+
}
|
|
15401
16231
|
var SCREENSHOT_REQUEST_TEMP_FILE = `${SCREENSHOT_REQUEST_FILE}.tmp`;
|
|
16232
|
+
var HOST_DIAGNOSTIC_LINE = /\[(?:Screenshot|Playtest)\]/u;
|
|
15402
16233
|
var LocalDeviceMailbox = class {
|
|
15403
|
-
async read(
|
|
16234
|
+
async read(path2) {
|
|
15404
16235
|
try {
|
|
15405
|
-
return await readFile(
|
|
16236
|
+
return await readFile(path2, "utf8");
|
|
15406
16237
|
} catch (error) {
|
|
15407
16238
|
if (isMissingFile(error) || isTransientMailboxLock(error)) return void 0;
|
|
15408
16239
|
throw error;
|
|
15409
16240
|
}
|
|
15410
16241
|
}
|
|
15411
|
-
async remove(
|
|
16242
|
+
async remove(path2) {
|
|
15412
16243
|
for (let retry = 0; ; retry += 1) {
|
|
15413
16244
|
try {
|
|
15414
|
-
await rm(
|
|
16245
|
+
await rm(path2, { force: true });
|
|
15415
16246
|
return;
|
|
15416
16247
|
} catch (error) {
|
|
15417
16248
|
if (retry >= 10 || !isTransientMailboxLock(error)) throw error;
|
|
15418
|
-
await
|
|
16249
|
+
await delay3(20);
|
|
15419
16250
|
}
|
|
15420
16251
|
}
|
|
15421
16252
|
}
|
|
15422
|
-
async write(
|
|
15423
|
-
await mkdir(dirname(
|
|
15424
|
-
const temporary = `${
|
|
16253
|
+
async write(path2, contents) {
|
|
16254
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
16255
|
+
const temporary = `${path2}.tmp`;
|
|
15425
16256
|
await writeFile(temporary, contents, "utf8");
|
|
15426
|
-
await rename(temporary,
|
|
16257
|
+
await rename(temporary, path2);
|
|
15427
16258
|
}
|
|
15428
16259
|
};
|
|
15429
16260
|
var DesktopPlaytestDriver = class {
|
|
@@ -15483,33 +16314,51 @@ var DesktopPlaytestDriver = class {
|
|
|
15483
16314
|
throw error;
|
|
15484
16315
|
}
|
|
15485
16316
|
}
|
|
15486
|
-
async screenshot(
|
|
16317
|
+
async screenshot(path2) {
|
|
15487
16318
|
const root = this.mailboxRoot;
|
|
15488
16319
|
if (root === void 0) throw new Error("Desktop playtest mailbox is unavailable before prepare().");
|
|
15489
16320
|
if (!await this.isAlive()) throw new Error("Desktop playtest executable exited before screenshot capture.");
|
|
15490
|
-
await rm(
|
|
16321
|
+
await rm(path2, { force: true });
|
|
15491
16322
|
const request = join(root, SCREENSHOT_REQUEST_FILE);
|
|
15492
|
-
await new LocalDeviceMailbox().write(request,
|
|
15493
|
-
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;
|
|
15494
16327
|
let lastReadError;
|
|
15495
16328
|
while (Date.now() < deadline) {
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
return;
|
|
15500
|
-
} catch (error) {
|
|
15501
|
-
if (error instanceof Error && error.name === "CaptureGuardError") throw error;
|
|
15502
|
-
if (!isMissingFile(error)) lastReadError = error;
|
|
15503
|
-
}
|
|
16329
|
+
const readError = await tryReadDesktopScreenshot(path2);
|
|
16330
|
+
if (readError === void 0) return;
|
|
16331
|
+
lastReadError = readError;
|
|
15504
16332
|
if (!await this.isAlive()) {
|
|
15505
16333
|
throw new Error("Desktop playtest executable exited before screenshot capture.");
|
|
15506
16334
|
}
|
|
15507
|
-
|
|
16335
|
+
if (!accepted) {
|
|
16336
|
+
accepted = await new LocalDeviceMailbox().read(request) === void 0;
|
|
16337
|
+
if (!accepted && Date.now() >= pickupDeadline) break;
|
|
16338
|
+
}
|
|
16339
|
+
await delay3(25);
|
|
15508
16340
|
}
|
|
15509
16341
|
throw new Error(
|
|
15510
|
-
`TN_PLAYTEST_NATIVE_SCREENSHOT_UNAVAILABLE: ${
|
|
16342
|
+
`TN_PLAYTEST_NATIVE_SCREENSHOT_UNAVAILABLE: ${await this.describeScreenshotTimeout(request, lastReadError)}`
|
|
15511
16343
|
);
|
|
15512
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
|
+
}
|
|
15513
16362
|
async stop() {
|
|
15514
16363
|
const child = this.child;
|
|
15515
16364
|
if (child === void 0) return;
|
|
@@ -15548,6 +16397,16 @@ var DesktopPlaytestDriver = class {
|
|
|
15548
16397
|
}
|
|
15549
16398
|
}
|
|
15550
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
|
+
}
|
|
15551
16410
|
function desktopConsoleType(stream, line) {
|
|
15552
16411
|
const text = line.trimStart();
|
|
15553
16412
|
if (/^(?:\[error\]|(?:error|fatal):)/iu.test(text)) return "error";
|
|
@@ -15602,7 +16461,7 @@ function waitForExit(child, timeoutMs) {
|
|
|
15602
16461
|
function isProcessExited(child) {
|
|
15603
16462
|
return child.exitCode !== null || child.signalCode !== null;
|
|
15604
16463
|
}
|
|
15605
|
-
function
|
|
16464
|
+
function delay3(milliseconds) {
|
|
15606
16465
|
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
15607
16466
|
}
|
|
15608
16467
|
function isTransientMailboxLock(error) {
|
|
@@ -15612,6 +16471,15 @@ function isTransientMailboxLock(error) {
|
|
|
15612
16471
|
function isMissingFile(error) {
|
|
15613
16472
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
15614
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
|
+
}
|
|
15615
16483
|
|
|
15616
16484
|
// src/runner/desktopRunner.ts
|
|
15617
16485
|
init_shared();
|
|
@@ -15672,7 +16540,8 @@ async function runDesktopPlaytest(config, dependencies = {}) {
|
|
|
15672
16540
|
cwd: config.projectPath,
|
|
15673
16541
|
...providedDisplay === void 0 ? {} : { env: providedDisplay.env },
|
|
15674
16542
|
executable,
|
|
15675
|
-
mailboxRoot: root
|
|
16543
|
+
mailboxRoot: root,
|
|
16544
|
+
screenshotTimeoutMs: config.timeoutMs
|
|
15676
16545
|
});
|
|
15677
16546
|
transport = dependencies.transport ?? new DeviceMailboxTransport(
|
|
15678
16547
|
new LocalDeviceMailbox(),
|
|
@@ -15692,6 +16561,17 @@ async function runDesktopPlaytest(config, dependencies = {}) {
|
|
|
15692
16561
|
} catch (error) {
|
|
15693
16562
|
executionFailed = true;
|
|
15694
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
|
+
}
|
|
15695
16575
|
} finally {
|
|
15696
16576
|
process.off("SIGINT", handleSignal);
|
|
15697
16577
|
process.off("SIGTERM", handleSignal);
|
|
@@ -15838,25 +16718,25 @@ var XcrunIosDriver = class {
|
|
|
15838
16718
|
return false;
|
|
15839
16719
|
}
|
|
15840
16720
|
}
|
|
15841
|
-
async screenshot(
|
|
16721
|
+
async screenshot(path2) {
|
|
15842
16722
|
if (this.options.transport === "simulator") {
|
|
15843
|
-
await this.run(["simctl", "io", this.device(), "screenshot",
|
|
16723
|
+
await this.run(["simctl", "io", this.device(), "screenshot", path2]);
|
|
15844
16724
|
return;
|
|
15845
16725
|
}
|
|
15846
|
-
await this.run(["devicectl", "device", "capture", "screen", "--device", this.device(), "--destination",
|
|
16726
|
+
await this.run(["devicectl", "device", "capture", "screen", "--device", this.device(), "--destination", path2]);
|
|
15847
16727
|
}
|
|
15848
|
-
async readFile(
|
|
15849
|
-
|
|
16728
|
+
async readFile(path2) {
|
|
16729
|
+
path2 = this.mailboxPath(path2);
|
|
15850
16730
|
if (this.options.transport === "simulator") {
|
|
15851
16731
|
try {
|
|
15852
|
-
return await readFile(
|
|
16732
|
+
return await readFile(path2, "utf8");
|
|
15853
16733
|
} catch (error) {
|
|
15854
16734
|
if (error.code === "ENOENT") return void 0;
|
|
15855
16735
|
throw error;
|
|
15856
16736
|
}
|
|
15857
16737
|
}
|
|
15858
16738
|
const directory = await mkdtemp(join(tmpdir(), "threenative-devicectl-read-"));
|
|
15859
|
-
const destination = join(directory, basename(
|
|
16739
|
+
const destination = join(directory, basename(path2));
|
|
15860
16740
|
try {
|
|
15861
16741
|
await this.run([
|
|
15862
16742
|
"devicectl",
|
|
@@ -15870,7 +16750,7 @@ var XcrunIosDriver = class {
|
|
|
15870
16750
|
"--domain-identifier",
|
|
15871
16751
|
this.options.bundleId,
|
|
15872
16752
|
"--source",
|
|
15873
|
-
|
|
16753
|
+
path2,
|
|
15874
16754
|
"--destination",
|
|
15875
16755
|
destination
|
|
15876
16756
|
]);
|
|
@@ -15883,16 +16763,16 @@ var XcrunIosDriver = class {
|
|
|
15883
16763
|
await rm(directory, { force: true, recursive: true });
|
|
15884
16764
|
}
|
|
15885
16765
|
}
|
|
15886
|
-
async removeFile(
|
|
16766
|
+
async removeFile(path2) {
|
|
15887
16767
|
if (this.mailboxRoot === void 0) return;
|
|
15888
|
-
|
|
16768
|
+
path2 = this.mailboxPath(path2);
|
|
15889
16769
|
if (this.options.transport === "simulator") {
|
|
15890
|
-
await unlink(
|
|
16770
|
+
await unlink(path2).catch((error) => {
|
|
15891
16771
|
if (error.code !== "ENOENT") throw error;
|
|
15892
16772
|
});
|
|
15893
16773
|
return;
|
|
15894
16774
|
}
|
|
15895
|
-
this.suppressedResponse = await this.readFile(
|
|
16775
|
+
this.suppressedResponse = await this.readFile(path2);
|
|
15896
16776
|
}
|
|
15897
16777
|
async stop() {
|
|
15898
16778
|
if (this.options.transport === "simulator") {
|
|
@@ -15909,17 +16789,17 @@ var XcrunIosDriver = class {
|
|
|
15909
16789
|
]).catch(() => void 0);
|
|
15910
16790
|
}
|
|
15911
16791
|
}
|
|
15912
|
-
async writeFile(
|
|
15913
|
-
|
|
16792
|
+
async writeFile(path2, contents) {
|
|
16793
|
+
path2 = this.mailboxPath(path2);
|
|
15914
16794
|
if (this.options.transport === "simulator") {
|
|
15915
|
-
await mkdir(dirname(
|
|
15916
|
-
const temporary = `${
|
|
16795
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
16796
|
+
const temporary = `${path2}.incoming-${process.pid}-${Date.now()}`;
|
|
15917
16797
|
await writeFile(temporary, contents, "utf8");
|
|
15918
|
-
await rename(temporary,
|
|
16798
|
+
await rename(temporary, path2);
|
|
15919
16799
|
return;
|
|
15920
16800
|
}
|
|
15921
16801
|
const directory = await mkdtemp(join(tmpdir(), "threenative-devicectl-write-"));
|
|
15922
|
-
const source = join(directory, basename(
|
|
16802
|
+
const source = join(directory, basename(path2));
|
|
15923
16803
|
try {
|
|
15924
16804
|
await writeFile(source, contents, "utf8");
|
|
15925
16805
|
await this.run([
|
|
@@ -15936,7 +16816,7 @@ var XcrunIosDriver = class {
|
|
|
15936
16816
|
"--source",
|
|
15937
16817
|
source,
|
|
15938
16818
|
"--destination",
|
|
15939
|
-
|
|
16819
|
+
path2
|
|
15940
16820
|
]);
|
|
15941
16821
|
} finally {
|
|
15942
16822
|
await rm(directory, { force: true, recursive: true });
|
|
@@ -16007,8 +16887,8 @@ var XcrunIosDriver = class {
|
|
|
16007
16887
|
device() {
|
|
16008
16888
|
return this.options.device ?? "booted";
|
|
16009
16889
|
}
|
|
16010
|
-
mailboxPath(
|
|
16011
|
-
return this.mailboxRoot === void 0 ?
|
|
16890
|
+
mailboxPath(path2) {
|
|
16891
|
+
return this.mailboxRoot === void 0 ? path2 : join(this.mailboxRoot, basename(path2));
|
|
16012
16892
|
}
|
|
16013
16893
|
};
|
|
16014
16894
|
function parseLaunchedPid(output) {
|
|
@@ -16045,33 +16925,33 @@ async function runIosPlaytest(config, dependencies = {}) {
|
|
|
16045
16925
|
init_scenario();
|
|
16046
16926
|
var SCENARIO_VIEWPORT = { height: 720, width: 1280 };
|
|
16047
16927
|
var FINAL_STEP_LABEL = "replay-final";
|
|
16048
|
-
function recordNumber(value,
|
|
16928
|
+
function recordNumber(value, path2, integer = false) {
|
|
16049
16929
|
if (typeof value !== "number" || !Number.isFinite(value) || integer && !Number.isInteger(value))
|
|
16050
|
-
throw invalidScenario(
|
|
16930
|
+
throw invalidScenario(path2, `${path2} must be a finite${integer ? " integer" : " number"}.`);
|
|
16051
16931
|
return value;
|
|
16052
16932
|
}
|
|
16053
|
-
function recordString(value,
|
|
16054
|
-
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.`);
|
|
16055
16935
|
return value;
|
|
16056
16936
|
}
|
|
16057
|
-
function recordObject(value,
|
|
16937
|
+
function recordObject(value, path2) {
|
|
16058
16938
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
16059
|
-
throw invalidScenario(
|
|
16939
|
+
throw invalidScenario(path2, `${path2} must be an object.`);
|
|
16060
16940
|
return value;
|
|
16061
16941
|
}
|
|
16062
|
-
function recordTuple(value,
|
|
16942
|
+
function recordTuple(value, path2) {
|
|
16063
16943
|
if (!Array.isArray(value) || value.length !== 3 || !value.every((item) => typeof item === "number" && Number.isFinite(item)))
|
|
16064
|
-
throw invalidScenario(
|
|
16944
|
+
throw invalidScenario(path2, `${path2} must be a finite three-number tuple.`);
|
|
16065
16945
|
return value;
|
|
16066
16946
|
}
|
|
16067
|
-
function recordPointer(value,
|
|
16947
|
+
function recordPointer(value, path2) {
|
|
16068
16948
|
if (!Array.isArray(value) || value.length !== 5 || !value.every((item) => typeof item === "number" && Number.isFinite(item)))
|
|
16069
|
-
throw invalidScenario(
|
|
16949
|
+
throw invalidScenario(path2, `${path2} must be [x, y, buttons, viewport width, viewport height].`);
|
|
16070
16950
|
const pointer = value;
|
|
16071
16951
|
if (!Number.isInteger(pointer[2]) || pointer[2] < 0 || (pointer[2] & -8) !== 0)
|
|
16072
|
-
throw invalidScenario(
|
|
16952
|
+
throw invalidScenario(path2, `${path2} buttons must use left, right, or middle buttons only.`);
|
|
16073
16953
|
if (!Number.isInteger(pointer[3]) || pointer[3] < 1 || !Number.isInteger(pointer[4]) || pointer[4] < 1)
|
|
16074
|
-
throw invalidScenario(
|
|
16954
|
+
throw invalidScenario(path2, `${path2} viewport dimensions must be positive integers.`);
|
|
16075
16955
|
return pointer;
|
|
16076
16956
|
}
|
|
16077
16957
|
function validateRecording(value, scenarioPath) {
|
|
@@ -16310,30 +17190,30 @@ function parseAudioArgs(argv) {
|
|
|
16310
17190
|
}
|
|
16311
17191
|
var CLIP_KEYS = /* @__PURE__ */ new Set(["bands", "loop", "path", "peakMax", "seamMaxRatio", "silenceRms"]);
|
|
16312
17192
|
var MANIFEST_KEYS = /* @__PURE__ */ new Set(["clips", "version"]);
|
|
16313
|
-
function parseAudioManifest(text,
|
|
17193
|
+
function parseAudioManifest(text, path2) {
|
|
16314
17194
|
let raw;
|
|
16315
17195
|
try {
|
|
16316
17196
|
raw = JSON.parse(text);
|
|
16317
17197
|
} catch (error) {
|
|
16318
17198
|
const message = error instanceof Error ? error.message : String(error);
|
|
16319
|
-
throw new PlaytestCliUsageError(`audio: ${
|
|
17199
|
+
throw new PlaytestCliUsageError(`audio: ${path2} is not valid JSON: ${message}`);
|
|
16320
17200
|
}
|
|
16321
|
-
if (!
|
|
16322
|
-
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");
|
|
16323
17203
|
if (raw.version !== 1)
|
|
16324
17204
|
throw new PlaytestCliUsageError(
|
|
16325
|
-
`audio: ${
|
|
17205
|
+
`audio: ${path2} declares version ${JSON.stringify(raw.version)}; this inspector implements version 1.`
|
|
16326
17206
|
);
|
|
16327
17207
|
if (!Array.isArray(raw.clips))
|
|
16328
|
-
throw new PlaytestCliUsageError(`audio: ${
|
|
17208
|
+
throw new PlaytestCliUsageError(`audio: ${path2} must carry a "clips" array.`);
|
|
16329
17209
|
if (raw.clips.length === 0)
|
|
16330
17210
|
throw new PlaytestCliUsageError(
|
|
16331
|
-
`audio: ${
|
|
17211
|
+
`audio: ${path2} declares no clips; a manifest must assert at least one clip.`
|
|
16332
17212
|
);
|
|
16333
17213
|
const seen = /* @__PURE__ */ new Set();
|
|
16334
17214
|
const clips = raw.clips.map((entry, index) => {
|
|
16335
|
-
const where = `${
|
|
16336
|
-
if (!
|
|
17215
|
+
const where = `${path2} clips[${String(index)}]`;
|
|
17216
|
+
if (!isRecord6(entry)) throw new PlaytestCliUsageError(`audio: ${where} must be an object.`);
|
|
16337
17217
|
rejectUnknown(entry, CLIP_KEYS, where, "clip");
|
|
16338
17218
|
const clipPath = entry.path;
|
|
16339
17219
|
if (typeof clipPath !== "string" || clipPath.length === 0)
|
|
@@ -16361,7 +17241,7 @@ function parseAudioManifest(text, path) {
|
|
|
16361
17241
|
return { clips, version: 1 };
|
|
16362
17242
|
}
|
|
16363
17243
|
function parseBands(raw, where) {
|
|
16364
|
-
if (!
|
|
17244
|
+
if (!isRecord6(raw)) throw new PlaytestCliUsageError(`audio: ${where} "bands" must be an object.`);
|
|
16365
17245
|
const bands = {};
|
|
16366
17246
|
for (const [name, bound] of Object.entries(raw)) {
|
|
16367
17247
|
if (!BAND_NAMES.includes(name)) {
|
|
@@ -16369,7 +17249,7 @@ function parseBands(raw, where) {
|
|
|
16369
17249
|
`audio: ${where} names band "${name}"; the measured bands are ${BAND_NAMES.join(", ")}.`
|
|
16370
17250
|
);
|
|
16371
17251
|
}
|
|
16372
|
-
if (!
|
|
17252
|
+
if (!isRecord6(bound))
|
|
16373
17253
|
throw new PlaytestCliUsageError(`audio: ${where} band "${name}" must be an object.`);
|
|
16374
17254
|
rejectUnknown(bound, /* @__PURE__ */ new Set(["max", "min"]), `${where} band "${name}"`, "bound");
|
|
16375
17255
|
const min = bound.min === void 0 ? void 0 : percent(bound.min, `${where} band "${name}" min`);
|
|
@@ -16412,7 +17292,7 @@ function positive(value, where) {
|
|
|
16412
17292
|
throw new PlaytestCliUsageError(`audio: ${where} must be a finite positive number.`);
|
|
16413
17293
|
return value;
|
|
16414
17294
|
}
|
|
16415
|
-
function
|
|
17295
|
+
function isRecord6(value) {
|
|
16416
17296
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16417
17297
|
}
|
|
16418
17298
|
function analyseSamples(channels, sampleRate) {
|
|
@@ -16517,9 +17397,9 @@ function measureSeam(channels, sampleRate) {
|
|
|
16517
17397
|
wrap
|
|
16518
17398
|
};
|
|
16519
17399
|
}
|
|
16520
|
-
function checkClip(
|
|
17400
|
+
function checkClip(path2, analysis, expectation) {
|
|
16521
17401
|
const checks = [];
|
|
16522
|
-
const label = (name) => `${
|
|
17402
|
+
const label = (name) => `${path2} ${name}`;
|
|
16523
17403
|
const silenceRms = expectation.silenceRms ?? DEFAULT_SILENCE_RMS;
|
|
16524
17404
|
if (analysis.rms < silenceRms) {
|
|
16525
17405
|
checks.push({
|
|
@@ -16628,7 +17508,7 @@ function formatAudioReport(report) {
|
|
|
16628
17508
|
if (pictures.length > 0) {
|
|
16629
17509
|
lines.push("");
|
|
16630
17510
|
lines.push("spectrograms:");
|
|
16631
|
-
for (const { path, spectrogram } of pictures) lines.push(` ${
|
|
17511
|
+
for (const { path: path2, spectrogram } of pictures) lines.push(` ${path2} -> ${String(spectrogram)}`);
|
|
16632
17512
|
}
|
|
16633
17513
|
const failed = report.checks.filter(({ status }) => status === "fail").length;
|
|
16634
17514
|
lines.push("");
|
|
@@ -16893,16 +17773,16 @@ async function inspectAudio(args) {
|
|
|
16893
17773
|
if (args.dir !== void 0) checks.push(await coverageCheck(args.root, args.dir, manifest.clips));
|
|
16894
17774
|
return { checks, clips, pass: !checks.some(({ status }) => status === "fail") };
|
|
16895
17775
|
}
|
|
16896
|
-
async function readManifest(
|
|
17776
|
+
async function readManifest(path2) {
|
|
16897
17777
|
try {
|
|
16898
|
-
return await readFile(
|
|
17778
|
+
return await readFile(path2, "utf8");
|
|
16899
17779
|
} catch {
|
|
16900
|
-
throw new PlaytestCliUsageError(`audio: cannot read the expectation manifest at ${
|
|
17780
|
+
throw new PlaytestCliUsageError(`audio: cannot read the expectation manifest at ${path2}.`);
|
|
16901
17781
|
}
|
|
16902
17782
|
}
|
|
16903
17783
|
async function coverageCheck(root, dir, clips) {
|
|
16904
17784
|
const base = resolve(root, dir);
|
|
16905
|
-
const declared = new Set(clips.map(({ path }) => resolve(root,
|
|
17785
|
+
const declared = new Set(clips.map(({ path: path2 }) => resolve(root, path2)));
|
|
16906
17786
|
let found;
|
|
16907
17787
|
try {
|
|
16908
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));
|
|
@@ -16914,7 +17794,7 @@ async function coverageCheck(root, dir, clips) {
|
|
|
16914
17794
|
status: "fail"
|
|
16915
17795
|
};
|
|
16916
17796
|
}
|
|
16917
|
-
const undeclared = found.filter((
|
|
17797
|
+
const undeclared = found.filter((path2) => !declared.has(path2)).map((path2) => relative(root, path2));
|
|
16918
17798
|
if (undeclared.length > 0) {
|
|
16919
17799
|
return {
|
|
16920
17800
|
detail: `${String(undeclared.length)} audio file(s) in ${dir} are not declared: ${undeclared.sort().join(", ")}`,
|
|
@@ -16938,8 +17818,8 @@ async function assertDecoder() {
|
|
|
16938
17818
|
);
|
|
16939
17819
|
}
|
|
16940
17820
|
}
|
|
16941
|
-
async function decodeAudio(
|
|
16942
|
-
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", "-"]);
|
|
16943
17823
|
return parseWav(wav);
|
|
16944
17824
|
}
|
|
16945
17825
|
function parseWav(wav) {
|
|
@@ -17667,6 +18547,20 @@ function classifyRunnerError(error, options = {}) {
|
|
|
17667
18547
|
};
|
|
17668
18548
|
}
|
|
17669
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
|
+
}
|
|
17670
18564
|
if (message.startsWith("TN_PLAYTEST_DEVICE_FAILED")) {
|
|
17671
18565
|
return diagnostic(
|
|
17672
18566
|
"TN_PLAYTEST_DEVICE_FAILED",
|
|
@@ -17821,7 +18715,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
17821
18715
|
if (argv[0] === "record-to-scenario") {
|
|
17822
18716
|
return await recordToScenarioCommand(argv.slice(1));
|
|
17823
18717
|
}
|
|
17824
|
-
config = parseStandalonePlaytestArgs(argv);
|
|
18718
|
+
config = await resolveBuildReport(parseStandalonePlaytestArgs(argv));
|
|
17825
18719
|
assertCpuProfileTargetSupported(config.target ?? "browser", config.cpuProfilePath);
|
|
17826
18720
|
const scenarioPaths = config.scenarioPaths ?? [config.scenarioPath];
|
|
17827
18721
|
const reports = config.target === "browser" ? config.device === void 0 ? await runStandalonePlaytests(config) : await runAndroidBrowserPlaytests(config) : await runDevicePlaytests(config, scenarioPaths);
|
|
@@ -17906,8 +18800,8 @@ function diagnostic(code, message, instruction) {
|
|
|
17906
18800
|
function scenarioUnreadable(message, options) {
|
|
17907
18801
|
const cwd = options.cwd ?? process.cwd();
|
|
17908
18802
|
const candidate = options.scenarioPath ?? /Playtest scenario ['"]([^'"]+)['"]/u.exec(message)?.[1] ?? /(?:open|read) ['"]([^'"]+)['"]/u.exec(message)?.[1];
|
|
17909
|
-
const
|
|
17910
|
-
const printedPath =
|
|
18803
|
+
const path2 = candidate === void 0 ? void 0 : resolve(cwd, candidate);
|
|
18804
|
+
const printedPath = path2 ?? "the requested scenario path";
|
|
17911
18805
|
return diagnostic(
|
|
17912
18806
|
"TN_PLAYTEST_SCENARIO_UNREADABLE",
|
|
17913
18807
|
`${message} Resolved absolute path: ${printedPath}.`,
|