@threenative/playtest 0.3.1 → 0.3.3
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/{diagnostics-f8464bJw.d.ts → diagnostics-Bpy15z5f.d.ts} +42 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +253 -49
- package/dist/protocol.d.ts +32 -1
- package/dist/protocol.js +2 -1
- package/dist/runner/cli.d.ts +2 -2
- package/dist/runner/cli.js +843 -312
- package/dist/runner/index.d.ts +19 -6
- package/dist/runner/index.js +602 -92
- package/dist/{shared-BGwYk5HG.d.ts → shared-eFOF5bZO.d.ts} +9 -1
- package/dist/three/index.js +4 -1
- package/package.json +1 -1
package/dist/runner/cli.js
CHANGED
|
@@ -288,6 +288,9 @@ function requiredPlaytestCapabilities(scenario, target) {
|
|
|
288
288
|
if (scenario.steps.some((step) => step.kind === "aimAt")) {
|
|
289
289
|
required.add("entity.setup");
|
|
290
290
|
}
|
|
291
|
+
if (scenario.assert?.geometry !== void 0) {
|
|
292
|
+
required.add("runtime.geometry");
|
|
293
|
+
}
|
|
291
294
|
if (scenario.artifacts?.screenshots !== false) {
|
|
292
295
|
required.add("browser.screenshot");
|
|
293
296
|
}
|
|
@@ -623,14 +626,16 @@ var init_assertion_schema = __esm({
|
|
|
623
626
|
trivialityRationale: "It evaluates captured error and readiness channels across the run; no initial scalar value can satisfy those diagnostics by itself."
|
|
624
627
|
},
|
|
625
628
|
{
|
|
626
|
-
description: "Proves a live render sample exists and optionally bounds frame time, an fps floor, per-phase frame budget, draw calls
|
|
627
|
-
example: { performance: { maxPhaseMsP95: { render: 12 }, minFps: 30 } },
|
|
629
|
+
description: "Proves a live render sample exists and optionally bounds frame time, an fps floor, per-phase frame budget, whole-frame or per-pass draw calls and triangles.",
|
|
630
|
+
example: { performance: { maxPassDrawCalls: { shadow: 400 }, maxPhaseMsP95: { render: 12 }, minFps: 30 } },
|
|
628
631
|
fields: [
|
|
629
632
|
{ description: "Maximum nearest-rank 95th-percentile frame time in milliseconds.", name: "maxFrameMsP95", type: "number" },
|
|
630
633
|
{ description: "Minimum sustained frames per second, from the median sampled frame.", name: "minFps", type: "number" },
|
|
631
634
|
{ description: "Per-phase millisecond ceilings at nearest-rank p95. Phases: hostGap, update, render, overlay, residual.", name: "maxPhaseMsP95", type: "{ [phase]: number }" },
|
|
632
|
-
{ description: "Maximum observed renderer draw-call count.", name: "maxDrawCalls", type: "number" },
|
|
633
|
-
{ description: "
|
|
635
|
+
{ description: "Maximum observed renderer draw-call count across every pass combined.", name: "maxDrawCalls", type: "number" },
|
|
636
|
+
{ description: "Per-pass draw-call ceilings, keyed by pass kind: main, shadow, reflection, nested. Fails closed when a sampled frame carries no pass split or omits the declared kind.", name: "maxPassDrawCalls", type: "{ [pass: 'main' | 'shadow' | 'reflection' | 'nested']: number }" },
|
|
637
|
+
{ description: "Per-pass triangle ceilings, keyed by pass kind: main, shadow, reflection, nested. Fails closed when a sampled frame carries no pass split or omits the declared kind.", name: "maxPassTriangles", type: "{ [pass: 'main' | 'shadow' | 'reflection' | 'nested']: number }" },
|
|
638
|
+
{ description: "Maximum observed renderer triangle count across every pass combined.", name: "maxTriangles", type: "number" }
|
|
634
639
|
],
|
|
635
640
|
cardinality: "object",
|
|
636
641
|
kind: "performance",
|
|
@@ -679,6 +684,24 @@ var init_assertion_schema = __esm({
|
|
|
679
684
|
triviality: "reject-initial-value",
|
|
680
685
|
trivialityRationale: "An entity can be present and in-frame before input; the scenario must prove visibility after its setup or document why that presence is held."
|
|
681
686
|
},
|
|
687
|
+
{
|
|
688
|
+
description: "Proves which labelled audio cues the game actually played, and how often.",
|
|
689
|
+
example: { audio: [{ cue: "speech:p01", maxPlays: 1 }] },
|
|
690
|
+
fields: [
|
|
691
|
+
{ description: "Cue label the game passed to AudioBus.play/playAt.", name: "cue", required: true, type: "string" },
|
|
692
|
+
{ description: "Fewest plays required. Defaults to 1, so naming a cue asserts it was heard.", name: "minPlays", type: "non-negative integer" },
|
|
693
|
+
{ description: "Most plays allowed; 0 proves silence and 1 proves a one-shot stayed one.", name: "maxPlays", type: "non-negative integer" },
|
|
694
|
+
{ description: "Fewest milliseconds between this cue and the cue played before it, so one line cannot cut another.", name: "minGapMs", type: "non-negative integer" }
|
|
695
|
+
],
|
|
696
|
+
cardinality: "array",
|
|
697
|
+
kind: "audio",
|
|
698
|
+
observationPath: "runtimeObservations",
|
|
699
|
+
requiredCapabilities: ["runtime.audio"],
|
|
700
|
+
resultIdPrefix: "audio.",
|
|
701
|
+
supportedOn: ["web", "desktop"],
|
|
702
|
+
triviality: "not-applicable",
|
|
703
|
+
trivialityRationale: "A cue count starts at zero and only a played cue moves it, so there is no initial value to reject."
|
|
704
|
+
},
|
|
682
705
|
{
|
|
683
706
|
description: "Proves runtime world metadata exposed by the application bridge.",
|
|
684
707
|
example: { world: { seed: 90210 } },
|
|
@@ -1557,6 +1580,53 @@ function contactAssertionSatisfiedAtStep(assertion, observations, scenario) {
|
|
|
1557
1580
|
const minimum = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1558
1581
|
return stepAvailable && (!anonymous || candidates.length > 0) && count >= minimum && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
1559
1582
|
}
|
|
1583
|
+
function smallestGapBefore(recent, cue) {
|
|
1584
|
+
let smallest;
|
|
1585
|
+
for (let index = 1; index < recent.length; index += 1) {
|
|
1586
|
+
const entry = recent[index];
|
|
1587
|
+
const previous = recent[index - 1];
|
|
1588
|
+
if (!isRecord(entry) || !isRecord(previous)) continue;
|
|
1589
|
+
if (entry.cue !== cue) continue;
|
|
1590
|
+
if (typeof entry.atMs !== "number" || typeof previous.atMs !== "number") continue;
|
|
1591
|
+
const gap = entry.atMs - previous.atMs;
|
|
1592
|
+
if (smallest === void 0 || gap < smallest) smallest = gap;
|
|
1593
|
+
}
|
|
1594
|
+
return smallest;
|
|
1595
|
+
}
|
|
1596
|
+
function evaluateAudioAssertion(assertion, observations) {
|
|
1597
|
+
const gameplay = gameplayObservations(observations);
|
|
1598
|
+
const audio = isRecord(gameplay?.audio) ? gameplay.audio : void 0;
|
|
1599
|
+
const cues = isRecord(audio?.cues) ? audio.cues : void 0;
|
|
1600
|
+
const observed = cues === void 0 ? void 0 : cues[assertion.cue];
|
|
1601
|
+
const plays = typeof observed === "number" ? observed : 0;
|
|
1602
|
+
const minimum = assertion.minPlays ?? 1;
|
|
1603
|
+
const recent = Array.isArray(audio?.recentCues) ? audio.recentCues : [];
|
|
1604
|
+
const gap = smallestGapBefore(recent, assertion.cue);
|
|
1605
|
+
const gapPass = assertion.minGapMs === void 0 || gap === void 0 || gap >= assertion.minGapMs;
|
|
1606
|
+
const pass = cues !== void 0 && plays >= minimum && (assertion.maxPlays === void 0 || plays <= assertion.maxPlays) && gapPass;
|
|
1607
|
+
const result = {
|
|
1608
|
+
details: {
|
|
1609
|
+
cue: assertion.cue,
|
|
1610
|
+
maxPlays: assertion.maxPlays ?? null,
|
|
1611
|
+
minGapMs: assertion.minGapMs ?? null,
|
|
1612
|
+
minPlays: minimum,
|
|
1613
|
+
observed: cues === void 0 ? null : plays,
|
|
1614
|
+
observedGapMs: gap ?? null
|
|
1615
|
+
},
|
|
1616
|
+
id: `audio.${assertion.cue}`,
|
|
1617
|
+
pass
|
|
1618
|
+
};
|
|
1619
|
+
return pass ? { assertion: result } : {
|
|
1620
|
+
assertion: result,
|
|
1621
|
+
diagnostic: {
|
|
1622
|
+
code: "TN_PLAYTEST_AUDIO_ASSERTION_FAILED",
|
|
1623
|
+
message: cues === void 0 ? `No runtime audio ledger was published, so cue '${assertion.cue}' cannot be proved either way.` : gapPass ? `Cue '${assertion.cue}' played ${plays} time(s); expected at least ${minimum}${assertion.maxPlays === void 0 ? "" : ` and at most ${assertion.maxPlays}`}.` : `Cue '${assertion.cue}' started ${gap ?? 0} ms after the line before it, which is under the ${String(assertion.minGapMs)} ms it needs; one of them was cut off.`,
|
|
1624
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/audio/cues",
|
|
1625
|
+
severity: "error",
|
|
1626
|
+
suggestion: cues === void 0 ? "Run on a target whose bridge advertises runtime.audio, and pass `cue` to AudioBus.play/playAt for the lines under test." : "Read observations.json/runtimeObservations/gameplay/audio/recentCues for when each play happened, and check the one-shot flag that gates the cue."
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1560
1630
|
function evaluateWorldAssertion(assertion, observations) {
|
|
1561
1631
|
const gameplay = gameplayObservations(observations);
|
|
1562
1632
|
const world = isRecord(gameplay?.world) ? gameplay.world : void 0;
|
|
@@ -1735,6 +1805,51 @@ var init_families_observation = __esm({
|
|
|
1735
1805
|
}
|
|
1736
1806
|
});
|
|
1737
1807
|
|
|
1808
|
+
// src/protocol.ts
|
|
1809
|
+
function jsonByteLength(value) {
|
|
1810
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1811
|
+
}
|
|
1812
|
+
function assertJsonSafe(value, path = "$") {
|
|
1813
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
if (typeof value === "number") {
|
|
1817
|
+
if (Number.isFinite(value)) {
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
1821
|
+
}
|
|
1822
|
+
if (Array.isArray(value)) {
|
|
1823
|
+
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
if (typeof value === "object") {
|
|
1827
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1828
|
+
assertJsonSafe(item, `${path}.${key}`);
|
|
1829
|
+
}
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
throw new TypeError(`${path} must be JSON-safe.`);
|
|
1833
|
+
}
|
|
1834
|
+
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
|
+
var init_protocol = __esm({
|
|
1836
|
+
"src/protocol.ts"() {
|
|
1837
|
+
PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
1838
|
+
PLAYTEST_PROTOCOL_VERSION = 1;
|
|
1839
|
+
PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
1840
|
+
PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
1841
|
+
PLAYTEST_PROTOCOL_LIMITS = {
|
|
1842
|
+
maxEntitiesPerSample: 100,
|
|
1843
|
+
maxEventsPerDrain: 1e3,
|
|
1844
|
+
maxPayloadBytes: 1e6,
|
|
1845
|
+
operationTimeoutMs: 5e3
|
|
1846
|
+
};
|
|
1847
|
+
PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
1848
|
+
PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
1849
|
+
PLAYTEST_FRAME_PASS_KINDS = ["main", "shadow", "reflection", "nested"];
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
|
|
1738
1853
|
// src/evaluators/render-evidence.ts
|
|
1739
1854
|
function projectedPixelsForEntity(snapshot, entity, viewport) {
|
|
1740
1855
|
const rendered = renderedEntity(snapshot, entity);
|
|
@@ -1857,13 +1972,47 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1857
1972
|
samplesPass && triangles.length === samples.length && maxObservedTriangles !== void 0 && maxObservedTriangles <= assertion.maxTriangles
|
|
1858
1973
|
);
|
|
1859
1974
|
}
|
|
1975
|
+
const addPassBound = (unit, kind, ceiling) => {
|
|
1976
|
+
const noun = unit === "draws" ? "draw calls" : "triangles";
|
|
1977
|
+
const measured = observed.flatMap((sample) => {
|
|
1978
|
+
const pass2 = sample.passes?.find((candidate) => candidate.kind === kind);
|
|
1979
|
+
return pass2 === void 0 ? [] : [pass2[unit]];
|
|
1980
|
+
});
|
|
1981
|
+
const actual = measured.length === samples.length ? Math.max(...measured) : void 0;
|
|
1982
|
+
const id = unit === "draws" ? `performance.maxPassDrawCalls.${kind}` : `performance.maxPassTriangles.${kind}`;
|
|
1983
|
+
const pass = samplesPass && actual !== void 0 && actual <= ceiling;
|
|
1984
|
+
results.push({
|
|
1985
|
+
details: { actual: actual ?? null, expected: ceiling, pass: kind, sampleCount: samples.length, unit: noun },
|
|
1986
|
+
id,
|
|
1987
|
+
pass
|
|
1988
|
+
});
|
|
1989
|
+
if (!pass) diagnostics.push({
|
|
1990
|
+
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1991
|
+
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: path,
|
|
1993
|
+
severity: "error",
|
|
1994
|
+
sourcePath,
|
|
1995
|
+
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."
|
|
1996
|
+
});
|
|
1997
|
+
};
|
|
1998
|
+
for (const [kind, ceiling] of Object.entries(assertion.maxPassDrawCalls ?? {}))
|
|
1999
|
+
addPassBound("draws", kind, ceiling);
|
|
2000
|
+
for (const [kind, ceiling] of Object.entries(assertion.maxPassTriangles ?? {}))
|
|
2001
|
+
addPassBound("triangles", kind, ceiling);
|
|
1860
2002
|
return { assertions: results, diagnostics };
|
|
1861
2003
|
}
|
|
1862
2004
|
function isRuntimeDiagnosticsSample(value) {
|
|
1863
2005
|
if (!isRecord(value) || typeof value.frameMs !== "number" || !Number.isFinite(value.frameMs) || value.frameMs <= 0) {
|
|
1864
2006
|
return false;
|
|
1865
2007
|
}
|
|
1866
|
-
return (value.drawCalls === void 0 || typeof value.drawCalls === "number" && Number.isFinite(value.drawCalls) && value.drawCalls >= 0) && (value.triangles === void 0 || typeof value.triangles === "number" && Number.isFinite(value.triangles) && value.triangles >= 0) && isFramePhaseSplit(value.phases);
|
|
2008
|
+
return (value.drawCalls === void 0 || typeof value.drawCalls === "number" && Number.isFinite(value.drawCalls) && value.drawCalls >= 0) && (value.triangles === void 0 || typeof value.triangles === "number" && Number.isFinite(value.triangles) && value.triangles >= 0) && isFramePhaseSplit(value.phases) && isFramePassSplit(value.passes);
|
|
2009
|
+
}
|
|
2010
|
+
function isFramePassSplit(value) {
|
|
2011
|
+
if (value === void 0) return true;
|
|
2012
|
+
if (!Array.isArray(value)) return false;
|
|
2013
|
+
return value.every(
|
|
2014
|
+
(pass) => isRecord(pass) && PLAYTEST_FRAME_PASS_KINDS.includes(pass.kind) && typeof pass.draws === "number" && Number.isFinite(pass.draws) && pass.draws >= 0 && typeof pass.triangles === "number" && Number.isFinite(pass.triangles) && pass.triangles >= 0
|
|
2015
|
+
);
|
|
1867
2016
|
}
|
|
1868
2017
|
function isFramePhaseSplit(value) {
|
|
1869
2018
|
if (value === void 0) return true;
|
|
@@ -2042,6 +2191,7 @@ function minimumResolvedDistance(effectLog, effectLogSeries, entityId, target, b
|
|
|
2042
2191
|
}
|
|
2043
2192
|
var init_render_evidence = __esm({
|
|
2044
2193
|
"src/evaluators/render-evidence.ts"() {
|
|
2194
|
+
init_protocol();
|
|
2045
2195
|
init_measures();
|
|
2046
2196
|
init_assertion_report();
|
|
2047
2197
|
}
|
|
@@ -3134,6 +3284,11 @@ function emitPerfSignalsWorld(ctx) {
|
|
|
3134
3284
|
suggestion: "Expose a bounded events callback on the playtest bridge and inspect the emitted signal name and entity."
|
|
3135
3285
|
});
|
|
3136
3286
|
}
|
|
3287
|
+
for (const assertion of scenarioAssertions.audio ?? []) {
|
|
3288
|
+
const result = evaluateAudioAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
3289
|
+
assertions.push(result.assertion);
|
|
3290
|
+
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
3291
|
+
}
|
|
3137
3292
|
if (scenarioAssertions.world !== void 0) {
|
|
3138
3293
|
const result = evaluateWorldAssertion(scenarioAssertions.world, input.report.observations?.runtimeObservations);
|
|
3139
3294
|
assertions.push(result.assertion);
|
|
@@ -4373,6 +4528,19 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
4373
4528
|
emitRenderChain(ctx);
|
|
4374
4529
|
emitScene(ctx);
|
|
4375
4530
|
emitSceneNodes(ctx);
|
|
4531
|
+
if (scenarioAssertions.geometry !== void 0) {
|
|
4532
|
+
const observed = input.report.observations?.geometry;
|
|
4533
|
+
const status = observed?.status;
|
|
4534
|
+
const pass = status === "captured";
|
|
4535
|
+
assertions.push({ details: { observed, status }, id: "geometry.observed", pass });
|
|
4536
|
+
if (!pass) diagnostics.push({
|
|
4537
|
+
code: "TN_PLAYTEST_GEOMETRY_UNOBSERVED",
|
|
4538
|
+
message: "A geometry assertion was evaluated against a run whose bridge reported no captured geometry frame.",
|
|
4539
|
+
observedRuntimePath: "observations.json/geometry",
|
|
4540
|
+
severity: "error",
|
|
4541
|
+
suggestion: "Request the capture on a target whose bridge advertises runtime.geometry and is presenting world frames."
|
|
4542
|
+
});
|
|
4543
|
+
}
|
|
4376
4544
|
emitCausedBy(ctx);
|
|
4377
4545
|
emitStartup(ctx);
|
|
4378
4546
|
emitMovementEvidence(ctx);
|
|
@@ -4412,50 +4580,6 @@ var init_assertions = __esm({
|
|
|
4412
4580
|
init_assertion_schema();
|
|
4413
4581
|
}
|
|
4414
4582
|
});
|
|
4415
|
-
|
|
4416
|
-
// src/protocol.ts
|
|
4417
|
-
function jsonByteLength(value) {
|
|
4418
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
4419
|
-
}
|
|
4420
|
-
function assertJsonSafe(value, path = "$") {
|
|
4421
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
4422
|
-
return;
|
|
4423
|
-
}
|
|
4424
|
-
if (typeof value === "number") {
|
|
4425
|
-
if (Number.isFinite(value)) {
|
|
4426
|
-
return;
|
|
4427
|
-
}
|
|
4428
|
-
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
4429
|
-
}
|
|
4430
|
-
if (Array.isArray(value)) {
|
|
4431
|
-
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
4432
|
-
return;
|
|
4433
|
-
}
|
|
4434
|
-
if (typeof value === "object") {
|
|
4435
|
-
for (const [key, item] of Object.entries(value)) {
|
|
4436
|
-
assertJsonSafe(item, `${path}.${key}`);
|
|
4437
|
-
}
|
|
4438
|
-
return;
|
|
4439
|
-
}
|
|
4440
|
-
throw new TypeError(`${path} must be JSON-safe.`);
|
|
4441
|
-
}
|
|
4442
|
-
var PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, PLAYTEST_FRAME_BUDGET_PHASES;
|
|
4443
|
-
var init_protocol = __esm({
|
|
4444
|
-
"src/protocol.ts"() {
|
|
4445
|
-
PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
4446
|
-
PLAYTEST_PROTOCOL_VERSION = 1;
|
|
4447
|
-
PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
4448
|
-
PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
4449
|
-
PLAYTEST_PROTOCOL_LIMITS = {
|
|
4450
|
-
maxEntitiesPerSample: 100,
|
|
4451
|
-
maxEventsPerDrain: 1e3,
|
|
4452
|
-
maxPayloadBytes: 1e6,
|
|
4453
|
-
operationTimeoutMs: 5e3
|
|
4454
|
-
};
|
|
4455
|
-
PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
4456
|
-
PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
4457
|
-
}
|
|
4458
|
-
});
|
|
4459
4583
|
var NUMERIC_COMPARISON_KEYS, MIN_TRIVIALITY_REASON_LENGTH;
|
|
4460
4584
|
var init_schema_base = __esm({
|
|
4461
4585
|
"src/scenario/schema-base.ts"() {
|
|
@@ -4598,6 +4722,8 @@ var init_generated_assertion_validators = __esm({
|
|
|
4598
4722
|
"minFps": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4599
4723
|
"maxPhaseMsP95": (value) => isRecord2(value),
|
|
4600
4724
|
"maxDrawCalls": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4725
|
+
"maxPassDrawCalls": (value) => isRecord2(value),
|
|
4726
|
+
"maxPassTriangles": (value) => isRecord2(value),
|
|
4601
4727
|
"maxTriangles": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4602
4728
|
}),
|
|
4603
4729
|
"parity": Object.freeze({
|
|
@@ -4614,6 +4740,12 @@ var init_generated_assertion_validators = __esm({
|
|
|
4614
4740
|
"present": (value) => typeof value === "boolean",
|
|
4615
4741
|
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4616
4742
|
}),
|
|
4743
|
+
"audio": Object.freeze({
|
|
4744
|
+
"cue": (value) => typeof value === "string" && value.trim() !== "",
|
|
4745
|
+
"minPlays": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4746
|
+
"maxPlays": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4747
|
+
"minGapMs": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0
|
|
4748
|
+
}),
|
|
4617
4749
|
"world": Object.freeze({
|
|
4618
4750
|
"seed": (value) => true,
|
|
4619
4751
|
"runtime": (value) => isRecord2(value)
|
|
@@ -4919,10 +5051,12 @@ function validateDeviceMetricsAssertion(value, scenarioPath, objectPath) {
|
|
|
4919
5051
|
}
|
|
4920
5052
|
function validatePerformanceAssertion(value, scenarioPath, objectPath) {
|
|
4921
5053
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
4922
|
-
rejectUnknownKeys(record4, ["maxDrawCalls", "maxFrameMsP95", "maxPhaseMsP95", "maxTriangles", "minFps"], scenarioPath, objectPath);
|
|
5054
|
+
rejectUnknownKeys(record4, ["maxDrawCalls", "maxFrameMsP95", "maxPassDrawCalls", "maxPassTriangles", "maxPhaseMsP95", "maxTriangles", "minFps"], scenarioPath, objectPath);
|
|
4923
5055
|
return {
|
|
4924
5056
|
...present("maxDrawCalls", optionalNonNegativeNumber(record4, "maxDrawCalls", scenarioPath, objectPath)),
|
|
4925
5057
|
...present("maxFrameMsP95", optionalNonNegativeNumber(record4, "maxFrameMsP95", scenarioPath, objectPath)),
|
|
5058
|
+
...present("maxPassDrawCalls", validatePassBudget(record4.maxPassDrawCalls, scenarioPath, `${objectPath}.maxPassDrawCalls`)),
|
|
5059
|
+
...present("maxPassTriangles", validatePassBudget(record4.maxPassTriangles, scenarioPath, `${objectPath}.maxPassTriangles`)),
|
|
4926
5060
|
...present("maxPhaseMsP95", validatePhaseBudget(record4.maxPhaseMsP95, scenarioPath, `${objectPath}.maxPhaseMsP95`)),
|
|
4927
5061
|
...present("maxTriangles", optionalNonNegativeNumber(record4, "maxTriangles", scenarioPath, objectPath)),
|
|
4928
5062
|
...present("minFps", optionalNonNegativeNumber(record4, "minFps", scenarioPath, objectPath))
|
|
@@ -5058,6 +5192,25 @@ function validateStartupAssertion(value, scenarioPath, objectPath) {
|
|
|
5058
5192
|
}
|
|
5059
5193
|
return result;
|
|
5060
5194
|
}
|
|
5195
|
+
function validatePassBudget(value, scenarioPath, objectPath) {
|
|
5196
|
+
if (value === void 0) return void 0;
|
|
5197
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5198
|
+
const entries = Object.entries(record4);
|
|
5199
|
+
if (entries.length === 0)
|
|
5200
|
+
throw invalidScenario(scenarioPath, `${objectPath} must name at least one render pass.`);
|
|
5201
|
+
const budget = {};
|
|
5202
|
+
for (const [pass, ceiling] of entries) {
|
|
5203
|
+
if (!PLAYTEST_FRAME_PASS_KINDS.includes(pass))
|
|
5204
|
+
throw invalidScenario(
|
|
5205
|
+
scenarioPath,
|
|
5206
|
+
`${objectPath}.${pass} is not a render pass. Expected one of: ${PLAYTEST_FRAME_PASS_KINDS.join(", ")}.`
|
|
5207
|
+
);
|
|
5208
|
+
if (typeof ceiling !== "number" || !Number.isFinite(ceiling) || ceiling < 0)
|
|
5209
|
+
throw invalidScenario(scenarioPath, `${objectPath}.${pass} must be a non-negative number of draw calls or triangles.`);
|
|
5210
|
+
budget[pass] = ceiling;
|
|
5211
|
+
}
|
|
5212
|
+
return budget;
|
|
5213
|
+
}
|
|
5061
5214
|
function validatePhaseBudget(value, scenarioPath, objectPath) {
|
|
5062
5215
|
if (value === void 0) return void 0;
|
|
5063
5216
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
@@ -6168,14 +6321,16 @@ function validateStepLabels(steps, assertions, scenarioPath) {
|
|
|
6168
6321
|
}
|
|
6169
6322
|
}
|
|
6170
6323
|
function playtestStepHoldTicks(step, fallback = 1) {
|
|
6171
|
-
|
|
6324
|
+
const pointerHold = (step.pointers !== void 0 || step.pointerPosition !== void 0) && step.holdTicks !== void 0;
|
|
6325
|
+
if (step.press === void 0 && !pointerHold || step.holdFrames !== void 0 || step.waitFrames !== void 0)
|
|
6326
|
+
return 0;
|
|
6172
6327
|
return Math.max(1, step.holdTicks ?? fallback);
|
|
6173
6328
|
}
|
|
6174
6329
|
function playtestStepWaitTicks(step) {
|
|
6175
6330
|
return step.waitFrames === void 0 ? Math.max(0, step.waitTicks ?? 0) : 0;
|
|
6176
6331
|
}
|
|
6177
6332
|
function validateAssertions(value, scenarioPath) {
|
|
6178
|
-
rejectUnknownKeys(value, PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), scenarioPath, "assert");
|
|
6333
|
+
rejectUnknownKeys(value, [...PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), "geometry"], scenarioPath, "assert");
|
|
6179
6334
|
validateAssertionShapes(value, scenarioPath);
|
|
6180
6335
|
validateAssertionKeys(value, scenarioPath);
|
|
6181
6336
|
if (Array.isArray(value.signals) && value.signals.length === 0) {
|
|
@@ -6201,6 +6356,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6201
6356
|
const renderChain = value.renderChain === void 0 ? void 0 : validateRenderChainAssertion(value.renderChain, scenarioPath, "assert.renderChain");
|
|
6202
6357
|
const startup = value.startup === void 0 ? void 0 : validateStartupAssertion(value.startup, scenarioPath, "assert.startup");
|
|
6203
6358
|
const scene = value.scene === void 0 ? void 0 : validateSceneAssertion(value.scene, scenarioPath, "assert.scene");
|
|
6359
|
+
const geometry = value.geometry === void 0 ? void 0 : validateGeometryCaptureRequest(value.geometry, scenarioPath, "assert.geometry");
|
|
6204
6360
|
const world = isRecord3(value.world) ? value.world : void 0;
|
|
6205
6361
|
const optOuts = [
|
|
6206
6362
|
["noConsoleErrors", "consoleErrorsOptOutReason"],
|
|
@@ -6218,6 +6374,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6218
6374
|
return {
|
|
6219
6375
|
...Array.isArray(value.aerodynamics) ? { aerodynamics: value.aerodynamics.map((entry, index) => validateAerodynamicsAssertion(entry, scenarioPath, `assert.aerodynamics[${index}]`)) } : {},
|
|
6220
6376
|
...Array.isArray(value.animation) ? { animation: value.animation.map((entry, index) => validateAnimationAssertion(entry, scenarioPath, `assert.animation[${index}]`)) } : {},
|
|
6377
|
+
...Array.isArray(value.audio) ? { audio: value.audio.map((entry, index) => validateAudioAssertion(entry, scenarioPath, `assert.audio[${index}]`)) } : {},
|
|
6221
6378
|
...camera === void 0 ? {} : {
|
|
6222
6379
|
camera: {
|
|
6223
6380
|
...typeof camera.entity === "string" ? { entity: camera.entity } : {},
|
|
@@ -6250,6 +6407,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6250
6407
|
...renderChain === void 0 ? {} : { renderChain },
|
|
6251
6408
|
...startup === void 0 ? {} : { startup },
|
|
6252
6409
|
...scene === void 0 ? {} : { scene },
|
|
6410
|
+
...geometry === void 0 ? {} : { geometry },
|
|
6253
6411
|
...hasKey(value, "causedBy") ? {
|
|
6254
6412
|
causedBy: requireArray(value, "causedBy", scenarioPath, "assert.causedBy").map((entry, index) => validateCausedByAssertion(entry, scenarioPath, `assert.causedBy[${index}]`))
|
|
6255
6413
|
} : {},
|
|
@@ -6309,6 +6467,34 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6309
6467
|
...world === void 0 ? {} : { world: validateWorldAssertion(world, scenarioPath) }
|
|
6310
6468
|
};
|
|
6311
6469
|
}
|
|
6470
|
+
function validateAudioAssertion(value, scenarioPath, objectPath) {
|
|
6471
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
6472
|
+
rejectUnknownKeys(record4, ["cue", "maxPlays", "minGapMs", "minPlays"], scenarioPath, objectPath);
|
|
6473
|
+
if (typeof record4.cue !== "string" || record4.cue.trim() === "")
|
|
6474
|
+
throw invalidScenario(scenarioPath, `Assertion '${objectPath}.cue' must be a non-empty string.`);
|
|
6475
|
+
const bound = (name) => {
|
|
6476
|
+
const raw = record4[name];
|
|
6477
|
+
if (raw === void 0) return void 0;
|
|
6478
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0)
|
|
6479
|
+
throw invalidScenario(scenarioPath, `Assertion '${objectPath}.${name}' must be a non-negative integer.`);
|
|
6480
|
+
return raw;
|
|
6481
|
+
};
|
|
6482
|
+
const minPlays = bound("minPlays");
|
|
6483
|
+
const maxPlays = bound("maxPlays");
|
|
6484
|
+
const minGapMs = bound("minGapMs");
|
|
6485
|
+
if (minPlays !== void 0 && maxPlays !== void 0 && maxPlays < minPlays) {
|
|
6486
|
+
throw invalidScenario(
|
|
6487
|
+
scenarioPath,
|
|
6488
|
+
`Assertion '${objectPath}' cannot require at least ${minPlays} play(s) and at most ${maxPlays}.`
|
|
6489
|
+
);
|
|
6490
|
+
}
|
|
6491
|
+
return {
|
|
6492
|
+
cue: record4.cue,
|
|
6493
|
+
...maxPlays === void 0 ? {} : { maxPlays },
|
|
6494
|
+
...minGapMs === void 0 ? {} : { minGapMs },
|
|
6495
|
+
...minPlays === void 0 ? {} : { minPlays }
|
|
6496
|
+
};
|
|
6497
|
+
}
|
|
6312
6498
|
function validateWorldAssertion(value, scenarioPath) {
|
|
6313
6499
|
rejectUnknownKeys(value, ["runtime", "seed"], scenarioPath, "assert.world");
|
|
6314
6500
|
if (!hasKey(value, "seed") || value.seed !== null && (typeof value.seed !== "number" || !Number.isFinite(value.seed))) {
|
|
@@ -6475,6 +6661,24 @@ function validateOccludedAssertion(value, scenarioPath, objectPath) {
|
|
|
6475
6661
|
...present("target", optionalString(record4, "target", scenarioPath, objectPath))
|
|
6476
6662
|
};
|
|
6477
6663
|
}
|
|
6664
|
+
function validateGeometryCaptureRequest(value, scenarioPath, objectPath) {
|
|
6665
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
6666
|
+
rejectUnknownKeys(record4, ["limit", "sort", "timeoutMs"], scenarioPath, objectPath);
|
|
6667
|
+
if (record4.limit !== void 0 && (typeof record4.limit !== "number" || !Number.isInteger(record4.limit) || record4.limit < 1 || record4.limit > 500)) {
|
|
6668
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.limit' must be an integer from 1 to 500, received ${describeValue(record4.limit)}.`);
|
|
6669
|
+
}
|
|
6670
|
+
if (record4.sort !== void 0 && record4.sort !== "triangles" && record4.sort !== "draws" && record4.sort !== "projected") {
|
|
6671
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.sort' must be one of triangles, draws, projected, received ${describeValue(record4.sort)}.`);
|
|
6672
|
+
}
|
|
6673
|
+
if (record4.timeoutMs !== void 0 && (typeof record4.timeoutMs !== "number" || !Number.isFinite(record4.timeoutMs) || record4.timeoutMs <= 0)) {
|
|
6674
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.timeoutMs' must be a positive finite number, received ${describeValue(record4.timeoutMs)}.`);
|
|
6675
|
+
}
|
|
6676
|
+
return {
|
|
6677
|
+
...record4.limit === void 0 ? {} : { limit: record4.limit },
|
|
6678
|
+
...record4.sort === void 0 ? {} : { sort: record4.sort },
|
|
6679
|
+
...record4.timeoutMs === void 0 ? {} : { timeoutMs: record4.timeoutMs }
|
|
6680
|
+
};
|
|
6681
|
+
}
|
|
6478
6682
|
var PLAYTEST_ROOT_KEYS, PLAYTEST_STEP_KEYS, MAX_RESOURCE_WAIT_TIMEOUT_MS;
|
|
6479
6683
|
var init_schema_validate = __esm({
|
|
6480
6684
|
"src/scenario/schema-validate.ts"() {
|
|
@@ -7067,6 +7271,7 @@ var init_capabilities = __esm({
|
|
|
7067
7271
|
capability("runtime.diagnostics", "Captures application runtime errors."),
|
|
7068
7272
|
capability("runtime.events", "Drains bounded application event observations."),
|
|
7069
7273
|
capability("runtime.fixedStep", "Advances an application-owned deterministic tick."),
|
|
7274
|
+
capability("runtime.geometry", "Answers one armed per-object geometry capture for the frame it was requested on."),
|
|
7070
7275
|
capability("runtime.physics", "Samples bounded application-owned physics observations."),
|
|
7071
7276
|
capability("runtime.performance", "Samples bounded per-render frame cost and renderer counts."),
|
|
7072
7277
|
capability("runtime.pipelineCensus", "Samples bounded shader and pipeline creation observations."),
|
|
@@ -7114,6 +7319,8 @@ var init_index = __esm({
|
|
|
7114
7319
|
init_diagnostics();
|
|
7115
7320
|
init_protocol();
|
|
7116
7321
|
init_scenario();
|
|
7322
|
+
init_scenario();
|
|
7323
|
+
init_scenario();
|
|
7117
7324
|
}
|
|
7118
7325
|
});
|
|
7119
7326
|
|
|
@@ -7127,6 +7334,7 @@ var init_observationFields = __esm({
|
|
|
7127
7334
|
"console",
|
|
7128
7335
|
"effectLogBefore",
|
|
7129
7336
|
"framebufferCoverage",
|
|
7337
|
+
"geometry",
|
|
7130
7338
|
"hud",
|
|
7131
7339
|
"network",
|
|
7132
7340
|
"physicsDebugSeries",
|
|
@@ -7807,12 +8015,15 @@ var PLAYTEST_FLAGS = {
|
|
|
7807
8015
|
"--no-screenshots": { default: "false", summary: "skip the before/after artifact frames; scenarios that assert on a frame still capture one", takesValue: false },
|
|
7808
8016
|
"--browser-arg": { allowDashValue: true, default: "none (repeatable)", repeatable: true, summary: "one additional Chromium argument", takesValue: true },
|
|
7809
8017
|
"--browser-recipe": { default: "none", summary: "named browser recipe (webgpu)", takesValue: true },
|
|
8018
|
+
"--cpu-prof": { default: "none", summary: "write a Chrome DevTools .cpuprofile for this run (browser and desktop targets)", takesValue: true },
|
|
7810
8019
|
"--bundle-id": { default: "dev.threenative.runtime", summary: "iOS application bundle identifier", takesValue: true },
|
|
7811
8020
|
"--device": { default: "platform default", summary: "Android serial or iOS device identifier", takesValue: true },
|
|
7812
8021
|
"--executable": { default: "required for desktop", summary: "native desktop game executable", takesValue: true },
|
|
7813
8022
|
"--endpoint": { default: "http://127.0.0.1:41777/playtest", summary: "device bridge endpoint", takesValue: true },
|
|
7814
8023
|
"--headed": { default: "false", summary: "show the browser window", takesValue: false },
|
|
7815
|
-
|
|
8024
|
+
// `allowDashValue` so a host flag can be passed as one: `--host-arg --ui` is the UI root the
|
|
8025
|
+
// overlay serves, and the parser would otherwise read `--ui` as a playtest flag and reject it.
|
|
8026
|
+
"--host-arg": { allowDashValue: true, default: "none", repeatable: true, summary: "argument passed to the native desktop host, repeatable", takesValue: true },
|
|
7816
8027
|
"--mailbox-root": { default: "Android external files directory", summary: "native device mailbox directory", takesValue: true },
|
|
7817
8028
|
"--ios-transport": { default: "simulator", summary: "iOS transport (simulator or device)", takesValue: true },
|
|
7818
8029
|
"--project": { default: ".", summary: "project root used to resolve paths", takesValue: true },
|
|
@@ -7858,6 +8069,9 @@ function formatUsage() {
|
|
|
7858
8069
|
" with repeatable --host-arg, or --logcat <serial>",
|
|
7859
8070
|
" bounds: --max-frame-p95 <ms>, --min-fps <fps>",
|
|
7860
8071
|
" --require-windows <n> (default 2), --timeout <s>, --text",
|
|
8072
|
+
" --allow-virtual-display accepts a frame rate the display did not",
|
|
8073
|
+
" see (a private Xvfb, or a loop the presentation cap outran); without",
|
|
8074
|
+
" it such a run prints no fps column and refuses a --min-fps bound",
|
|
7861
8075
|
" trace record a Chrome performance trace of a running game and name the",
|
|
7862
8076
|
" functions inside its slow frames \u2014 a percentile says a frame was",
|
|
7863
8077
|
" slow, a trace says which function. Take one BEFORE attributing any",
|
|
@@ -7952,6 +8166,7 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
7952
8166
|
throw new PlaytestCliUsageError("Choose --browser-recipe or --browser-arg, not both.");
|
|
7953
8167
|
}
|
|
7954
8168
|
const device = flags.get("--device")?.[0];
|
|
8169
|
+
const cpuProfilePath = flags.get("--cpu-prof")?.[0];
|
|
7955
8170
|
if (target === "browser" && device !== void 0) {
|
|
7956
8171
|
if (browserRecipe !== void 0) {
|
|
7957
8172
|
throw new PlaytestCliUsageError("Android Chrome device runs cannot honor --browser-recipe; remove it.");
|
|
@@ -7994,6 +8209,7 @@ function parseStandalonePlaytestArgs(argv, cwd = process.cwd()) {
|
|
|
7994
8209
|
artifactDirectory: resolve(projectPath, flags.get("--artifacts")?.[0] ?? "artifacts/playtest"),
|
|
7995
8210
|
captureArtifactScreenshots: !argv.includes("--no-screenshots"),
|
|
7996
8211
|
...browserArgs.length === 0 ? {} : { browserArgs },
|
|
8212
|
+
...cpuProfilePath === void 0 ? {} : { cpuProfilePath: resolve(projectPath, cpuProfilePath) },
|
|
7997
8213
|
...device === void 0 ? {} : { device },
|
|
7998
8214
|
...executable === void 0 ? {} : {
|
|
7999
8215
|
desktop: {
|
|
@@ -8342,9 +8558,9 @@ var AdbAndroidDriver = class _AdbAndroidDriver {
|
|
|
8342
8558
|
const user = await this.resolveUser();
|
|
8343
8559
|
this.activeUser = user;
|
|
8344
8560
|
await this.adb(["reverse", `tcp:${port}`, `tcp:${port}`]);
|
|
8345
|
-
await this.adb(["logcat", "-c"]);
|
|
8346
8561
|
await this.adb(["shell", "am", "force-stop", "--user", user, this.options.packageName]);
|
|
8347
8562
|
if (viewport !== void 0) await this.presentViewport(viewport);
|
|
8563
|
+
await this.adb(["logcat", "-c"]);
|
|
8348
8564
|
await this.adb([
|
|
8349
8565
|
"shell",
|
|
8350
8566
|
"am",
|
|
@@ -9189,6 +9405,7 @@ function summariseScene(observation) {
|
|
|
9189
9405
|
const points = positions(entities);
|
|
9190
9406
|
const frames = (snapshot.runtimeDiagnosticsSeries ?? []).map(({ frameMs: frameMs2 }) => frameMs2);
|
|
9191
9407
|
const frameMs = median(frames);
|
|
9408
|
+
const passSplit = (snapshot.runtimeDiagnosticsSeries ?? []).at(-1)?.passes;
|
|
9192
9409
|
const world = snapshot.gameplay?.world;
|
|
9193
9410
|
const clips = Object.entries(snapshot.gameplay?.animation ?? {}).filter(([, animation]) => animation.advancedFrames > 0).map(([entity, animation]) => `${entity}: ${animation.clip}`);
|
|
9194
9411
|
const base = {
|
|
@@ -9231,6 +9448,7 @@ function summariseScene(observation) {
|
|
|
9231
9448
|
drawCalls: snapshot.performance?.drawCalls,
|
|
9232
9449
|
fps: frameMs === void 0 || frameMs <= 0 ? void 0 : Math.round(1e3 / frameMs),
|
|
9233
9450
|
frameMs,
|
|
9451
|
+
...passSplit === void 0 || passSplit.length === 0 ? {} : { passes: passSplit.map(({ draws, kind, triangles }) => ({ draws, kind, triangles })) },
|
|
9234
9452
|
triangles: snapshot.performance?.triangles,
|
|
9235
9453
|
...frameMs === void 0 ? {} : { vsyncLocked: onVsyncInterval(frameMs) }
|
|
9236
9454
|
},
|
|
@@ -9282,6 +9500,14 @@ function renderablesLine(overview) {
|
|
|
9282
9500
|
const state = projection.projecting === true ? `projection batching ${projection.batches ?? 0} groups` : `projection standing down${projection.reasonCode === void 0 ? "" : ` (${projection.reasonCode})`}`;
|
|
9283
9501
|
return ` renderables ${projection.renderables.toLocaleString("en-US")} handed to the renderer \xB7 ${state}`;
|
|
9284
9502
|
}
|
|
9503
|
+
function passesLine(overview) {
|
|
9504
|
+
const passes = overview.render.passes;
|
|
9505
|
+
if (passes === void 0) return void 0;
|
|
9506
|
+
const parts = passes.map(
|
|
9507
|
+
(pass) => `${pass.kind} ${pass.draws.toLocaleString("en-US")} draws / ${pass.triangles.toLocaleString("en-US")} tris`
|
|
9508
|
+
);
|
|
9509
|
+
return ` passes ${parts.join(" \xB7 ")}`;
|
|
9510
|
+
}
|
|
9285
9511
|
function livenessLine(overview) {
|
|
9286
9512
|
const { liveness: state } = overview;
|
|
9287
9513
|
if (state.ticks === void 0 && state.moved === 0) return void 0;
|
|
@@ -9312,6 +9538,7 @@ function formatSceneOverview(overview) {
|
|
|
9312
9538
|
` scale ${scale.verdict}${scale.medianEntityScale === void 0 ? "" : ` (median ${scale.medianEntityScale}\xD7, largest ${scale.largestEntityScale}\xD7)`}`,
|
|
9313
9539
|
` render ${render.drawCalls === void 0 ? "draw calls not observed" : `${render.drawCalls} draw calls`} \xB7 ${render.triangles === void 0 ? "triangles not observed" : `${render.triangles.toLocaleString("en-US")} triangles`}${render.frameMs === void 0 ? " \xB7 frame time not observed" : ` \xB7 ${render.frameMs.toFixed(1)} ms/frame (${render.fps} fps)`}`,
|
|
9314
9540
|
renderablesLine(overview),
|
|
9541
|
+
passesLine(overview),
|
|
9315
9542
|
...overview.room === void 0 ? [] : formatRoomLines(overview.room),
|
|
9316
9543
|
livenessLine(overview),
|
|
9317
9544
|
` gameplay ${gameplay.states} states \xB7 ${gameplay.clipsAdvancing.length === 0 ? "no clips advancing" : `clips ${gameplay.clipsAdvancing.join(", ")}`}${tags.length === 0 ? "" : ` \xB7 tags ${tags.join(", ")}`}`,
|
|
@@ -9474,79 +9701,257 @@ installThreePlaytestBridge({
|
|
|
9474
9701
|
}
|
|
9475
9702
|
return { created };
|
|
9476
9703
|
}
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
var
|
|
9480
|
-
var
|
|
9481
|
-
|
|
9482
|
-
};
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
value = JSON.parse(line.slice(at + marker.length));
|
|
9492
|
-
} catch {
|
|
9493
|
-
malformed();
|
|
9494
|
-
}
|
|
9495
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) malformed();
|
|
9496
|
-
const record4 = value;
|
|
9497
|
-
if (record4.version !== 1 || !["device", "store", "shutdown", "api-probe"].includes(String(record4.phase))) malformed();
|
|
9498
|
-
if (record4.phase !== "api-probe" && !["attached", "disabled", "unavailable", "unsupported"].includes(String(record4.mode))) malformed();
|
|
9499
|
-
if (record4.load !== void 0 && !["accepted", "missing", "rejected", "unavailable", "disabled"].includes(String(record4.load))) malformed();
|
|
9500
|
-
if (record4.store !== void 0 && !["stored", "not-attempted", "rejected", "unavailable"].includes(String(record4.store))) malformed();
|
|
9501
|
-
for (const field of ["emptyBytes", "serializedBytes", "loadedBytes", "storedBytes", "loadMs", "storeMs", "snapshotMs"]) {
|
|
9502
|
-
const number = record4[field];
|
|
9503
|
-
if (number !== void 0 && (typeof number !== "number" || !Number.isFinite(number) || number < 0)) malformed();
|
|
9504
|
-
}
|
|
9505
|
-
for (const field of ["renderAttached", "computeAttached"]) {
|
|
9506
|
-
const count = record4[field];
|
|
9507
|
-
if (count === void 0 || record4.phase === "api-probe" && typeof count === "boolean") continue;
|
|
9508
|
-
if (typeof count !== "number" || !Number.isFinite(count) || count < 0) malformed();
|
|
9509
|
-
}
|
|
9510
|
-
for (const field of ["reason", "storeReason"]) if (record4[field] !== void 0 && typeof record4[field] !== "string") malformed();
|
|
9511
|
-
if (record4.identity !== void 0 && (typeof record4.identity !== "string" || !/^[a-f0-9]{64}$/u.test(record4.identity))) malformed();
|
|
9512
|
-
const key = JSON.stringify(record4);
|
|
9513
|
-
if (!seen.has(key)) {
|
|
9514
|
-
seen.add(key);
|
|
9515
|
-
observations.push(record4);
|
|
9516
|
-
}
|
|
9704
|
+
var DEFAULT_XVFB_SCREEN = "1600x900x24";
|
|
9705
|
+
var HOST_DISPLAY_ENV = "TN_PLAYTEST_HOST_DISPLAY";
|
|
9706
|
+
var STRIPPED_WAYLAND_VARS = ["WAYLAND_DISPLAY", "WAYLAND_SOCKET", "XDG_SESSION_TYPE"];
|
|
9707
|
+
var X11_SOCKET_DIR = "/tmp/.X11-unix";
|
|
9708
|
+
function decideDisplayStrategy(input) {
|
|
9709
|
+
if (input.platform !== "linux") return { kind: "host" };
|
|
9710
|
+
const privateXvfb = {
|
|
9711
|
+
kind: "private-xvfb",
|
|
9712
|
+
screen: input.env.TN_XVFB_SCREEN ?? DEFAULT_XVFB_SCREEN
|
|
9713
|
+
};
|
|
9714
|
+
if (!hostDisplayRequested(input.env)) return privateXvfb;
|
|
9715
|
+
const display = input.env.DISPLAY;
|
|
9716
|
+
if (display !== void 0 && display.length > 0 && (input.displaySocketExists ?? x11SocketExists)(display)) {
|
|
9717
|
+
return { display, kind: "existing" };
|
|
9517
9718
|
}
|
|
9518
|
-
return
|
|
9719
|
+
return privateXvfb;
|
|
9519
9720
|
}
|
|
9520
|
-
function
|
|
9521
|
-
|
|
9522
|
-
return
|
|
9721
|
+
function hostDisplayRequested(env) {
|
|
9722
|
+
const value = env[HOST_DISPLAY_ENV];
|
|
9723
|
+
return value === "1" || value?.toLowerCase() === "true";
|
|
9523
9724
|
}
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
function
|
|
9533
|
-
|
|
9534
|
-
const
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9725
|
+
function x11SocketExists(display) {
|
|
9726
|
+
const number = displayNumber(display);
|
|
9727
|
+
return number === void 0 ? false : existsSync(join(X11_SOCKET_DIR, `X${number}`));
|
|
9728
|
+
}
|
|
9729
|
+
function displayNumber(display) {
|
|
9730
|
+
const parsed = Number.parseInt(display.replace(/^:/u, ""), 10);
|
|
9731
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
9732
|
+
}
|
|
9733
|
+
function childEnvForDisplay(env, display) {
|
|
9734
|
+
const child = { ...env };
|
|
9735
|
+
for (const name of STRIPPED_WAYLAND_VARS) delete child[name];
|
|
9736
|
+
child.DISPLAY = display;
|
|
9737
|
+
return child;
|
|
9738
|
+
}
|
|
9739
|
+
function runNeedsPixels(config, scenario) {
|
|
9740
|
+
if (config.headless !== true) return true;
|
|
9741
|
+
const takesScreenshot = scenario.artifacts?.screenshots !== false || scenario.steps.some(({ screenshot }) => screenshot !== void 0);
|
|
9742
|
+
const evaluatesVisual = (scenario.assert?.visual?.length ?? 0) > 0;
|
|
9743
|
+
return takesScreenshot || evaluatesVisual || scenario.assert?.framebufferCoverage !== void 0;
|
|
9744
|
+
}
|
|
9745
|
+
async function provideDisplay(options = {}) {
|
|
9746
|
+
const env = options.env ?? process.env;
|
|
9747
|
+
const platform = options.platform ?? process.platform;
|
|
9748
|
+
const strategy = decideDisplayStrategy({
|
|
9749
|
+
displaySocketExists: options.displaySocketExists,
|
|
9750
|
+
env,
|
|
9751
|
+
platform
|
|
9752
|
+
});
|
|
9753
|
+
if (strategy.kind === "host") {
|
|
9754
|
+
return {
|
|
9755
|
+
compositor: void 0,
|
|
9756
|
+
display: void 0,
|
|
9757
|
+
env: { ...env },
|
|
9758
|
+
release: async () => void 0,
|
|
9759
|
+
strategy
|
|
9760
|
+
};
|
|
9761
|
+
}
|
|
9762
|
+
if (strategy.kind === "existing") {
|
|
9763
|
+
return {
|
|
9764
|
+
compositor: void 0,
|
|
9765
|
+
display: strategy.display,
|
|
9766
|
+
env: childEnvForDisplay(env, strategy.display),
|
|
9767
|
+
release: async () => void 0,
|
|
9768
|
+
strategy
|
|
9769
|
+
};
|
|
9770
|
+
}
|
|
9771
|
+
const commandExists2 = options.commandExists ?? defaultCommandExists;
|
|
9772
|
+
if (!commandExists2("Xvfb")) {
|
|
9773
|
+
throw new Error(
|
|
9774
|
+
"No usable X display is available and Xvfb is not installed, so this pixel-producing run cannot start (Debian/Ubuntu 'xvfb', Arch 'xorg-server-xvfb', Fedora 'xorg-x11-server-Xvfb'). Refusing to render blind."
|
|
9775
|
+
);
|
|
9776
|
+
}
|
|
9777
|
+
const spawnProcess = options.spawnProcess ?? spawn;
|
|
9778
|
+
const xvfb = spawnProcess("Xvfb", [
|
|
9779
|
+
"-displayfd",
|
|
9780
|
+
"3",
|
|
9781
|
+
"-nolisten",
|
|
9782
|
+
"tcp",
|
|
9783
|
+
// COMPOSITE and SHAPE are what a compositing manager needs before it can blend anything, and
|
|
9784
|
+
// the native desktop runtime refuses to attach its UI overlay to a display without one. Xvfb
|
|
9785
|
+
// does not enable them by default, so every native UI run on a private display reported
|
|
9786
|
+
// `TN_UI_OVERLAY:{"attached":false,"reason":"no compositing manager is running"}` — including
|
|
9787
|
+
// the starter template's own shipped native-playtests/react-hud scenario, which failed out of
|
|
9788
|
+
// the box on a freshly scaffolded project. A browser run does not care either way.
|
|
9789
|
+
"+extension",
|
|
9790
|
+
"COMPOSITE",
|
|
9791
|
+
"+extension",
|
|
9792
|
+
"SHAPE",
|
|
9793
|
+
"-screen",
|
|
9794
|
+
"0",
|
|
9795
|
+
strategy.screen
|
|
9796
|
+
], { stdio: ["ignore", "ignore", "pipe", "pipe"] });
|
|
9797
|
+
xvfb.on?.("error", () => void 0);
|
|
9798
|
+
try {
|
|
9799
|
+
const number = await readXvfbDisplayNumber(xvfb);
|
|
9800
|
+
const display = `:${number}`;
|
|
9801
|
+
const compositor = await startCompositor(display, { commandExists: commandExists2, env, spawnProcess });
|
|
9802
|
+
return {
|
|
9803
|
+
compositor: compositor?.name,
|
|
9804
|
+
display,
|
|
9805
|
+
env: childEnvForDisplay(env, display),
|
|
9806
|
+
release: async () => {
|
|
9807
|
+
if (compositor !== void 0) await stopChild(compositor.child);
|
|
9808
|
+
await stopChild(xvfb);
|
|
9809
|
+
},
|
|
9810
|
+
strategy
|
|
9811
|
+
};
|
|
9812
|
+
} catch (error) {
|
|
9813
|
+
await stopChild(xvfb);
|
|
9814
|
+
throw error;
|
|
9815
|
+
}
|
|
9816
|
+
}
|
|
9817
|
+
var COMPOSITORS = [
|
|
9818
|
+
{ args: ["-n"], name: "xcompmgr" },
|
|
9819
|
+
{ args: [], name: "picom" },
|
|
9820
|
+
{ args: [], name: "compton" }
|
|
9821
|
+
];
|
|
9822
|
+
var COMPOSITOR_SETTLE_MS = 250;
|
|
9823
|
+
async function startCompositor(display, options) {
|
|
9824
|
+
const choice = COMPOSITORS.find(({ name }) => options.commandExists(name));
|
|
9825
|
+
if (choice === void 0) return void 0;
|
|
9826
|
+
const child = options.spawnProcess(choice.name, [...choice.args], {
|
|
9827
|
+
env: { ...options.env, DISPLAY: display },
|
|
9828
|
+
stdio: "ignore"
|
|
9829
|
+
});
|
|
9830
|
+
let spawnFailed = false;
|
|
9831
|
+
child.on?.("error", () => {
|
|
9832
|
+
spawnFailed = true;
|
|
9833
|
+
});
|
|
9834
|
+
await new Promise((settle) => setTimeout(settle, COMPOSITOR_SETTLE_MS));
|
|
9835
|
+
if (spawnFailed) return void 0;
|
|
9836
|
+
if ((child.exitCode ?? null) !== null || (child.signalCode ?? null) !== null) return void 0;
|
|
9837
|
+
return { child, name: choice.name };
|
|
9838
|
+
}
|
|
9839
|
+
var XVFB_DISPLAY_TIMEOUT_MS = 1e4;
|
|
9840
|
+
async function readXvfbDisplayNumber(xvfb) {
|
|
9841
|
+
const report = xvfb.stdio[3];
|
|
9842
|
+
if (report === null || report === void 0 || typeof report.on !== "function") {
|
|
9843
|
+
throw new Error("Xvfb was spawned without a display-report descriptor to read.");
|
|
9844
|
+
}
|
|
9845
|
+
const stream = report;
|
|
9846
|
+
return new Promise((resolveDisplay, rejectDisplay) => {
|
|
9847
|
+
let settled = false;
|
|
9848
|
+
const finish = (settle) => {
|
|
9849
|
+
if (settled) return;
|
|
9850
|
+
settled = true;
|
|
9851
|
+
clearTimeout(timer);
|
|
9852
|
+
stream.removeListener("data", onData);
|
|
9853
|
+
stream.removeListener("close", onClose);
|
|
9854
|
+
settle();
|
|
9855
|
+
};
|
|
9856
|
+
const onData = (chunk) => {
|
|
9857
|
+
const number = Number.parseInt(String(chunk).trim(), 10);
|
|
9858
|
+
if (Number.isInteger(number) && number >= 0) finish(() => resolveDisplay(number));
|
|
9859
|
+
};
|
|
9860
|
+
const onClose = () => finish(() => rejectDisplay(new Error("Xvfb exited before it reported a display.")));
|
|
9861
|
+
const timer = setTimeout(() => finish(() => {
|
|
9862
|
+
rejectDisplay(new Error(`Xvfb did not report a display within ${XVFB_DISPLAY_TIMEOUT_MS}ms.`));
|
|
9863
|
+
}), XVFB_DISPLAY_TIMEOUT_MS);
|
|
9864
|
+
stream.on("data", onData);
|
|
9865
|
+
stream.on("close", onClose);
|
|
9866
|
+
});
|
|
9867
|
+
}
|
|
9868
|
+
async function stopChild(child) {
|
|
9869
|
+
const exitedAlready = () => (child.exitCode ?? null) !== null || (child.signalCode ?? null) !== null;
|
|
9870
|
+
if (exitedAlready()) return;
|
|
9871
|
+
child.kill("SIGTERM");
|
|
9872
|
+
const started = Date.now();
|
|
9873
|
+
while (Date.now() - started < 1e3 && !exitedAlready()) {
|
|
9874
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 25));
|
|
9875
|
+
}
|
|
9876
|
+
if (!exitedAlready()) child.kill("SIGKILL");
|
|
9877
|
+
}
|
|
9878
|
+
function defaultCommandExists(command) {
|
|
9879
|
+
const paths = (process.env.PATH ?? "").split(":").filter((segment) => segment.length > 0);
|
|
9880
|
+
return paths.some((directory) => existsSync(join(directory, command)));
|
|
9881
|
+
}
|
|
9882
|
+
|
|
9883
|
+
// src/runner/pipeline-cache-observations.ts
|
|
9884
|
+
var marker = "TN_PIPELINE_CACHE:";
|
|
9885
|
+
var malformed = () => {
|
|
9886
|
+
throw new Error("TN_PERF_PIPELINE_CACHE_MALFORMED");
|
|
9887
|
+
};
|
|
9888
|
+
function parsePipelineCacheObservations(text) {
|
|
9889
|
+
const observations = [];
|
|
9890
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9891
|
+
for (const line of text.split("\n")) {
|
|
9892
|
+
const at = line.indexOf(marker);
|
|
9893
|
+
if (at < 0) continue;
|
|
9894
|
+
let value;
|
|
9895
|
+
try {
|
|
9896
|
+
value = JSON.parse(line.slice(at + marker.length));
|
|
9897
|
+
} catch {
|
|
9898
|
+
malformed();
|
|
9899
|
+
}
|
|
9900
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) malformed();
|
|
9901
|
+
const record4 = value;
|
|
9902
|
+
if (record4.version !== 1 || !["device", "store", "shutdown", "api-probe"].includes(String(record4.phase))) malformed();
|
|
9903
|
+
if (record4.phase !== "api-probe" && !["attached", "disabled", "unavailable", "unsupported"].includes(String(record4.mode))) malformed();
|
|
9904
|
+
if (record4.load !== void 0 && !["accepted", "missing", "rejected", "unavailable", "disabled"].includes(String(record4.load))) malformed();
|
|
9905
|
+
if (record4.store !== void 0 && !["stored", "not-attempted", "rejected", "unavailable"].includes(String(record4.store))) malformed();
|
|
9906
|
+
for (const field of ["emptyBytes", "serializedBytes", "loadedBytes", "storedBytes", "loadMs", "storeMs", "snapshotMs"]) {
|
|
9907
|
+
const number = record4[field];
|
|
9908
|
+
if (number !== void 0 && (typeof number !== "number" || !Number.isFinite(number) || number < 0)) malformed();
|
|
9909
|
+
}
|
|
9910
|
+
for (const field of ["renderAttached", "computeAttached"]) {
|
|
9911
|
+
const count = record4[field];
|
|
9912
|
+
if (count === void 0 || record4.phase === "api-probe" && typeof count === "boolean") continue;
|
|
9913
|
+
if (typeof count !== "number" || !Number.isFinite(count) || count < 0) malformed();
|
|
9914
|
+
}
|
|
9915
|
+
for (const field of ["reason", "storeReason"]) if (record4[field] !== void 0 && typeof record4[field] !== "string") malformed();
|
|
9916
|
+
if (record4.identity !== void 0 && (typeof record4.identity !== "string" || !/^[a-f0-9]{64}$/u.test(record4.identity))) malformed();
|
|
9917
|
+
const key = JSON.stringify(record4);
|
|
9918
|
+
if (!seen.has(key)) {
|
|
9919
|
+
seen.add(key);
|
|
9920
|
+
observations.push(record4);
|
|
9921
|
+
}
|
|
9922
|
+
}
|
|
9923
|
+
return observations;
|
|
9924
|
+
}
|
|
9925
|
+
function formatPipelineCacheObservations(values) {
|
|
9926
|
+
if (values.length === 0) return "pipeline cache: not reported \u2014 no hit or persistence claim";
|
|
9927
|
+
return values.map((value) => `pipeline cache ${value.phase}: ${value.mode ?? "API probe"}, load ${value.load ?? "unreported"} (${value.loadedBytes ?? "unreported"} bytes), store ${value.store ?? "unreported"} (${value.storedBytes ?? "unreported"} bytes)` + (value.reason ? `, ${value.reason}` : "") + (value.storeReason ? `, ${value.storeReason}` : "")).join("\n") + "\npipeline cache observations are not hits; compare same-build process-cold pairs for benefit";
|
|
9928
|
+
}
|
|
9929
|
+
|
|
9930
|
+
// src/runner/pipeline-summary.ts
|
|
9931
|
+
var PIPELINE_CAPTURE_VERSION = 1;
|
|
9932
|
+
var PIPELINE_EVENT_MARKER = "TN_PIPELINE_EVENT:";
|
|
9933
|
+
var PIPELINE_CAPTURE_MARKER = "TN_PIPELINE_CAPTURE:";
|
|
9934
|
+
var PIPELINE_FIRST_PRESENT_MARKER = "TN_PIPELINE_FIRST_PRESENT:";
|
|
9935
|
+
var PIPELINE_COMPLETE_MARKER = "TN_PIPELINE_COMPLETE:";
|
|
9936
|
+
var PIPELINE_CHECKPOINT_MARKER = "TN_PIPELINE_CHECKPOINT:";
|
|
9937
|
+
function parsePipelineCapture(input) {
|
|
9938
|
+
if (typeof input === "string") return parseCaptureDocument(input);
|
|
9939
|
+
const root = asRecord(input);
|
|
9940
|
+
if (root === void 0) throw malformed2("capture must be an object");
|
|
9941
|
+
if (root.nativeLog !== void 0) {
|
|
9942
|
+
if (root.version !== PIPELINE_CAPTURE_VERSION || typeof root.nativeLog !== "string")
|
|
9943
|
+
throw malformed2("paired capture requires version 1 and a nativeLog string");
|
|
9944
|
+
const renderer = parsePipelineCapture(root.census);
|
|
9945
|
+
const native = nativeCapture(parseNativeMarkerCapture(root.nativeLog));
|
|
9946
|
+
return reconcilePipelineCaptures(renderer, native);
|
|
9947
|
+
}
|
|
9948
|
+
const observations = asRecord(root.observations);
|
|
9949
|
+
const nested = firstDefinedRecord(
|
|
9950
|
+
root.pipelineCensus,
|
|
9951
|
+
root.census,
|
|
9952
|
+
observations?.pipelineCensus,
|
|
9953
|
+
root.capture
|
|
9954
|
+
);
|
|
9550
9955
|
const value = nested ?? root;
|
|
9551
9956
|
if (value.version === void 0) throw malformed2("capture is missing its version");
|
|
9552
9957
|
if (typeof value.version !== "number" || !Number.isInteger(value.version)) {
|
|
@@ -10415,14 +10820,24 @@ var FRAME_BUDGET_MARKER = "TN_FRAME_BUDGET:";
|
|
|
10415
10820
|
var PROJECTION_MARKER = "TN_PROJECTION:";
|
|
10416
10821
|
var HOST_GAP_MARKER = "TN_HOST_GAP:";
|
|
10417
10822
|
var HITCH_MARKER = "TN_FRAME_HITCH:";
|
|
10823
|
+
var SLOW_PHASE_MARKER = "TN_SLOW_PHASE:";
|
|
10824
|
+
var PRESENTS_TICK_MARKER = "TN_PRESENTS_TICK:";
|
|
10825
|
+
var PRESENTS_REACHED_DISPLAY_RATIO = 0.95;
|
|
10418
10826
|
function rankExactReasons(exact) {
|
|
10419
10827
|
return Object.entries(exact).filter(([, count]) => typeof count === "number" && count > 0).map(([reason, count]) => ({ count, reason })).sort((left, right) => right.count - left.count || (left.reason < right.reason ? -1 : 1));
|
|
10420
10828
|
}
|
|
10421
10829
|
var PRESENT_MODE_PATTERN = /Present mode: (\S+ \(vsync=(?:true|false)\))/u;
|
|
10830
|
+
function isPresentGap(payload) {
|
|
10831
|
+
const candidate = payload;
|
|
10832
|
+
return Number.isFinite(candidate.gapMs) && Number.isFinite(candidate.uptimeMs) && candidate.window === void 0;
|
|
10833
|
+
}
|
|
10422
10834
|
function parsePerformanceMarkers(text) {
|
|
10423
10835
|
const budgets = [];
|
|
10424
10836
|
const budgetPayloads = /* @__PURE__ */ new Set();
|
|
10425
10837
|
const hitches = [];
|
|
10838
|
+
const presentGaps = [];
|
|
10839
|
+
const presents = [];
|
|
10840
|
+
const slowPhases = [];
|
|
10426
10841
|
const hitchPayloads = /* @__PURE__ */ new Set();
|
|
10427
10842
|
const hostGaps = [];
|
|
10428
10843
|
const projections = [];
|
|
@@ -10443,9 +10858,22 @@ function parsePerformanceMarkers(text) {
|
|
|
10443
10858
|
const payload = JSON.stringify(hitch);
|
|
10444
10859
|
if (!hitchPayloads.has(payload)) {
|
|
10445
10860
|
hitchPayloads.add(payload);
|
|
10446
|
-
|
|
10861
|
+
if (isPresentGap(hitch)) {
|
|
10862
|
+
presentGaps.push(hitch);
|
|
10863
|
+
} else {
|
|
10864
|
+
if (!Number.isFinite(hitch.maxMs)) {
|
|
10865
|
+
throw new Error(
|
|
10866
|
+
`TN_PERF_MARKER_MALFORMED: a ${HITCH_MARKER} line carries neither a present gap (gapMs) nor a window's maxMs: ${line.trim()}`
|
|
10867
|
+
);
|
|
10868
|
+
}
|
|
10869
|
+
hitches.push(hitch);
|
|
10870
|
+
}
|
|
10447
10871
|
}
|
|
10448
10872
|
}
|
|
10873
|
+
const tick = parseMarkerLine(line, PRESENTS_TICK_MARKER);
|
|
10874
|
+
if (tick !== void 0) presents.push(tick);
|
|
10875
|
+
const slowPhase = parseMarkerLine(line, SLOW_PHASE_MARKER);
|
|
10876
|
+
if (slowPhase !== void 0) slowPhases.push(slowPhase);
|
|
10449
10877
|
const hostGap = parseMarkerLine(line, HOST_GAP_MARKER);
|
|
10450
10878
|
if (hostGap !== void 0) hostGaps.push(hostGap);
|
|
10451
10879
|
const projection = parseMarkerLine(line, PROJECTION_MARKER);
|
|
@@ -10459,7 +10887,18 @@ function parsePerformanceMarkers(text) {
|
|
|
10459
10887
|
const mode = PRESENT_MODE_PATTERN.exec(line);
|
|
10460
10888
|
if (mode?.[1] !== void 0) presentMode = mode[1];
|
|
10461
10889
|
}
|
|
10462
|
-
return {
|
|
10890
|
+
return {
|
|
10891
|
+
budgets,
|
|
10892
|
+
hitches,
|
|
10893
|
+
hostGaps,
|
|
10894
|
+
pipelineEvents,
|
|
10895
|
+
pipelineCaches: parsePipelineCacheObservations(text),
|
|
10896
|
+
presentGaps,
|
|
10897
|
+
presentMode,
|
|
10898
|
+
presents,
|
|
10899
|
+
projections,
|
|
10900
|
+
slowPhases
|
|
10901
|
+
};
|
|
10463
10902
|
}
|
|
10464
10903
|
function parseMarkerLine(line, marker2) {
|
|
10465
10904
|
const start = line.indexOf(marker2);
|
|
@@ -10474,11 +10913,27 @@ function parseMarkerLine(line, marker2) {
|
|
|
10474
10913
|
);
|
|
10475
10914
|
}
|
|
10476
10915
|
}
|
|
10477
|
-
function assessPerfMarkers(parse, bounds, source) {
|
|
10916
|
+
function assessPerfMarkers(parse, bounds, source, display) {
|
|
10478
10917
|
const discardCount = parse.budgets.length > 1 ? 1 : 0;
|
|
10479
10918
|
const discardedWindows = parse.budgets.slice(0, discardCount).map(({ window: window2 }) => window2);
|
|
10480
10919
|
const steady = parse.budgets.slice(discardCount);
|
|
10481
10920
|
const violations = [];
|
|
10921
|
+
const unassessableWindows = [];
|
|
10922
|
+
const tick = parse.presents.at(-1);
|
|
10923
|
+
const presentsRatio = tick === void 0 || !Number.isFinite(tick.frames) || tick.frames <= 0 || !Number.isFinite(tick.presents) ? void 0 : tick.presents / tick.frames;
|
|
10924
|
+
const windowsCarryPresents = parse.budgets.length > 0 && parse.budgets.every((window2) => Number.isFinite(window2.presents));
|
|
10925
|
+
const unvouchableBy = () => {
|
|
10926
|
+
if (windowsCarryPresents) return display?.virtual === true ? `a ${display.strategy} display` : void 0;
|
|
10927
|
+
if (presentsRatio !== void 0 && presentsRatio < PRESENTS_REACHED_DISPLAY_RATIO) {
|
|
10928
|
+
return `the host presented ${tick?.presents} of ${tick?.frames} loop frames` + (tick?.capHz === void 0 ? "" : ` (cap ${tick.capHz} Hz)`);
|
|
10929
|
+
}
|
|
10930
|
+
return display?.virtual === true ? `a ${display.strategy} display` : void 0;
|
|
10931
|
+
};
|
|
10932
|
+
const unvouchable = unvouchableBy();
|
|
10933
|
+
const virtualDisplay = unvouchable !== void 0 && bounds.allowVirtualDisplay !== true;
|
|
10934
|
+
if (virtualDisplay && bounds.minFps !== void 0) {
|
|
10935
|
+
violations.push({ bound: bounds.minFps, code: "TN_PERF_VIRTUAL_DISPLAY", observed: void 0, window: -1 });
|
|
10936
|
+
}
|
|
10482
10937
|
if (steady.length < bounds.requireWindows) {
|
|
10483
10938
|
violations.push({ bound: bounds.requireWindows, code: "TN_PERF_WINDOWS_MISSING", observed: steady.length, window: -1 });
|
|
10484
10939
|
}
|
|
@@ -10491,19 +10946,47 @@ function assessPerfMarkers(parse, bounds, source) {
|
|
|
10491
10946
|
violations.push({ bound: bounds.maxFrameMsP95, code: "TN_PERF_MAX_FRAME_P95", observed: frameP95, window: window2.window });
|
|
10492
10947
|
}
|
|
10493
10948
|
}
|
|
10494
|
-
if (bounds.minFps !== void 0 &&
|
|
10495
|
-
|
|
10949
|
+
if (bounds.minFps !== void 0 && !virtualDisplay) {
|
|
10950
|
+
const rate = window2.presentedFps;
|
|
10951
|
+
if (rate !== void 0) {
|
|
10952
|
+
if (rate < bounds.minFps)
|
|
10953
|
+
violations.push({ bound: bounds.minFps, code: "TN_PERF_MIN_FPS", observed: rate, window: window2.window });
|
|
10954
|
+
} else if (window2.presents === void 0) {
|
|
10955
|
+
if (window2.fps < bounds.minFps)
|
|
10956
|
+
violations.push({ bound: bounds.minFps, code: "TN_PERF_MIN_FPS", observed: window2.fps, window: window2.window });
|
|
10957
|
+
} else {
|
|
10958
|
+
unassessableWindows.push(window2.window);
|
|
10959
|
+
}
|
|
10496
10960
|
}
|
|
10497
10961
|
}
|
|
10962
|
+
if (unassessableWindows.length > 0 && unassessableWindows.length === steady.length && bounds.minFps !== void 0) {
|
|
10963
|
+
violations.push({
|
|
10964
|
+
bound: bounds.minFps,
|
|
10965
|
+
code: "TN_PERF_BOUNDS_NOT_ASSESSABLE",
|
|
10966
|
+
observed: void 0,
|
|
10967
|
+
window: -1
|
|
10968
|
+
});
|
|
10969
|
+
}
|
|
10498
10970
|
return {
|
|
10499
10971
|
budgets: parse.budgets,
|
|
10500
10972
|
discardedWindows,
|
|
10973
|
+
...display !== void 0 || unvouchable !== void 0 ? {
|
|
10974
|
+
display: {
|
|
10975
|
+
fpsSuppressed: virtualDisplay,
|
|
10976
|
+
...unvouchable === void 0 ? {} : { reason: unvouchable },
|
|
10977
|
+
strategy: display?.strategy ?? "host",
|
|
10978
|
+
virtual: display?.virtual === true
|
|
10979
|
+
}
|
|
10980
|
+
} : {},
|
|
10501
10981
|
hitches: parse.hitches,
|
|
10502
10982
|
hostGaps: parse.hostGaps,
|
|
10983
|
+
presentGaps: parse.presentGaps,
|
|
10984
|
+
presents: parse.presents,
|
|
10503
10985
|
pipelineEvents: parse.pipelineEvents,
|
|
10504
10986
|
pipelineCaches: parse.pipelineCaches ?? [],
|
|
10505
10987
|
pass: violations.length === 0 && parse.budgets.length > 0,
|
|
10506
10988
|
presentMode: parse.presentMode,
|
|
10989
|
+
slowPhases: parse.slowPhases,
|
|
10507
10990
|
projections: parse.projections,
|
|
10508
10991
|
source,
|
|
10509
10992
|
violations
|
|
@@ -10511,13 +10994,16 @@ function assessPerfMarkers(parse, bounds, source) {
|
|
|
10511
10994
|
}
|
|
10512
10995
|
function parsePerfArgs(argv) {
|
|
10513
10996
|
const sources = { hostArgs: [] };
|
|
10514
|
-
const bounds = {
|
|
10997
|
+
const bounds = {
|
|
10998
|
+
requireWindows: 2
|
|
10999
|
+
};
|
|
10515
11000
|
let text = false;
|
|
10516
11001
|
let timeoutSeconds = 180;
|
|
10517
11002
|
for (let index = 0; index < argv.length; index += 1) {
|
|
10518
11003
|
const flag = argv[index];
|
|
10519
11004
|
const value = argv[index + 1];
|
|
10520
11005
|
if (flag === "--text") text = true;
|
|
11006
|
+
else if (flag === "--allow-virtual-display") bounds.allowVirtualDisplay = true;
|
|
10521
11007
|
else if (flag === "--file") {
|
|
10522
11008
|
sources.file = requireValue(flag, value);
|
|
10523
11009
|
index += 1;
|
|
@@ -10554,6 +11040,7 @@ function parsePerfArgs(argv) {
|
|
|
10554
11040
|
throw new PlaytestCliUsageError("threenative-playtest perf: --file, --executable and --logcat are mutually exclusive.");
|
|
10555
11041
|
}
|
|
10556
11042
|
return {
|
|
11043
|
+
allowVirtualDisplay: bounds.allowVirtualDisplay === true,
|
|
10557
11044
|
executable: sources.executable,
|
|
10558
11045
|
file: sources.file,
|
|
10559
11046
|
hostArgs: sources.hostArgs,
|
|
@@ -10602,6 +11089,7 @@ async function perfCommand(argv) {
|
|
|
10602
11089
|
}
|
|
10603
11090
|
async function runExecutable(args, executable) {
|
|
10604
11091
|
const source = `executable: ${[executable, ...args.hostArgs].join(" ")}`;
|
|
11092
|
+
const strategy = decideDisplayStrategy({ env: process.env, platform: process.platform });
|
|
10605
11093
|
const child = spawn(executable, args.hostArgs, { stdio: ["ignore", "pipe", "pipe"] });
|
|
10606
11094
|
let collected = "";
|
|
10607
11095
|
let stopped = false;
|
|
@@ -10631,7 +11119,10 @@ async function runExecutable(args, executable) {
|
|
|
10631
11119
|
});
|
|
10632
11120
|
child.on("exit", () => {
|
|
10633
11121
|
clearTimeout(timeout);
|
|
10634
|
-
const code = emit(parsePerformanceMarkers(collected), args, source
|
|
11122
|
+
const code = emit(parsePerformanceMarkers(collected), args, source, {
|
|
11123
|
+
strategy: strategy.kind,
|
|
11124
|
+
virtual: strategy.kind === "private-xvfb"
|
|
11125
|
+
});
|
|
10635
11126
|
process.exitCode = code;
|
|
10636
11127
|
settleExit(code);
|
|
10637
11128
|
});
|
|
@@ -10645,8 +11136,8 @@ async function readLogcat(serial) {
|
|
|
10645
11136
|
});
|
|
10646
11137
|
return stdout;
|
|
10647
11138
|
}
|
|
10648
|
-
function emit(parse, args, source) {
|
|
10649
|
-
const report = assessPerfMarkers(parse, args, source);
|
|
11139
|
+
function emit(parse, args, source, display) {
|
|
11140
|
+
const report = assessPerfMarkers(parse, args, source, display);
|
|
10650
11141
|
const windowsMissing = report.violations.some(({ code }) => code === "TN_PERF_WINDOWS_MISSING");
|
|
10651
11142
|
const exitCode = windowsMissing ? 2 : report.pass ? 0 : 1;
|
|
10652
11143
|
process.stdout.write(args.text ? formatPerfReport(report) : `${JSON.stringify(report, null, 2)}
|
|
@@ -10654,6 +11145,13 @@ function emit(parse, args, source) {
|
|
|
10654
11145
|
process.exitCode = exitCode;
|
|
10655
11146
|
return exitCode;
|
|
10656
11147
|
}
|
|
11148
|
+
function describeSuppression(report) {
|
|
11149
|
+
const reason = report.display?.reason;
|
|
11150
|
+
if (reason !== void 0) {
|
|
11151
|
+
return reason.startsWith("the host presented") ? `${reason} \u2014 the loop's cadence, not the display's` : `this run painted on ${reason}, where the present wait lands inside the update phase`;
|
|
11152
|
+
}
|
|
11153
|
+
return "this run's frame rate could not be vouched for";
|
|
11154
|
+
}
|
|
10657
11155
|
function formatPerfReport(report) {
|
|
10658
11156
|
const lines = [`perf \u2014 ${report.budgets.length} window(s) from ${report.source}`];
|
|
10659
11157
|
lines.push(formatPipelineCacheObservations(report.pipelineCaches ?? []));
|
|
@@ -10680,15 +11178,21 @@ function formatPerfReport(report) {
|
|
|
10680
11178
|
"gpu: not reported \u2014 the meter emits nothing rather than zero when the device did not grant 'timestamp-query'. Check the TN_WEBGPU_FEATURES line in the same log for what it did grant."
|
|
10681
11179
|
);
|
|
10682
11180
|
}
|
|
11181
|
+
const fpsSuppressed = report.display?.fpsSuppressed === true;
|
|
11182
|
+
if (fpsSuppressed) {
|
|
11183
|
+
lines.push(
|
|
11184
|
+
`fps suppressed: ${describeSuppression(report)}, so the frame rate is not the one a player would read. The phase rows below are unaffected. Rerun on the host display with TN_PLAYTEST_HOST_DISPLAY=1 for a quotable frame rate, or pass --allow-virtual-display to accept the phase timings with it.`
|
|
11185
|
+
);
|
|
11186
|
+
}
|
|
10683
11187
|
lines.push(
|
|
10684
|
-
`window fps frame p50/p95 render p50/p95 hostGap p50/p95${anyGpu ? " gpu ms" : ""}`
|
|
11188
|
+
`window ${fpsSuppressed ? " " : "fps "}frame p50/p95 render p50/p95 hostGap p50/p95${anyGpu ? " gpu ms" : ""}`
|
|
10685
11189
|
);
|
|
10686
11190
|
for (const window2 of report.budgets) {
|
|
10687
11191
|
const label = report.discardedWindows.includes(window2.window) ? `${window2.window}*` : String(window2.window);
|
|
10688
11192
|
lines.push(
|
|
10689
11193
|
[
|
|
10690
11194
|
label.padEnd(7),
|
|
10691
|
-
window2.fps.toFixed(2).padEnd(7),
|
|
11195
|
+
fpsSuppressed ? "".padEnd(7) : (window2.presentedFps ?? (window2.presents === 0 ? 0 : window2.fps)).toFixed(2).padEnd(7),
|
|
10692
11196
|
summary(window2.frame).padEnd(16),
|
|
10693
11197
|
summary(window2.phases?.render).padEnd(16),
|
|
10694
11198
|
summary(window2.phases?.hostGap),
|
|
@@ -10699,6 +11203,12 @@ function formatPerfReport(report) {
|
|
|
10699
11203
|
);
|
|
10700
11204
|
}
|
|
10701
11205
|
if (report.discardedWindows.length > 0) lines.push("* discarded as startup (window 1 always lies)");
|
|
11206
|
+
const presentedNothing = report.budgets.filter((window2) => window2.presents === 0);
|
|
11207
|
+
if (presentedNothing.length > 0) {
|
|
11208
|
+
lines.push(
|
|
11209
|
+
`windows ${presentedNothing.map((window2) => window2.window).join(", ")} presented nothing in their loop frames: too short to contain a present, so their frame rate is unmeasured rather than zero`
|
|
11210
|
+
);
|
|
11211
|
+
}
|
|
10702
11212
|
lines.push(...formatProjection(report.projections));
|
|
10703
11213
|
const lastGap = report.hostGaps.at(-1);
|
|
10704
11214
|
if (lastGap !== void 0) {
|
|
@@ -10707,7 +11217,7 @@ function formatPerfReport(report) {
|
|
|
10707
11217
|
lines.push(` ${name.padEnd(16)}${segment.p50Ms.toFixed(3)}`);
|
|
10708
11218
|
}
|
|
10709
11219
|
}
|
|
10710
|
-
lines.push(...formatHitches(report.hitches));
|
|
11220
|
+
lines.push(...formatHitches(report.hitches, report.presentGaps, report.slowPhases));
|
|
10711
11221
|
for (const violation of report.violations) {
|
|
10712
11222
|
const observed = violation.observed === void 0 ? "absent" : round3(violation.observed).toString();
|
|
10713
11223
|
lines.push(`FAIL ${violation.code}: window ${violation.window} observed ${observed} against bound ${violation.bound}`);
|
|
@@ -10740,11 +11250,39 @@ function formatProjection(windows) {
|
|
|
10740
11250
|
function summary(summaryValue) {
|
|
10741
11251
|
return summaryValue === void 0 ? "\u2014" : `${summaryValue.p50.toFixed(1)}/${summaryValue.p95.toFixed(1)}`;
|
|
10742
11252
|
}
|
|
10743
|
-
function
|
|
10744
|
-
|
|
10745
|
-
const
|
|
10746
|
-
|
|
10747
|
-
|
|
11253
|
+
function phasesWithinGap(gap, slowPhases) {
|
|
11254
|
+
const start = gap.uptimeMs - gap.gapMs;
|
|
11255
|
+
const overlapping = slowPhases.filter(
|
|
11256
|
+
(phase) => phase.atMs > start && phase.atMs - phase.ms < gap.uptimeMs
|
|
11257
|
+
);
|
|
11258
|
+
const innermost = overlapping.filter(
|
|
11259
|
+
(candidate) => !overlapping.some(
|
|
11260
|
+
(other) => other !== candidate && other.atMs <= candidate.atMs && other.atMs - other.ms >= candidate.atMs - candidate.ms
|
|
11261
|
+
)
|
|
11262
|
+
);
|
|
11263
|
+
const reportable = innermost.length > 0 ? innermost : overlapping;
|
|
11264
|
+
return [...reportable].sort((left, right) => right.ms - left.ms).slice(0, 3);
|
|
11265
|
+
}
|
|
11266
|
+
function describeGap(gap, slowPhases) {
|
|
11267
|
+
const phases = phasesWithinGap(gap, slowPhases);
|
|
11268
|
+
if (phases.length === 0) {
|
|
11269
|
+
return slowPhases.length === 0 ? "no slow phase reported in this log" : "no slow phase fell inside it";
|
|
11270
|
+
}
|
|
11271
|
+
return phases.map((phase) => `${phase.phase} ${phase.ms.toFixed(3)} ms`).join(", ");
|
|
11272
|
+
}
|
|
11273
|
+
function formatHitches(hitches, presentGaps = [], slowPhases = []) {
|
|
11274
|
+
const lines = [];
|
|
11275
|
+
if (presentGaps.length > 0) {
|
|
11276
|
+
const worst = Math.max(...presentGaps.map((gap) => gap.gapMs));
|
|
11277
|
+
const at = presentGaps.reduce((best, gap) => gap.gapMs >= best.gapMs ? gap : best);
|
|
11278
|
+
lines.push(
|
|
11279
|
+
`present gaps (${presentGaps.length}): worst ${worst.toFixed(3)} ms at uptime ${at.uptimeMs.toFixed(0)} ms \u2014 one frame each, reported by the frame budget's own hitch threshold`
|
|
11280
|
+
);
|
|
11281
|
+
for (const gap of presentGaps) lines.push(` gap ${gap.gapMs.toFixed(3)} ms at uptime ${gap.uptimeMs.toFixed(0)} ms: ${describeGap(gap, slowPhases)}`);
|
|
11282
|
+
}
|
|
11283
|
+
if (hitches.length === 0) return lines;
|
|
11284
|
+
const windows = `hitch windows (post-launch, ${hitches.length}): worst ${Math.max(...hitches.map((h) => h.maxMs)).toFixed(3)} ms`;
|
|
11285
|
+
lines.push(windows);
|
|
10748
11286
|
const named = hitches.filter((hitch) => (hitch.pipelineCompileCalls ?? 0) > 0);
|
|
10749
11287
|
if (named.length === 0) {
|
|
10750
11288
|
const anyField = hitches.some((hitch) => hitch.pipelineCompileCalls !== void 0);
|
|
@@ -11108,7 +11646,7 @@ var DeviceMailboxTransport = class {
|
|
|
11108
11646
|
async waitForResponse(id, method, order, timeoutMs) {
|
|
11109
11647
|
const deadline = Date.now() + timeoutMs;
|
|
11110
11648
|
while (!this.closed && Date.now() < deadline) {
|
|
11111
|
-
const raw = await this.mailbox
|
|
11649
|
+
const raw = await readMailboxFile(this.mailbox, this.paths.response);
|
|
11112
11650
|
if (raw !== void 0) {
|
|
11113
11651
|
const response = parseResponse(raw);
|
|
11114
11652
|
this.responseObserver?.({ body: raw, method, order, requestId: response.id });
|
|
@@ -11125,7 +11663,7 @@ var DeviceMailboxTransport = class {
|
|
|
11125
11663
|
));
|
|
11126
11664
|
}
|
|
11127
11665
|
async readResponse() {
|
|
11128
|
-
const raw = await this.mailbox
|
|
11666
|
+
const raw = await readMailboxFile(this.mailbox, this.paths.response);
|
|
11129
11667
|
return raw === void 0 ? void 0 : parseResponse(raw);
|
|
11130
11668
|
}
|
|
11131
11669
|
};
|
|
@@ -11200,6 +11738,18 @@ async function delayUntil(deadline) {
|
|
|
11200
11738
|
const remaining = deadline - Date.now();
|
|
11201
11739
|
if (remaining > 0) await new Promise((resolve13) => setTimeout(resolve13, Math.min(40, remaining)));
|
|
11202
11740
|
}
|
|
11741
|
+
var kMailboxLockCodes = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES"]);
|
|
11742
|
+
async function readMailboxFile(mailbox, path) {
|
|
11743
|
+
try {
|
|
11744
|
+
return await mailbox.read(path);
|
|
11745
|
+
} catch (error) {
|
|
11746
|
+
if (isMailboxLockError(error)) return void 0;
|
|
11747
|
+
throw error;
|
|
11748
|
+
}
|
|
11749
|
+
}
|
|
11750
|
+
function isMailboxLockError(error) {
|
|
11751
|
+
return typeof error === "object" && error !== null && "code" in error && kMailboxLockCodes.has(String(error.code));
|
|
11752
|
+
}
|
|
11203
11753
|
|
|
11204
11754
|
// src/runner/deviceSignal.ts
|
|
11205
11755
|
init_shared();
|
|
@@ -11925,140 +12475,6 @@ async function sampleHud(page, assertions) {
|
|
|
11925
12475
|
|
|
11926
12476
|
// src/runner/steps.ts
|
|
11927
12477
|
init_browser();
|
|
11928
|
-
var DEFAULT_XVFB_SCREEN = "1600x900x24";
|
|
11929
|
-
var HOST_DISPLAY_ENV = "TN_PLAYTEST_HOST_DISPLAY";
|
|
11930
|
-
var STRIPPED_WAYLAND_VARS = ["WAYLAND_DISPLAY", "WAYLAND_SOCKET", "XDG_SESSION_TYPE"];
|
|
11931
|
-
var X11_SOCKET_DIR = "/tmp/.X11-unix";
|
|
11932
|
-
function decideDisplayStrategy(input) {
|
|
11933
|
-
if (input.platform !== "linux") return { kind: "host" };
|
|
11934
|
-
const privateXvfb = {
|
|
11935
|
-
kind: "private-xvfb",
|
|
11936
|
-
screen: input.env.TN_XVFB_SCREEN ?? DEFAULT_XVFB_SCREEN
|
|
11937
|
-
};
|
|
11938
|
-
if (!hostDisplayRequested(input.env)) return privateXvfb;
|
|
11939
|
-
const display = input.env.DISPLAY;
|
|
11940
|
-
if (display !== void 0 && display.length > 0 && (input.displaySocketExists ?? x11SocketExists)(display)) {
|
|
11941
|
-
return { display, kind: "existing" };
|
|
11942
|
-
}
|
|
11943
|
-
return privateXvfb;
|
|
11944
|
-
}
|
|
11945
|
-
function hostDisplayRequested(env) {
|
|
11946
|
-
const value = env[HOST_DISPLAY_ENV];
|
|
11947
|
-
return value === "1" || value?.toLowerCase() === "true";
|
|
11948
|
-
}
|
|
11949
|
-
function x11SocketExists(display) {
|
|
11950
|
-
const number = displayNumber(display);
|
|
11951
|
-
return number === void 0 ? false : existsSync(join(X11_SOCKET_DIR, `X${number}`));
|
|
11952
|
-
}
|
|
11953
|
-
function displayNumber(display) {
|
|
11954
|
-
const parsed = Number.parseInt(display.replace(/^:/u, ""), 10);
|
|
11955
|
-
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
11956
|
-
}
|
|
11957
|
-
function childEnvForDisplay(env, display) {
|
|
11958
|
-
const child = { ...env };
|
|
11959
|
-
for (const name of STRIPPED_WAYLAND_VARS) delete child[name];
|
|
11960
|
-
child.DISPLAY = display;
|
|
11961
|
-
return child;
|
|
11962
|
-
}
|
|
11963
|
-
function runNeedsPixels(config, scenario) {
|
|
11964
|
-
if (config.headless !== true) return true;
|
|
11965
|
-
const takesScreenshot = scenario.artifacts?.screenshots !== false || scenario.steps.some(({ screenshot }) => screenshot !== void 0);
|
|
11966
|
-
const evaluatesVisual = (scenario.assert?.visual?.length ?? 0) > 0;
|
|
11967
|
-
return takesScreenshot || evaluatesVisual || scenario.assert?.framebufferCoverage !== void 0;
|
|
11968
|
-
}
|
|
11969
|
-
async function provideDisplay(options = {}) {
|
|
11970
|
-
const env = options.env ?? process.env;
|
|
11971
|
-
const platform = options.platform ?? process.platform;
|
|
11972
|
-
const strategy = decideDisplayStrategy({
|
|
11973
|
-
displaySocketExists: options.displaySocketExists,
|
|
11974
|
-
env,
|
|
11975
|
-
platform
|
|
11976
|
-
});
|
|
11977
|
-
if (strategy.kind === "host") {
|
|
11978
|
-
return { display: void 0, env: { ...env }, release: async () => void 0, strategy };
|
|
11979
|
-
}
|
|
11980
|
-
if (strategy.kind === "existing") {
|
|
11981
|
-
return {
|
|
11982
|
-
display: strategy.display,
|
|
11983
|
-
env: childEnvForDisplay(env, strategy.display),
|
|
11984
|
-
release: async () => void 0,
|
|
11985
|
-
strategy
|
|
11986
|
-
};
|
|
11987
|
-
}
|
|
11988
|
-
const commandExists2 = options.commandExists ?? defaultCommandExists;
|
|
11989
|
-
if (!commandExists2("Xvfb")) {
|
|
11990
|
-
throw new Error(
|
|
11991
|
-
"No usable X display is available and Xvfb is not installed, so this pixel-producing run cannot start (Debian/Ubuntu 'xvfb', Arch 'xorg-server-xvfb', Fedora 'xorg-x11-server-Xvfb'). Refusing to render blind."
|
|
11992
|
-
);
|
|
11993
|
-
}
|
|
11994
|
-
const spawnProcess = options.spawnProcess ?? spawn;
|
|
11995
|
-
const xvfb = spawnProcess("Xvfb", [
|
|
11996
|
-
"-displayfd",
|
|
11997
|
-
"3",
|
|
11998
|
-
"-nolisten",
|
|
11999
|
-
"tcp",
|
|
12000
|
-
"-screen",
|
|
12001
|
-
"0",
|
|
12002
|
-
strategy.screen
|
|
12003
|
-
], { stdio: ["ignore", "ignore", "pipe", "pipe"] });
|
|
12004
|
-
xvfb.on?.("error", () => void 0);
|
|
12005
|
-
try {
|
|
12006
|
-
const number = await readXvfbDisplayNumber(xvfb);
|
|
12007
|
-
const display = `:${number}`;
|
|
12008
|
-
return {
|
|
12009
|
-
display,
|
|
12010
|
-
env: childEnvForDisplay(env, display),
|
|
12011
|
-
release: () => stopXvfb(xvfb),
|
|
12012
|
-
strategy
|
|
12013
|
-
};
|
|
12014
|
-
} catch (error) {
|
|
12015
|
-
await stopXvfb(xvfb);
|
|
12016
|
-
throw error;
|
|
12017
|
-
}
|
|
12018
|
-
}
|
|
12019
|
-
var XVFB_DISPLAY_TIMEOUT_MS = 1e4;
|
|
12020
|
-
async function readXvfbDisplayNumber(xvfb) {
|
|
12021
|
-
const report = xvfb.stdio[3];
|
|
12022
|
-
if (report === null || report === void 0 || typeof report.on !== "function") {
|
|
12023
|
-
throw new Error("Xvfb was spawned without a display-report descriptor to read.");
|
|
12024
|
-
}
|
|
12025
|
-
const stream = report;
|
|
12026
|
-
return new Promise((resolveDisplay, rejectDisplay) => {
|
|
12027
|
-
let settled = false;
|
|
12028
|
-
const finish = (settle) => {
|
|
12029
|
-
if (settled) return;
|
|
12030
|
-
settled = true;
|
|
12031
|
-
clearTimeout(timer);
|
|
12032
|
-
stream.removeListener("data", onData);
|
|
12033
|
-
stream.removeListener("close", onClose);
|
|
12034
|
-
settle();
|
|
12035
|
-
};
|
|
12036
|
-
const onData = (chunk) => {
|
|
12037
|
-
const number = Number.parseInt(String(chunk).trim(), 10);
|
|
12038
|
-
if (Number.isInteger(number) && number >= 0) finish(() => resolveDisplay(number));
|
|
12039
|
-
};
|
|
12040
|
-
const onClose = () => finish(() => rejectDisplay(new Error("Xvfb exited before it reported a display.")));
|
|
12041
|
-
const timer = setTimeout(() => finish(() => {
|
|
12042
|
-
rejectDisplay(new Error(`Xvfb did not report a display within ${XVFB_DISPLAY_TIMEOUT_MS}ms.`));
|
|
12043
|
-
}), XVFB_DISPLAY_TIMEOUT_MS);
|
|
12044
|
-
stream.on("data", onData);
|
|
12045
|
-
stream.on("close", onClose);
|
|
12046
|
-
});
|
|
12047
|
-
}
|
|
12048
|
-
async function stopXvfb(xvfb) {
|
|
12049
|
-
const exitedAlready = () => (xvfb.exitCode ?? null) !== null || (xvfb.signalCode ?? null) !== null;
|
|
12050
|
-
if (exitedAlready()) return;
|
|
12051
|
-
xvfb.kill("SIGTERM");
|
|
12052
|
-
const started = Date.now();
|
|
12053
|
-
while (Date.now() - started < 1e3 && !exitedAlready()) {
|
|
12054
|
-
await new Promise((resolveWait) => setTimeout(resolveWait, 25));
|
|
12055
|
-
}
|
|
12056
|
-
if (!exitedAlready()) xvfb.kill("SIGKILL");
|
|
12057
|
-
}
|
|
12058
|
-
function defaultCommandExists(command) {
|
|
12059
|
-
const paths = (process.env.PATH ?? "").split(":").filter((segment) => segment.length > 0);
|
|
12060
|
-
return paths.some((directory) => existsSync(join(directory, command)));
|
|
12061
|
-
}
|
|
12062
12478
|
var DEFAULT_COLUMNS = 32;
|
|
12063
12479
|
var DEFAULT_ROWS = 18;
|
|
12064
12480
|
var PROBE_KEY = "__THREENATIVE_FRAMEBUFFER_COVERAGE_PROBE__";
|
|
@@ -12910,6 +13326,7 @@ async function provideRunDisplay() {
|
|
|
12910
13326
|
const provided = await provideDisplay();
|
|
12911
13327
|
writeCaptureState({
|
|
12912
13328
|
captureDisplay: {
|
|
13329
|
+
...provided.compositor === void 0 ? {} : { compositor: provided.compositor },
|
|
12913
13330
|
...provided.display === void 0 ? {} : { display: provided.display },
|
|
12914
13331
|
...provided.strategy.kind === "private-xvfb" ? { screen: provided.strategy.screen } : {},
|
|
12915
13332
|
strategy: provided.strategy.kind
|
|
@@ -12924,6 +13341,10 @@ function writeCaptureState(payload) {
|
|
|
12924
13341
|
function addPreflightDiagnostic(report, diagnostic2) {
|
|
12925
13342
|
return diagnostic2 === void 0 ? report : { ...report, diagnostics: [diagnostic2, ...report.diagnostics] };
|
|
12926
13343
|
}
|
|
13344
|
+
var SOFTWARE_DEVICE_LOSS = /TN_DEVICE_LOST|WebGPU Device Lost|A valid external Instance reference no longer exists/iu;
|
|
13345
|
+
function isSoftwareDeviceLossEntry(entry) {
|
|
13346
|
+
return (entry.type === "error" || entry.type === "assert" || entry.type === "pageerror") && SOFTWARE_DEVICE_LOSS.test(entry.text);
|
|
13347
|
+
}
|
|
12927
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) {
|
|
12928
13349
|
const movementSample = isAnonymousMovementScenario(scenario) ? observedMovementSample(movementSamples) : void 0;
|
|
12929
13350
|
const entity = scenario.assert?.movement?.entity ?? scenario.subject ?? movementSample?.entity ?? "";
|
|
@@ -12939,6 +13360,10 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12939
13360
|
const movementDelta = beforePosition === void 0 || afterPosition === void 0 ? void 0 : subtract(afterPosition, beforePosition);
|
|
12940
13361
|
const distance = movementDelta === void 0 ? 0 : length(movementDelta);
|
|
12941
13362
|
const performanceSeries = scenario.assert?.performance === void 0 && scenario.assert?.parity === void 0 ? void 0 : afterSnapshot?.runtimeDiagnosticsSeries ?? beforeSnapshot?.runtimeDiagnosticsSeries;
|
|
13363
|
+
const softwareAdapter = capture?.rendererKind === "webgpu" ? softwareAdapterName(capture.adapter) : void 0;
|
|
13364
|
+
const softwareLane = config.allowSoftwareAdapter === true && softwareAdapter !== void 0;
|
|
13365
|
+
const deviceLossEntries = softwareLane ? consoleEntries.filter(isSoftwareDeviceLossEntry) : [];
|
|
13366
|
+
const observedConsoleEntries = deviceLossEntries.length === 0 ? consoleEntries : consoleEntries.filter((entry) => !isSoftwareDeviceLossEntry(entry));
|
|
12942
13367
|
const diagnostics = [];
|
|
12943
13368
|
if (runtimeReady === false && scenario.assert?.diagnostics?.runtimeReady === true) {
|
|
12944
13369
|
diagnostics.push({
|
|
@@ -12971,7 +13396,7 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12971
13396
|
// Honest placement reporting: what the scenario asked to override, and what applied.
|
|
12972
13397
|
...setup === void 0 ? {} : { setup },
|
|
12973
13398
|
observations: buildObservations({
|
|
12974
|
-
console:
|
|
13399
|
+
console: observedConsoleEntries,
|
|
12975
13400
|
...components === void 0 ? {} : { components },
|
|
12976
13401
|
...labeledSamples.length === 0 ? {} : {
|
|
12977
13402
|
componentSeries: labeledSamples.map(({ label, snapshot }) => ({ label, snapshots: snapshot.components ?? {}, tick: snapshot.clock.tick ?? 0 })),
|
|
@@ -12985,6 +13410,9 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
12985
13410
|
network: networkEntries,
|
|
12986
13411
|
...performanceSeries === void 0 ? {} : { performanceSeries },
|
|
12987
13412
|
...afterSnapshot?.pipelineCensus === void 0 && beforeSnapshot?.pipelineCensus === void 0 ? {} : { pipelineCensus: afterSnapshot?.pipelineCensus ?? beforeSnapshot?.pipelineCensus },
|
|
13413
|
+
// Like the pipeline census: a report about the frame it was requested on, kept whole. The
|
|
13414
|
+
// last sample wins, because a capture describes the world as the run left it.
|
|
13415
|
+
...afterSnapshot?.geometry === void 0 && beforeSnapshot?.geometry === void 0 ? {} : { geometry: afterSnapshot?.geometry ?? beforeSnapshot?.geometry },
|
|
12988
13416
|
...afterSnapshot?.renderChain === void 0 && beforeSnapshot?.renderChain === void 0 ? {} : { renderChain: afterSnapshot?.renderChain ?? beforeSnapshot?.renderChain },
|
|
12989
13417
|
resources: resourceObservations(beforeSnapshot, afterSnapshot),
|
|
12990
13418
|
// The room as the run left it, falling back to how it started. A scene assertion is about
|
|
@@ -13006,8 +13434,8 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
13006
13434
|
},
|
|
13007
13435
|
...afterSnapshot?.physicsDebugSeries === void 0 ? {} : { physicsDebugSeries: afterSnapshot.physicsDebugSeries },
|
|
13008
13436
|
...beforeSnapshot?.physicsDebugSeries?.[0]?.snapshot === void 0 ? {} : { physicsDebugBefore: beforeSnapshot.physicsDebugSeries[0].snapshot },
|
|
13009
|
-
runtimeDiagnostics: normalizedRuntimeDiagnostics(afterSnapshot, scenario,
|
|
13010
|
-
...beforeSnapshot === void 0 ? {} : { runtimeDiagnosticsBefore: normalizedRuntimeDiagnostics(beforeSnapshot, scenario,
|
|
13437
|
+
runtimeDiagnostics: normalizedRuntimeDiagnostics(afterSnapshot, scenario, observedConsoleEntries),
|
|
13438
|
+
...beforeSnapshot === void 0 ? {} : { runtimeDiagnosticsBefore: normalizedRuntimeDiagnostics(beforeSnapshot, scenario, observedConsoleEntries) },
|
|
13011
13439
|
...visual === void 0 ? {} : { visual }
|
|
13012
13440
|
})
|
|
13013
13441
|
};
|
|
@@ -13019,7 +13447,14 @@ function buildReport(config, scenario, beforeSnapshot, afterSnapshot, consoleEnt
|
|
|
13019
13447
|
const assertionResults = [...evaluated.assertions, ...cameraResult === void 0 ? [] : [cameraResult]];
|
|
13020
13448
|
const trivialityOptOuts = collectTrivialityOptOuts(assertionResults);
|
|
13021
13449
|
const allDiagnostics = [...diagnostics, ...evaluated.diagnostics];
|
|
13022
|
-
|
|
13450
|
+
if (deviceLossEntries.length > 0) {
|
|
13451
|
+
allDiagnostics.push({
|
|
13452
|
+
code: "TN_PLAYTEST_SOFTWARE_DEVICE_LOST",
|
|
13453
|
+
message: `The software adapter '${softwareAdapter}' lost its WebGPU device during the run; ${deviceLossEntries.length} device-loss console error(s) were recorded instead of failing noConsoleErrors. This lane is not render evidence.`,
|
|
13454
|
+
severity: "warning",
|
|
13455
|
+
suggestion: "Expected on a CPU rasteriser when a frame outlasts the GPU process; rerun on a hardware adapter before reading any pixels."
|
|
13456
|
+
});
|
|
13457
|
+
}
|
|
13023
13458
|
if (softwareAdapter !== void 0 && config.allowSoftwareAdapter !== true) {
|
|
13024
13459
|
allDiagnostics.push({
|
|
13025
13460
|
code: "TN_PLAYTEST_SOFTWARE_ADAPTER",
|
|
@@ -13359,6 +13794,26 @@ function removeStrandedProfiles(before, root = tmpdir()) {
|
|
|
13359
13794
|
}
|
|
13360
13795
|
return removed;
|
|
13361
13796
|
}
|
|
13797
|
+
async function startBrowserCpuProfile(page, outputPath) {
|
|
13798
|
+
const cdp = await page.context().newCDPSession(page);
|
|
13799
|
+
await cdp.send("Profiler.enable");
|
|
13800
|
+
await cdp.send("Profiler.start");
|
|
13801
|
+
return {
|
|
13802
|
+
async stop() {
|
|
13803
|
+
const { profile } = await cdp.send("Profiler.stop");
|
|
13804
|
+
await writeFile(outputPath, `${JSON.stringify(profile)}
|
|
13805
|
+
`);
|
|
13806
|
+
return outputPath;
|
|
13807
|
+
}
|
|
13808
|
+
};
|
|
13809
|
+
}
|
|
13810
|
+
function assertCpuProfileTargetSupported(target, cpuProfilePath) {
|
|
13811
|
+
if (cpuProfilePath === void 0) return;
|
|
13812
|
+
if (target === "browser" || target === "desktop") return;
|
|
13813
|
+
throw new Error(
|
|
13814
|
+
`TN_PLAYTEST_CPU_PROFILE_UNSUPPORTED: --cpu-prof is not supported on the ${target} target; use the browser or desktop target.`
|
|
13815
|
+
);
|
|
13816
|
+
}
|
|
13362
13817
|
|
|
13363
13818
|
// src/runner/runner.ts
|
|
13364
13819
|
var SCREENSHOT_TIMEOUT_MS = 12e4;
|
|
@@ -13442,6 +13897,25 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13442
13897
|
await serverTeardownPromise;
|
|
13443
13898
|
};
|
|
13444
13899
|
let profilesBeforeLaunch;
|
|
13900
|
+
let cpuProfile;
|
|
13901
|
+
let cpuProfileStopped = false;
|
|
13902
|
+
const stopCpuProfile = async (failClosed) => {
|
|
13903
|
+
if (cpuProfile === void 0 || cpuProfileStopped) return;
|
|
13904
|
+
cpuProfileStopped = true;
|
|
13905
|
+
try {
|
|
13906
|
+
const written = await cpuProfile.stop();
|
|
13907
|
+
process.stderr.write(`${JSON.stringify({ cpuProfile: written })}
|
|
13908
|
+
`);
|
|
13909
|
+
} catch (error) {
|
|
13910
|
+
if (failClosed) {
|
|
13911
|
+
throw new Error(`TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED: ${error instanceof Error ? error.message : String(error)}`);
|
|
13912
|
+
}
|
|
13913
|
+
process.stderr.write(
|
|
13914
|
+
`${JSON.stringify({ diagnostics: [{ code: "TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED", message: error instanceof Error ? error.message : String(error), severity: "error" }] })}
|
|
13915
|
+
`
|
|
13916
|
+
);
|
|
13917
|
+
}
|
|
13918
|
+
};
|
|
13445
13919
|
const teardown = async (stopManagedServerOnTeardown = ownsServer) => {
|
|
13446
13920
|
teardownPromise ??= (async () => {
|
|
13447
13921
|
await teardownBrowserSession(page, context, browser, browserLaunch, options.remoteBrowser);
|
|
@@ -13586,13 +14060,15 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13586
14060
|
"entities",
|
|
13587
14061
|
"resources",
|
|
13588
14062
|
...scenario.assert?.aerodynamics === void 0 && scenario.assert?.contacts === void 0 && scenario.assert?.settled === void 0 ? [] : ["physicsDebugSeries"],
|
|
13589
|
-
...scenario.assert?.performance === void 0 ? [] : ["runtimeDiagnosticsSeries"],
|
|
14063
|
+
...scenario.assert?.performance === void 0 && scenario.assert?.parity === void 0 ? [] : ["runtimeDiagnosticsSeries"],
|
|
13590
14064
|
...scenario.assert?.renderChain === void 0 ? [] : ["renderChain"]
|
|
13591
14065
|
],
|
|
13592
14066
|
resources: resourceIds,
|
|
13593
14067
|
// One selector per assertion, in scenario order: the evaluator reads observation `i` for
|
|
13594
14068
|
// assertion `i`, so the mapping has to be positional and never deduplicated.
|
|
13595
|
-
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) }
|
|
14069
|
+
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) },
|
|
14070
|
+
// One armed capture per sample; absent means the bridge does no geometry work at all.
|
|
14071
|
+
...scenario.assert?.geometry === void 0 ? {} : { geometry: scenario.assert.geometry }
|
|
13596
14072
|
};
|
|
13597
14073
|
const labeledSamples = [];
|
|
13598
14074
|
const capturesAnonymousMovement = isAnonymousMovementScenario(scenario);
|
|
@@ -13732,6 +14208,9 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13732
14208
|
scenario.artifacts?.screenshots === "before-after" ? join(activeConfig.artifactDirectory, "before.png") : void 0
|
|
13733
14209
|
) : await capturePage("before.png", scenario.artifacts?.screenshots === "before-after" ? { path: join(activeConfig.artifactDirectory, "before.png") } : {}) : void 0;
|
|
13734
14210
|
let framebufferCoverage;
|
|
14211
|
+
if (activeConfig.cpuProfilePath !== void 0) {
|
|
14212
|
+
cpuProfile = await startBrowserCpuProfile(activePage, activeConfig.cpuProfilePath);
|
|
14213
|
+
}
|
|
13735
14214
|
for (const [index, step] of scenario.steps.entries()) {
|
|
13736
14215
|
const framebufferAssertion = scenario.assert?.framebufferCoverage;
|
|
13737
14216
|
if (framebufferAssertion !== void 0 && step.label === framebufferAssertion.window.startStep) {
|
|
@@ -13829,6 +14308,7 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13829
14308
|
network: networkEntries,
|
|
13830
14309
|
runtimeTrace: normalizedRuntimeDiagnostics(afterSnapshot, scenario, consoleEntries)
|
|
13831
14310
|
});
|
|
14311
|
+
await stopCpuProfile(true);
|
|
13832
14312
|
if (options.remoteBrowser === void 0) await context.close();
|
|
13833
14313
|
else await page.close();
|
|
13834
14314
|
return addPreflightDiagnostic(report, preflight);
|
|
@@ -13844,6 +14324,7 @@ async function runStandalonePlaytestInternal(config, options = {}) {
|
|
|
13844
14324
|
} finally {
|
|
13845
14325
|
process.off("SIGINT", handleSignal);
|
|
13846
14326
|
process.off("SIGTERM", handleSignal);
|
|
14327
|
+
await stopCpuProfile(false);
|
|
13847
14328
|
await teardown();
|
|
13848
14329
|
await providedDisplay?.release().catch(() => void 0);
|
|
13849
14330
|
await captureLease?.release().catch(() => void 0);
|
|
@@ -14266,12 +14747,21 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14266
14747
|
"diagnostics",
|
|
14267
14748
|
"entities",
|
|
14268
14749
|
"resources",
|
|
14269
|
-
...scenario.assert?.aerodynamics === void 0 && scenario.assert?.contacts === void 0 && scenario.assert?.settled === void 0 ? [] : ["physicsDebugSeries"]
|
|
14750
|
+
...scenario.assert?.aerodynamics === void 0 && scenario.assert?.contacts === void 0 && scenario.assert?.settled === void 0 ? [] : ["physicsDebugSeries"],
|
|
14751
|
+
// The same two fields the browser lane requests, for the same reason: the bridge answers
|
|
14752
|
+
// only what it was asked for, so a `performance`, `parity` or `renderChain` assertion on a
|
|
14753
|
+
// device or desktop target used to evaluate against an empty series and fail as
|
|
14754
|
+
// "unobserved" even though the handshake advertises `runtime.performance` and
|
|
14755
|
+
// `runtime.renderChain`.
|
|
14756
|
+
...scenario.assert?.performance === void 0 && scenario.assert?.parity === void 0 ? [] : ["runtimeDiagnosticsSeries"],
|
|
14757
|
+
...scenario.assert?.renderChain === void 0 ? [] : ["renderChain"]
|
|
14270
14758
|
],
|
|
14271
14759
|
resources: observedResourceIds(scenario),
|
|
14272
14760
|
// One selector per assertion in scenario order: the evaluator reads observation `i` for
|
|
14273
14761
|
// assertion `i`, so the mapping has to be positional and never deduplicated.
|
|
14274
|
-
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) }
|
|
14762
|
+
...scenario.assert?.sceneNodes === void 0 ? {} : { sceneNodes: scenario.assert.sceneNodes.map(({ select }) => select) },
|
|
14763
|
+
// One armed capture per sample; absent means the bridge does no geometry work at all.
|
|
14764
|
+
...scenario.assert?.geometry === void 0 ? {} : { geometry: scenario.assert.geometry }
|
|
14275
14765
|
};
|
|
14276
14766
|
const before = await bridge.sample(sampleRequest);
|
|
14277
14767
|
const pathEntity = scenario.assert?.movement?.pathLength === void 0 ? void 0 : scenario.assert.movement.entity ?? scenario.subject;
|
|
@@ -14284,6 +14774,9 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14284
14774
|
const heldKeys = /* @__PURE__ */ new Set();
|
|
14285
14775
|
let pointerButtons = 0;
|
|
14286
14776
|
let pointerCount = 0;
|
|
14777
|
+
let pointerX = 0;
|
|
14778
|
+
let pointerY = 0;
|
|
14779
|
+
let pointerHeld = false;
|
|
14287
14780
|
for (const [index, step] of scenario.steps.entries()) {
|
|
14288
14781
|
await throwIfAborted(target);
|
|
14289
14782
|
const framebufferAssertion = scenario.assert?.framebufferCoverage;
|
|
@@ -14329,11 +14822,14 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14329
14822
|
if (step.pointerPosition !== void 0) {
|
|
14330
14823
|
const previousPointerButtons = pointerButtons;
|
|
14331
14824
|
pointerButtons = step.pointerPosition.buttons ?? pointerButtons;
|
|
14825
|
+
if (pointerButtons !== 0) pointerHeld = true;
|
|
14826
|
+
pointerX = step.pointerPosition.x * scenario.viewport.width;
|
|
14827
|
+
pointerY = step.pointerPosition.y * scenario.viewport.height;
|
|
14332
14828
|
await transport.call("input.pointer", {
|
|
14333
14829
|
buttons: pointerButtons,
|
|
14334
14830
|
type: pointerButtons === 0 ? "move" : previousPointerButtons === 0 ? "down" : "move",
|
|
14335
|
-
x:
|
|
14336
|
-
y:
|
|
14831
|
+
x: pointerX,
|
|
14832
|
+
y: pointerY
|
|
14337
14833
|
});
|
|
14338
14834
|
}
|
|
14339
14835
|
if (step.pointers !== void 0) {
|
|
@@ -14407,9 +14903,10 @@ async function runDevicePlaytestInternal(config, target, cleanupState) {
|
|
|
14407
14903
|
if (capturesAnonymousMovement) afterStep = await bridge.sample(sampleRequest);
|
|
14408
14904
|
}
|
|
14409
14905
|
}
|
|
14410
|
-
if (step.
|
|
14906
|
+
if (pointerHeld && step.release && step.kind !== "wait") {
|
|
14411
14907
|
pointerButtons = 0;
|
|
14412
|
-
|
|
14908
|
+
pointerHeld = false;
|
|
14909
|
+
await transport.call("input.pointer", { buttons: 0, type: "up", x: pointerX, y: pointerY });
|
|
14413
14910
|
}
|
|
14414
14911
|
if (step.pointers !== void 0 && step.release) {
|
|
14415
14912
|
await setDevicePointers(target, transport, [], scenario.viewport);
|
|
@@ -14566,7 +15063,7 @@ function createDeviceTransport(driver, endpoint, paths, operationTimeoutMs) {
|
|
|
14566
15063
|
return new DeviceBridgeTransport(endpoint);
|
|
14567
15064
|
}
|
|
14568
15065
|
async function setDevicePointers(target, transport, pointers, viewport) {
|
|
14569
|
-
if (target.name === "ios") {
|
|
15066
|
+
if (target.name === "ios" || target.name === "desktop") {
|
|
14570
15067
|
await transport.call("input.pointers", {
|
|
14571
15068
|
pointers: pointers.map((pointer) => ({
|
|
14572
15069
|
...pointer.buttons === void 0 ? {} : { buttons: pointer.buttons },
|
|
@@ -14655,14 +15152,6 @@ function unsupportedAssertion(scenario, target, hasPointerTransport) {
|
|
|
14655
15152
|
target
|
|
14656
15153
|
);
|
|
14657
15154
|
}
|
|
14658
|
-
const hasMultiPointerInput = scenario.steps.some((step) => step.pointers !== void 0);
|
|
14659
|
-
if (hasMultiPointerInput && target === "desktop") {
|
|
14660
|
-
return unsupportedDiagnostic(
|
|
14661
|
-
"complete held-pointer input",
|
|
14662
|
-
"Run this scenario on --target browser or --target android; the desktop mailbox host exposes one pointer.",
|
|
14663
|
-
target
|
|
14664
|
-
);
|
|
14665
|
-
}
|
|
14666
15155
|
if (scenario.assert?.deviceMetrics !== void 0 && target !== "android") {
|
|
14667
15156
|
return unsupportedDiagnostic(
|
|
14668
15157
|
"device thermal and power assertions",
|
|
@@ -14915,12 +15404,20 @@ var LocalDeviceMailbox = class {
|
|
|
14915
15404
|
try {
|
|
14916
15405
|
return await readFile(path, "utf8");
|
|
14917
15406
|
} catch (error) {
|
|
14918
|
-
if (isMissingFile(error)) return void 0;
|
|
15407
|
+
if (isMissingFile(error) || isTransientMailboxLock(error)) return void 0;
|
|
14919
15408
|
throw error;
|
|
14920
15409
|
}
|
|
14921
15410
|
}
|
|
14922
15411
|
async remove(path) {
|
|
14923
|
-
|
|
15412
|
+
for (let retry = 0; ; retry += 1) {
|
|
15413
|
+
try {
|
|
15414
|
+
await rm(path, { force: true });
|
|
15415
|
+
return;
|
|
15416
|
+
} catch (error) {
|
|
15417
|
+
if (retry >= 10 || !isTransientMailboxLock(error)) throw error;
|
|
15418
|
+
await delay2(20);
|
|
15419
|
+
}
|
|
15420
|
+
}
|
|
14924
15421
|
}
|
|
14925
15422
|
async write(path, contents) {
|
|
14926
15423
|
await mkdir(dirname(path), { recursive: true });
|
|
@@ -15054,10 +15551,12 @@ var DesktopPlaytestDriver = class {
|
|
|
15054
15551
|
function desktopConsoleType(stream, line) {
|
|
15055
15552
|
const text = line.trimStart();
|
|
15056
15553
|
if (/^(?:\[error\]|(?:error|fatal):)/iu.test(text)) return "error";
|
|
15057
|
-
if (/^(?:\[warn(?:ing)?\]|warning:|MESA-EGL:\s*warning:|\*\* \([^)]*\): WARNING \*\*:)/iu.test(
|
|
15554
|
+
if (/^(?:\[warn(?:ing)?\]|warning:|MESA-EGL:\s*warning:|libEGL\s+warning:|\*\* \([^)]*\): WARNING \*\*:|\([^)]*\): dbind-WARNING \*\*:)/iu.test(
|
|
15555
|
+
text
|
|
15556
|
+
)) {
|
|
15058
15557
|
return "warning";
|
|
15059
15558
|
}
|
|
15060
|
-
if (/^Gtk-Message:/u.test(text)) return "log";
|
|
15559
|
+
if (/^ALSA lib\b|^\[Audio\] Failed to open audio device: ALSA:|^Gtk-Message:/u.test(text)) return "log";
|
|
15061
15560
|
return stream === "stderr" ? "error" : "log";
|
|
15062
15561
|
}
|
|
15063
15562
|
function terminateProcess(child, signal) {
|
|
@@ -15106,6 +15605,10 @@ function isProcessExited(child) {
|
|
|
15106
15605
|
function delay2(milliseconds) {
|
|
15107
15606
|
return new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
15108
15607
|
}
|
|
15608
|
+
function isTransientMailboxLock(error) {
|
|
15609
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
15610
|
+
return code === "EPERM" || code === "EBUSY";
|
|
15611
|
+
}
|
|
15109
15612
|
function isMissingFile(error) {
|
|
15110
15613
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
15111
15614
|
}
|
|
@@ -15113,7 +15616,8 @@ function isMissingFile(error) {
|
|
|
15113
15616
|
// src/runner/desktopRunner.ts
|
|
15114
15617
|
init_shared();
|
|
15115
15618
|
function desktopHostArgs(config) {
|
|
15116
|
-
|
|
15619
|
+
const args = config.desktop?.hostArgs ?? [];
|
|
15620
|
+
return config.cpuProfilePath === void 0 ? args : [...args, `--cpu-prof=${config.cpuProfilePath}`];
|
|
15117
15621
|
}
|
|
15118
15622
|
async function runDesktopPlaytest(config, dependencies = {}) {
|
|
15119
15623
|
const executable = config.desktop?.executable;
|
|
@@ -15240,6 +15744,22 @@ function cleanupFailure2(errors) {
|
|
|
15240
15744
|
return new AggregateError(errors, "Desktop playtest cleanup failed.");
|
|
15241
15745
|
}
|
|
15242
15746
|
var execFileAsync4 = promisify(execFile);
|
|
15747
|
+
var kIosCompactAppleRecord = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (Df|Db|A|I|E|F) +\S+\[\d+:[0-9a-f]+\] \[([^\]:]+):[^\]]+\]/u;
|
|
15748
|
+
var kIosExplicitErrorMarker = /\[error\]|\bFATAL\b|GPUValidationError|uncaught/iu;
|
|
15749
|
+
var kIosAppleFaultFailure = /\b(?:error|fail(?:ed|ure)?|abort(?:ed)?|crash(?:ed)?)\b/iu;
|
|
15750
|
+
var kIosTextError = /\[error\]|\b(?:Error|Fault|FATAL|FAILED|GPUValidationError|uncaught)\b/u;
|
|
15751
|
+
function classifyIosConsoleLine(text) {
|
|
15752
|
+
const compact = kIosCompactAppleRecord.exec(text);
|
|
15753
|
+
if (compact !== null) {
|
|
15754
|
+
if (kIosExplicitErrorMarker.test(text)) return "error";
|
|
15755
|
+
if (compact[2].startsWith("com.apple.")) {
|
|
15756
|
+
return compact[1] === "F" && kIosAppleFaultFailure.test(text) ? "error" : "log";
|
|
15757
|
+
}
|
|
15758
|
+
if (compact[1] === "E" || compact[1] === "F") return "error";
|
|
15759
|
+
return kIosTextError.test(text) ? "error" : "log";
|
|
15760
|
+
}
|
|
15761
|
+
return kIosTextError.test(text) ? "error" : "log";
|
|
15762
|
+
}
|
|
15243
15763
|
var XcrunIosDriver = class {
|
|
15244
15764
|
constructor(options, run2) {
|
|
15245
15765
|
this.options = options;
|
|
@@ -15276,6 +15796,8 @@ var XcrunIosDriver = class {
|
|
|
15276
15796
|
await this.prepareDevice(endpoint, mailboxRoot);
|
|
15277
15797
|
}
|
|
15278
15798
|
async captureConsole() {
|
|
15799
|
+
if (this.pid === void 0) throw new Error("iOS console capture requires a launched process.");
|
|
15800
|
+
const predicate = `processIdentifier == ${this.pid}`;
|
|
15279
15801
|
const output = this.options.transport === "simulator" ? await this.run([
|
|
15280
15802
|
"simctl",
|
|
15281
15803
|
"spawn",
|
|
@@ -15287,7 +15809,7 @@ var XcrunIosDriver = class {
|
|
|
15287
15809
|
"--last",
|
|
15288
15810
|
"5m",
|
|
15289
15811
|
"--predicate",
|
|
15290
|
-
|
|
15812
|
+
predicate
|
|
15291
15813
|
]) : await this.run([
|
|
15292
15814
|
"devicectl",
|
|
15293
15815
|
"device",
|
|
@@ -15298,12 +15820,9 @@ var XcrunIosDriver = class {
|
|
|
15298
15820
|
"--last",
|
|
15299
15821
|
"5m",
|
|
15300
15822
|
"--predicate",
|
|
15301
|
-
|
|
15823
|
+
predicate
|
|
15302
15824
|
]);
|
|
15303
|
-
return output.split(/\r?\n/u).filter((line) =>
|
|
15304
|
-
text,
|
|
15305
|
-
type: /\b(?:Error|Fault|FATAL|FAILED|GPUValidationError)\b/u.test(text) ? "error" : "log"
|
|
15306
|
-
}));
|
|
15825
|
+
return output.split(/\r?\n/u).filter((line) => line.trim().length > 0).map((text) => ({ text, type: classifyIosConsoleLine(text) }));
|
|
15307
15826
|
}
|
|
15308
15827
|
async isAlive() {
|
|
15309
15828
|
if (this.pid === void 0) return false;
|
|
@@ -15488,9 +16007,6 @@ var XcrunIosDriver = class {
|
|
|
15488
16007
|
device() {
|
|
15489
16008
|
return this.options.device ?? "booted";
|
|
15490
16009
|
}
|
|
15491
|
-
processName() {
|
|
15492
|
-
return basename(this.options.appPath, ".app");
|
|
15493
|
-
}
|
|
15494
16010
|
mailboxPath(path) {
|
|
15495
16011
|
return this.mailboxRoot === void 0 ? path : join(this.mailboxRoot, basename(path));
|
|
15496
16012
|
}
|
|
@@ -17158,6 +17674,20 @@ function classifyRunnerError(error, options = {}) {
|
|
|
17158
17674
|
"Confirm adb can reach the requested serial and Android Chrome exposes its CDP socket, then rerun."
|
|
17159
17675
|
);
|
|
17160
17676
|
}
|
|
17677
|
+
if (message.startsWith("TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED")) {
|
|
17678
|
+
return diagnostic(
|
|
17679
|
+
"TN_PLAYTEST_CPU_PROFILE_WRITE_FAILED",
|
|
17680
|
+
message,
|
|
17681
|
+
"Point --cpu-prof at a writable path; the run is not green without the profile it was asked for."
|
|
17682
|
+
);
|
|
17683
|
+
}
|
|
17684
|
+
if (message.startsWith("TN_PLAYTEST_CPU_PROFILE_UNSUPPORTED")) {
|
|
17685
|
+
return diagnostic(
|
|
17686
|
+
"TN_PLAYTEST_CPU_PROFILE_UNSUPPORTED",
|
|
17687
|
+
message,
|
|
17688
|
+
"Run --cpu-prof on the browser or desktop target, where the profile can be produced."
|
|
17689
|
+
);
|
|
17690
|
+
}
|
|
17161
17691
|
if (message.startsWith("browserType.launch")) {
|
|
17162
17692
|
return diagnostic(
|
|
17163
17693
|
"TN_PLAYTEST_BROWSER_UNAVAILABLE",
|
|
@@ -17292,6 +17822,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
17292
17822
|
return await recordToScenarioCommand(argv.slice(1));
|
|
17293
17823
|
}
|
|
17294
17824
|
config = parseStandalonePlaytestArgs(argv);
|
|
17825
|
+
assertCpuProfileTargetSupported(config.target ?? "browser", config.cpuProfilePath);
|
|
17295
17826
|
const scenarioPaths = config.scenarioPaths ?? [config.scenarioPath];
|
|
17296
17827
|
const reports = config.target === "browser" ? config.device === void 0 ? await runStandalonePlaytests(config) : await runAndroidBrowserPlaytests(config) : await runDevicePlaytests(config, scenarioPaths);
|
|
17297
17828
|
const output = reports.length === 1 ? reports[0] : { pass: reports.every(({ pass }) => pass), reports };
|