@threenative/playtest 0.3.3 → 0.3.5

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.
@@ -1,9 +1,59 @@
1
- import { IPlaytestObservationSnapshot, IPlaytestSetupRequest, JsonValue, IPlaytestBridgeDescription, IPlaytestBridgeReady, IPlaytestSampleRequest } from '../protocol.js';
2
- import { b as IPlaytestScenario, s as IPlaytestObservations, r as IPlaytestFramebufferCoverageObservation, j as IPlaytestCaptureProvenance, z as IPlaytestSetupApplication, l as IPlaytestDeviceMetricsObservation, e as IPlaytestDiagnostic, w as IPlaytestProtocolDiagnostic, i as IPlaytestArtifactRequest, v as IPlaytestPointer } from '../diagnostics-Bpy15z5f.js';
3
- import { Page } from 'playwright';
4
- import { I as IStandalonePlaytestConfig, b as IRunnerConsoleEntry, c as ILabeledPlaytestSample, d as IMovementSampleInterval, a as IStandalonePlaytestReport } from '../shared-eFOF5bZO.js';
5
- export { e as IPlaytestFlagHelp, f as IPlaytestServerConfig, g as IRunStepSamples, M as ManagedServerError, P as PLAYTEST_FLAGS, h as PlaytestCliUsageError, i as failedDiagnosticsAssertion, j as formatUsage, p as parseStandalonePlaytestArgs } from '../shared-eFOF5bZO.js';
1
+ import { I as IStandalonePlaytestConfig, b as IRunnerConsoleEntry, c as ILabeledPlaytestSample, d as IMovementSampleInterval, a as IStandalonePlaytestReport, e as IPlaytestBridgeClient, f as IBridgeTransport } from '../shared-DK12BZyS.js';
2
+ export { g as IPlaytestFlagHelp, h as IPlaytestServerConfig, i as IRunStepSamples, M as ManagedServerError, P as PLAYTEST_FLAGS, j as PlaytestBridgeError, k as PlaytestCliUsageError, l as PlaywrightTransport, m as advanceFixedStep, n as advanceTimeoutMs, o as bridgeWaitTimeoutMs, p as captureVisualSurface, q as connectPlaytestBridge, r as connectPlaytestBridgeTransport, s as failedDiagnosticsAssertion, t as formatUsage, u as parseStandalonePlaytestArgs, v as playtestStepDrivesMovement } from '../shared-DK12BZyS.js';
3
+ import { e as IPlaytestScenario, f as IPlaytestArtifactRequest, k as IPlaytestPointer } from '../schema-base-B5mr_Yr9.js';
4
+ import { n as IPlaytestObservations, m as IPlaytestFramebufferCoverageObservation, f as IPlaytestCaptureProvenance, p as IPlaytestSetupApplication, h as IPlaytestDeviceMetricsObservation, b as IPlaytestDiagnostic, o as IPlaytestProtocolDiagnostic, C as IAndroidAppState, E as IAndroidPointer, F as IAndroidPointerInjection, G as IAndroidDriver } from '../diagnostics-BhS6v2n1.js';
5
+ export { J as AdbAndroidDriver, K as IAndroidDriverOptions, L as IAndroidLifecycleOperation, M as IAndroidTouchViewport, N as IPlaytestDeviceLifecycleObservation, O as IPlaytestDeviceLifecyclePhase, Q as IPlaytestDeviceLifecyclePhysics, R as IPlaytestDeviceLifecycleSteps, S as androidTouchBatches, T as discoverAdb, U as keyboardIsShown, V as parseAndroidConsole, W as parseAndroidTouchViewport, X as rotatedTouchPosition, Y as tapCommand, Z as touchPositionForViewport, _ as touchRotationFromWindowDump, $ as viewportPresentationCommands, a0 as viewportPresentationObserved, a1 as viewportRestoreCommands } from '../diagnostics-BhS6v2n1.js';
6
+ import { IPlaytestObservationSnapshot, JsonValue } from '../protocol.js';
6
7
  import { ChildProcess } from 'node:child_process';
8
+ import { Page } from 'playwright';
9
+
10
+ /**
11
+ * The display half of the capture environment bake-in (abstraction report §2.10).
12
+ *
13
+ * The Layer-1/2/3 saga — headless black canvas, a Wayland session hanging Chromium at 120 s
14
+ * against 175 ms under X11, GPU starvation, blank captures — used to be solved by a wrapper
15
+ * every caller had to remember (`sh scripts/xvfb.sh`). The runner now owns the decision
16
+ * itself: pick a display strategy from the environment, strip the Wayland variables that
17
+ * send Chromium at the wrong windowing system, and provision a *private* Xvfb per run.
18
+ * `scripts/xvfb.sh` stays as a thin compatibility path over the same logic; it is no longer
19
+ * required for playtest runs.
20
+ *
21
+ * On Linux a private Xvfb is the DEFAULT, not the fallback, even when a live X display
22
+ * exists. A run that borrows the operator's desktop opens browser and host windows over
23
+ * whatever they are doing, and a long scenario sweep makes the machine unusable — so the
24
+ * display a run paints on is opt-in, through `TN_PLAYTEST_HOST_DISPLAY`. Opt in when the
25
+ * run genuinely needs the session's real GPU adapter (heavy TSL post chains have been
26
+ * observed falling back to SwiftShader under Xvfb) or when a human wants to watch it.
27
+ *
28
+ * Fail-closed applies here like everywhere else in this package: a run that needs pixels and
29
+ * cannot get a display errors naming the cause. It never falls through to a headless launch
30
+ * whose screenshots are SwiftShader blanks.
31
+ */
32
+ interface IDisplayStrategyHost {
33
+ kind: "host";
34
+ }
35
+ interface IDisplayStrategyExisting {
36
+ display: string;
37
+ kind: "existing";
38
+ }
39
+ interface IDisplayStrategyPrivateXvfb {
40
+ kind: "private-xvfb";
41
+ screen: string;
42
+ }
43
+ type IDisplayStrategy = IDisplayStrategyHost | IDisplayStrategyExisting | IDisplayStrategyPrivateXvfb;
44
+ interface IDisplayDecisionInput {
45
+ env: NodeJS.ProcessEnv;
46
+ /** Availability override. By default, xdpyinfo verifies an authenticated X connection. */
47
+ displaySocketExists?: (display: string) => boolean;
48
+ platform: string;
49
+ }
50
+ /**
51
+ * Decide where the browser's pixels come from. On Linux that is a private Xvfb unless the
52
+ * caller asked for the session's display with `TN_PLAYTEST_HOST_DISPLAY`, and even then only
53
+ * when an X connection succeeds. An explicit host request fails rather than silently changing
54
+ * the display being measured. A Wayland session never satisfies a run by itself.
55
+ */
56
+ declare function decideDisplayStrategy(input: IDisplayDecisionInput): IDisplayStrategy;
7
57
 
8
58
  declare function preflightDisplay(config: Pick<IStandalonePlaytestConfig, "headless">, scenario: Pick<IPlaytestScenario, "artifacts" | "assert" | "steps">, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): IPlaytestDiagnostic | undefined;
9
59
  declare function buildReport(config: IStandalonePlaytestConfig, scenario: IPlaytestScenario, beforeSnapshot: IPlaytestObservationSnapshot | undefined, afterSnapshot: IPlaytestObservationSnapshot | undefined, consoleEntries: IRunnerConsoleEntry[], networkEntries: Array<{
@@ -16,75 +66,7 @@ declare function buildReport(config: IStandalonePlaytestConfig, scenario: IPlayt
16
66
  code: "TN_CAPTURE_BLANK";
17
67
  label: string;
18
68
  reason: string;
19
- } | undefined, movementSamples?: readonly IMovementSampleInterval[], setup?: IPlaytestSetupApplication | undefined, deviceMetrics?: IPlaytestDeviceMetricsObservation | undefined, movementBaselineSnapshot?: IPlaytestObservationSnapshot | undefined, startup?: IStandalonePlaytestReport["startup"]): IStandalonePlaytestReport;
20
-
21
- /** The only seam between assertion orchestration and an application bridge. */
22
- interface IBridgeTransport {
23
- readonly capabilities: readonly string[];
24
- call<T>(method: string, argument?: unknown, timeoutMs?: number): Promise<T>;
25
- close(): Promise<void>;
26
- waitForBridge(timeoutMs: number): Promise<boolean>;
27
- }
28
- /**
29
- * The budget for one `advance` call: the round-trip allowance plus time for the ticks themselves.
30
- *
31
- * Every other bridge method is a request and a reply, so `operationTimeoutMs` fits. `advance` runs
32
- * the game loop N times before replying, so its honest bound grows with N. Fixed at 5 s it failed
33
- * `starter-game-over` — 600 ticks in one call — on a two-core runner, and reported it as
34
- * `TN_PLAYTEST_OPERATION_TIMEOUT`, which reads as a hung page rather than a slow one.
35
- */
36
- declare function advanceTimeoutMs(ticks: number, perTickMs?: number): number;
37
- declare class PlaytestBridgeError extends Error {
38
- readonly diagnostic: IPlaytestProtocolDiagnostic;
39
- constructor(diagnostic: IPlaytestProtocolDiagnostic);
40
- }
41
- interface IPlaytestBridgeClient {
42
- advance(ticks: number): Promise<void>;
43
- applySetup(request: IPlaytestSetupRequest): Promise<void>;
44
- close(): Promise<void>;
45
- drainEvents(limit?: number): Promise<JsonValue[]>;
46
- description: IPlaytestBridgeDescription;
47
- /** Setup applied before the handshake released a held game, when the scenario declared setup. */
48
- setupApplication?: IPlaytestSetupApplication;
49
- /** Re-reads the bridge's readiness, including startup progress when it reports any. */
50
- readiness(): Promise<IPlaytestBridgeReady>;
51
- sample(request: IPlaytestSampleRequest): Promise<IPlaytestObservationSnapshot>;
52
- }
53
- declare class PlaywrightTransport implements IBridgeTransport {
54
- private readonly page;
55
- private readonly operationTimeoutMs;
56
- readonly capabilities: readonly ["browser.canvas", "browser.console", "browser.dom", "browser.input", "browser.network", "browser.screenshot", "browser.trace", "runtime.diagnostics", "runtime.ui"];
57
- constructor(page: Page, operationTimeoutMs?: number);
58
- call<T>(method: string, argument?: unknown, timeoutMs?: number): Promise<T>;
59
- close(): Promise<void>;
60
- waitForBridge(timeoutMs: number): Promise<boolean>;
61
- }
62
- declare function connectPlaytestBridge(page: Page, scenario: IPlaytestScenario, timeoutMs?: number): Promise<IPlaytestBridgeClient | undefined>;
63
- /**
64
- * How long to wait for the page to install its playtest bridge.
65
- *
66
- * The bridge appears during application startup, not during a request/response round trip, so
67
- * `operationTimeoutMs` is the wrong budget for it by construction — the same mistake, in the same
68
- * direction, as timing a bulk `advance` with it. On a software-rendered two-core runner the
69
- * scaffolded starter spends seconds in first-use compilation before the bridge exists, and the run
70
- * was reported as `TN_PLAYTEST_BRIDGE_MISSING` with `frames: 0`: not a page without a bridge, a
71
- * page that had not finished booting yet.
72
- *
73
- * One operation plus the startup budget, matching `advanceTimeoutMs`. A page that genuinely
74
- * installs no bridge still fails with the same diagnostic, just later.
75
- */
76
- declare function bridgeWaitTimeoutMs(operationMs?: number): number;
77
- declare function connectPlaytestBridgeTransport(transport: IBridgeTransport, scenario: IPlaytestScenario, timeoutMs?: number, target?: string): Promise<IPlaytestBridgeClient | undefined>;
78
-
79
- /** Capture the largest rendered canvas without composited DOM overlays. */
80
- declare function captureVisualSurface(page: Page, artifactPath?: string): Promise<Buffer | undefined>;
81
- /**
82
- * The core bridge is installed before an async scene load completes, so its describe/ready
83
- * handshake can finish one browser frame before the fixed-step loop starts. Retry only that
84
- * exact startup race; a stopped loop that does not recover remains a runner failure.
85
- */
86
- declare function advanceFixedStep(page: Page, bridge: Pick<IPlaytestBridgeClient, "advance">, ticks: number): Promise<void>;
87
- declare function playtestStepDrivesMovement(step: IPlaytestScenario["steps"][number], hasHeldInput: boolean): boolean;
69
+ } | undefined, movementSamples?: readonly IMovementSampleInterval[], setup?: IPlaytestSetupApplication | undefined, deviceMetrics?: IPlaytestDeviceMetricsObservation | undefined, movementBaselineSnapshot?: IPlaytestObservationSnapshot | undefined, startup?: IStandalonePlaytestReport["startup"], deviceLifecycle?: IPlaytestObservations["deviceLifecycle"], tone?: IPlaytestObservations["tone"]): IStandalonePlaytestReport;
88
70
 
89
71
  /**
90
72
  * A published diagnostic that is unmistakably a *readout* rather than an error.
@@ -168,7 +150,7 @@ declare function runStandalonePlaytests(config: IStandalonePlaytestConfig): Prom
168
150
  declare function batchArtifactDirectory(base: string, scenarioPath: string, index: number): string;
169
151
  declare function resolveManagedServerConfig(config: IStandalonePlaytestConfig): Promise<IStandalonePlaytestConfig>;
170
152
 
171
- declare const WEBGPU_BROWSER_ARGS: readonly ["--ozone-platform=x11", "--enable-unsafe-webgpu", "--disable-gpu-sandbox", "--ignore-gpu-blocklist", "--enable-features=Vulkan"];
153
+ declare const WEBGPU_BROWSER_ARGS: readonly ["--ozone-platform=x11", "--enable-unsafe-webgpu", "--disable-gpu-sandbox", "--ignore-gpu-blocklist", "--enable-features=Vulkan", ...string[]];
172
154
  /** Allow performance probes to sample render work instead of Xvfb's compositor cadence. */
173
155
  declare const PERFORMANCE_BROWSER_ARGS: readonly ["--disable-frame-rate-limit", "--disable-gpu-vsync"];
174
156
  declare function resolveBrowserArguments(browserArgs: readonly string[] | undefined): string[];
@@ -186,241 +168,6 @@ interface IBrowserPointerChange {
186
168
  }
187
169
  declare function reconcileBrowserPointers(previous: ReadonlyMap<number, Required<IPlaytestPointer>>, next: readonly IPlaytestPointer[]): IBrowserPointerChange[];
188
170
 
189
- interface IAndroidDriverOptions {
190
- activity: string;
191
- adbPath?: string;
192
- packageName: string;
193
- serial?: string;
194
- /** Android user id to target; when omitted, the device's current foreground user is detected. */
195
- user?: string;
196
- /**
197
- * The rotation between the touchscreen's raw axes and the frame the app draws in, when the
198
- * device cannot be asked.
199
- *
200
- * Normally this is read from the window — `dumpsys window`'s `mRotation`, inverted, and then
201
- * `dumpsys input`'s `SurfaceOrientation` and the `user_rotation` setting behind it. Those two
202
- * older sources are why this option exists: an orientation-locked game on a device whose
203
- * display never rotated reads 0 from both while its window is turned 90° from the panel, so an
204
- * injected touch lands somewhere else entirely and every input assertion fails for a reason
205
- * that has nothing to do with the game.
206
- *
207
- * Set explicitly to make such a run reproducible, and say so in the evidence. Fails closed on
208
- * anything but 0, 1, 2 or 3.
209
- */
210
- touchRotation?: number;
211
- }
212
- interface IAndroidDriver {
213
- captureConsole(): Promise<Array<{
214
- text: string;
215
- type: string;
216
- }>>;
217
- /** The device this driver is bound to, when it knows; reported next to its metric samples. */
218
- deviceSerial?(): string | undefined;
219
- isAlive(): Promise<boolean>;
220
- prepare(endpoint: string, mailboxRoot?: string, viewport?: {
221
- height: number;
222
- width: number;
223
- }): Promise<void>;
224
- readFile?(path: string): Promise<string | undefined>;
225
- removeFile?(path: string): Promise<void>;
226
- /** Raw adb passthrough, so the host can measure the device itself. Read-only probes only. */
227
- runAdb?(args: readonly string[]): Promise<string>;
228
- screenshot(path: string): Promise<void>;
229
- setPointers?(pointers: readonly IAndroidPointer[]): Promise<IAndroidPointerInjection>;
230
- startScreenRecording?(): Promise<void>;
231
- /** One OS tap in viewport pixels. Works on emulators and physical devices alike. */
232
- tap?(x: number, y: number): Promise<void>;
233
- /** Put the soft keyboard away, and report whether one was up. */
234
- hideKeyboard?(): Promise<boolean>;
235
- stop(): Promise<void>;
236
- stopScreenRecording?(path: string): Promise<void>;
237
- writeFile?(path: string, contents: string): Promise<void>;
238
- }
239
- interface IAndroidPointer {
240
- buttons?: number;
241
- id: number;
242
- x: number;
243
- y: number;
244
- }
245
- interface IAndroidPointerInjection {
246
- activeIds: number[];
247
- injection: "adb-emu-event-protocol-b";
248
- rotation: number;
249
- trackingIds: number[];
250
- }
251
- interface IAndroidTouchViewport {
252
- device: {
253
- height: number;
254
- width: number;
255
- };
256
- logical: {
257
- bottom: number;
258
- left: number;
259
- right: number;
260
- top: number;
261
- };
262
- orientation: number | undefined;
263
- physical: {
264
- bottom: number;
265
- left: number;
266
- right: number;
267
- top: number;
268
- };
269
- }
270
- declare class AdbAndroidDriver implements IAndroidDriver {
271
- private readonly options;
272
- private static readonly COVERAGE_VIDEO_PATH;
273
- private readonly adbPath;
274
- private screenrecord?;
275
- private screenrecordError?;
276
- private readonly touchSlots;
277
- private nextTrackingId;
278
- private rotation?;
279
- private touchViewport?;
280
- private readonly user?;
281
- private activeUser?;
282
- private viewportPresented;
283
- constructor(options: IAndroidDriverOptions);
284
- prepare(endpoint: string, mailboxRoot?: string, viewport?: {
285
- height: number;
286
- width: number;
287
- }): Promise<void>;
288
- private resolveUser;
289
- /**
290
- * Put the device into the scenario's viewport, and fail closed if it did not take.
291
- *
292
- * A silent failure here is the expensive one: the run continues, the touches arrive, the
293
- * assertions go red, and the report blames the game for a device that was never showing the
294
- * viewport the scenario asked for.
295
- */
296
- private presentViewport;
297
- tap(x: number, y: number): Promise<void>;
298
- /**
299
- * Dismiss the soft keyboard and wait for it to actually be gone.
300
- *
301
- * Measured on the physical Pixel 8: focusing a text field opens the IME, the WebView reflows
302
- * into the space left above it, and the page's centred menu rides up — so a coordinate computed
303
- * against the scenario's viewport now points at the keyboard. A tap there does not merely miss
304
- * the control; it types a character into the field it meant to submit.
305
- *
306
- * BACK is the dismissal the platform guarantees. The wait is the point: the reflow happens on
307
- * the next layout pass, and a click sent into the middle of it lands wherever the menu was
308
- * halfway through moving.
309
- */
310
- hideKeyboard(): Promise<boolean>;
311
- captureConsole(): Promise<Array<{
312
- text: string;
313
- type: string;
314
- }>>;
315
- screenshot(path: string): Promise<void>;
316
- startScreenRecording(): Promise<void>;
317
- stopScreenRecording(path: string): Promise<void>;
318
- isAlive(): Promise<boolean>;
319
- setPointers(pointers: readonly IAndroidPointer[]): Promise<IAndroidPointerInjection>;
320
- readFile(path: string): Promise<string | undefined>;
321
- removeFile(path: string): Promise<void>;
322
- stop(): Promise<void>;
323
- private readRotation;
324
- writeFile(path: string, contents: string): Promise<void>;
325
- deviceSerial(): string | undefined;
326
- /**
327
- * The device-metrics probes read `dumpsys`, `logcat` and sysfs through here. Deliberately a
328
- * thin passthrough rather than a metrics API: the parsing belongs to deviceMetrics.ts, which
329
- * is unit-tested against real captured device output.
330
- */
331
- runAdb(args: readonly string[]): Promise<string>;
332
- private adb;
333
- private waitForScreenRecorder;
334
- private abortScreenRecording;
335
- private serialArgs;
336
- }
337
- declare function parseAndroidConsole(output: string): Array<{
338
- text: string;
339
- type: string;
340
- }>;
341
- declare function parseAndroidTouchViewport(output: string): IAndroidTouchViewport;
342
- /** Map a normalized logical-display point to the raw touchscreen axes. */
343
- declare function touchPositionForViewport(x: number, y: number, viewport: IAndroidTouchViewport, rotationOverride?: number): [number, number];
344
- /**
345
- * Splits slot identity from coordinates into separate synced `adb emu event send` batches.
346
- *
347
- * The emulator console drops ABS_MT_POSITION_X/Y from any batch that also carries an
348
- * ABS_MT_TRACKING_ID: the command reports `OK` and the coordinates never reach the device, so
349
- * every contact lands at (0, 0) and a two-finger gesture reads as two touches in the same
350
- * screen half — the exact failure that made the simultaneous-touch proof unprovable.
351
- * Confirmed against `getevent -lt /dev/input/event2` on emulator 36.6.11 with the android-35
352
- * google_apis image. Identity goes first so a slot exists before it is positioned.
353
- */
354
- declare function androidTouchBatches(identity: readonly string[], positions: readonly string[]): string[][];
355
- /**
356
- * Confirm that Android reported the requested viewport, including the physical-size omission.
357
- *
358
- * @situation verify that an Android device presented the requested viewport
359
- * @situation accept the physical panel size when `wm size` omits its override line
360
- * @example viewportPresentationObserved(undefined, "1080x2400", { width: 1080, height: 2400 });
361
- */
362
- declare function viewportPresentationObserved(override: string | undefined, expected: string | undefined, physical: {
363
- height: number;
364
- width: number;
365
- }): boolean;
366
- /**
367
- * The touch rotation for the window `dumpsys window` just described, or `undefined`.
368
- *
369
- * `mRotation` says how far the window's content is turned from the panel's natural frame.
370
- * {@link rotatedTouchPosition} converts the other way — a point in that content back to the
371
- * panel's raw axes — so the value it needs is the inverse, and handing it `mRotation` directly
372
- * is a 180-degree error on either odd rotation.
373
- *
374
- * This is the source of truth because it describes the *window*. `dumpsys input`'s
375
- * `SurfaceOrientation` is absent on the emulator, and `user_rotation` is the user's preference:
376
- * an orientation-locked game on a device the user never turned reads 0 there while its window
377
- * is turned 90 degrees off the panel, so every injected touch lands somewhere else.
378
- */
379
- declare function touchRotationFromWindowDump(dump: string): number | undefined;
380
- /**
381
- * Make the device present a scenario's declared viewport, one device pixel per CSS pixel.
382
- *
383
- * A scenario's `viewport` is a declared test condition, and the browser target honours it by
384
- * sizing the window. Without the same courtesy here, a UI page lays out at whatever CSS viewport
385
- * the device's density happens to give — 914x411 on a 2400x1080 panel at 420dpi — and a step
386
- * that names a point in viewport pixels lands on whatever the device's own layout put there.
387
- * Nothing about that failure looks like a coordinate problem: the touch arrives, the host
388
- * hit-tests it honestly, and the control simply is not where the scenario said.
389
- *
390
- * Density 160 is the whole mechanism: it makes `devicePixelRatio` 1, so a viewport pixel, a CSS
391
- * pixel and a device pixel are the same pixel and the page lays out exactly as it does on web.
392
- * The size is written in the panel's natural frame, which is why it is transposed for the
393
- * portrait-natural devices every phone and emulator here happens to be.
394
- */
395
- declare function viewportPresentationCommands(viewport: {
396
- height: number;
397
- width: number;
398
- }, physical: {
399
- height: number;
400
- width: number;
401
- }): string[][];
402
- /**
403
- * One OS-level tap, in the display's current orientation.
404
- *
405
- * With the viewport presented, that orientation *is* the scenario's viewport and the coordinate
406
- * needs no rotation — which is the second reason to prefer this over the emulator's pointer
407
- * protocol. The first is that `adb emu event send` exists only on emulators, and a click step
408
- * that only works on an emulator is a click step that does not work.
409
- */
410
- declare function tapCommand(x: number, y: number): string[];
411
- /** Whether an input method window is on screen, from `dumpsys input_method`. */
412
- declare function keyboardIsShown(dump: string): boolean;
413
- /**
414
- * Undo the presentation.
415
- *
416
- * `reset` and never the numbers read beforehand: a run that crashed between reading and writing
417
- * would restore a size it had already replaced, and leave the device quietly wrong for whoever
418
- * measures on it next.
419
- */
420
- declare function viewportRestoreCommands(): string[][];
421
- declare function rotatedTouchPosition(x: number, y: number, rotation: number): [number, number];
422
- declare function discoverAdb(environment?: NodeJS.ProcessEnv): string;
423
-
424
171
  declare const ANDROID_TRANSPORT_CAPABILITIES: readonly ["browser.console", "browser.input", "browser.screenshot", "device.metrics", "runtime.diagnostics"];
425
172
  interface IDeviceMailbox {
426
173
  read(path: string): Promise<string | undefined>;
@@ -438,9 +185,19 @@ interface IDeviceResponseObservation {
438
185
  order: number;
439
186
  requestId: string;
440
187
  }
188
+ /** One outstanding mailbox request; large arguments retain only a bounded preview. */
189
+ interface IDeviceRequestContext {
190
+ argument?: JsonValue;
191
+ argumentTruncated?: boolean;
192
+ method: string;
193
+ order: number;
194
+ requestId: string;
195
+ timeoutMs: number;
196
+ }
441
197
  interface IDevicePlaytestTransport extends IBridgeTransport {
442
198
  start(): Promise<void>;
443
199
  setResponseObserver?(observer: (observation: IDeviceResponseObservation) => void): void;
200
+ getPendingRequest?(): IDeviceRequestContext | undefined;
444
201
  }
445
202
  declare class DeviceBridgeTransport implements IDevicePlaytestTransport {
446
203
  readonly capabilities: readonly ["browser.console", "browser.input", "browser.screenshot", "device.metrics", "runtime.diagnostics"];
@@ -468,9 +225,12 @@ declare class DeviceMailboxTransport implements IDevicePlaytestTransport {
468
225
  private closed;
469
226
  private nextId;
470
227
  private nextOrder;
228
+ private pendingRequest?;
229
+ private readonly abandonedIds;
471
230
  private responseObserver?;
472
231
  constructor(mailbox: IDeviceMailbox, paths: IDeviceMailboxPaths, operationTimeoutMs?: number);
473
232
  setResponseObserver(observer: (observation: IDeviceResponseObservation) => void): void;
233
+ getPendingRequest(): IDeviceRequestContext | undefined;
474
234
  start(): Promise<void>;
475
235
  call<T>(method: string, argument?: unknown, timeoutMs?: number): Promise<T>;
476
236
  close(): Promise<void>;
@@ -497,20 +257,28 @@ interface IAndroidPlaytestDependencies {
497
257
  transport?: IDevicePlaytestTransport;
498
258
  }
499
259
  interface IDevicePlaytestDriver {
260
+ readonly processId?: number;
261
+ /** Send the app behind HOME and wait until the device reports it unfocused. */
262
+ background?(): Promise<void>;
500
263
  captureConsole(): Promise<Array<{
501
264
  text: string;
502
265
  type: string;
503
266
  }>>;
504
267
  deviceSerial?(): string | undefined;
268
+ /** Bring the launched app back to the foreground without force-stopping it. */
269
+ foreground?(): Promise<void>;
505
270
  isAlive(): Promise<boolean>;
271
+ /** What the device says about the app right now; the lifecycle phases are read from this. */
272
+ lifecycleState?(): Promise<IAndroidAppState>;
506
273
  prepare(endpoint: string, mailboxRoot?: string, viewport?: {
507
274
  height: number;
508
275
  width: number;
509
276
  }): Promise<void>;
510
277
  readFile?(path: string): Promise<string | undefined>;
511
278
  removeFile?(path: string): Promise<void>;
279
+ rotate?(rotation: number): Promise<void>;
512
280
  runAdb?(args: readonly string[]): Promise<string>;
513
- screenshot(path: string): Promise<void>;
281
+ screenshot(path: string, onRequestAccepted?: () => Promise<void>): Promise<void>;
514
282
  setPointers?(pointers: readonly IAndroidPointer[]): Promise<IAndroidPointerInjection>;
515
283
  tap?(x: number, y: number): Promise<void>;
516
284
  hideKeyboard?(): Promise<boolean>;
@@ -536,6 +304,8 @@ interface IDesktopPlaytestDriverOptions {
536
304
  cwd?: string;
537
305
  env?: NodeJS.ProcessEnv;
538
306
  executable: string;
307
+ /** Ask the host for the wall clock, the native counterpart of the browser's init script. */
308
+ liveClock?: boolean;
539
309
  mailboxRoot?: string;
540
310
  screenshotTimeoutMs?: number;
541
311
  }
@@ -552,21 +322,46 @@ declare class LocalDeviceMailbox {
552
322
  declare class DesktopPlaytestDriver implements IDevicePlaytestDriver {
553
323
  private readonly options;
554
324
  private child?;
325
+ private childClosed?;
555
326
  private mailboxRoot?;
556
327
  private readonly consoleEntries;
557
328
  private readonly pendingOutput;
558
329
  constructor(options: IDesktopPlaytestDriverOptions);
330
+ /** The child this driver owns; never inferred from a process-name search. */
331
+ get processId(): number | undefined;
559
332
  captureConsole(): Promise<Array<{
560
333
  text: string;
561
334
  type: string;
562
335
  }>>;
563
336
  isAlive(): Promise<boolean>;
564
- prepare(_endpoint: string, mailboxRoot?: string): Promise<void>;
565
- screenshot(path: string): Promise<void>;
337
+ prepare(_endpoint: string, mailboxRoot?: string, viewport?: {
338
+ height: number;
339
+ width: number;
340
+ }): Promise<void>;
341
+ /**
342
+ * Capture the running game to `path`, returning once the file is written.
343
+ *
344
+ * A deterministic native loop presents nothing between ticks, so the host's copy never happens
345
+ * on its own. `onRequestAccepted` is invoked exactly once, after the host has consumed the
346
+ * request file and therefore set its copy flag; the runner points it at the bridge's render-only
347
+ * operation so the host has a present to copy. It is absent when the bridge offers none, which
348
+ * leaves the pre-existing behavior.
349
+ */
350
+ screenshot(path: string, onRequestAccepted?: () => Promise<void>): Promise<void>;
351
+ /**
352
+ * Why a screenshot produced no file. The host's own lines are the only place that answer is
353
+ * written, and the request file's presence splits the failure in two: left behind means the host
354
+ * never looked, consumed means it read the request and the capture never landed. A bounded tail,
355
+ * never the whole log — a 40k-line dump is how a timeout becomes unreadable. The tail keeps the
356
+ * host's tagged lines and the entries classified as errors, because the root cause (an EGL
357
+ * failure, a texture that never arrived) is usually an untagged line the tag filter alone drops.
358
+ */
359
+ private describeScreenshotTimeout;
566
360
  stop(): Promise<void>;
567
361
  private recordOutput;
568
362
  private flushOutput;
569
363
  }
364
+ declare function desktopConsoleType(stream: "stderr" | "stdout", line: string): string;
570
365
 
571
366
  interface IDesktopPlaytestDependencies {
572
367
  driver?: IDevicePlaytestDriver;
@@ -676,7 +471,17 @@ interface IPipelineCaptureEvent {
676
471
  readonly wallMs?: number;
677
472
  readonly label?: string;
678
473
  readonly error?: string;
474
+ readonly nodeBuilds?: number;
679
475
  readonly beforeFirstPresent?: boolean;
476
+ readonly beforeWarmUpSettled?: boolean;
477
+ readonly afterWarmUpScope?: string;
478
+ }
479
+ interface IPipelineCaptureNodeBuild {
480
+ readonly provenance: IPipelineCaptureProvenance;
481
+ readonly startedMs: number;
482
+ readonly beforeFirstPresent?: boolean;
483
+ readonly beforeWarmUpSettled?: boolean;
484
+ readonly afterWarmUpScope?: string;
680
485
  }
681
486
  interface IPipelineCaptureCounts {
682
487
  readonly lookups: number;
@@ -687,6 +492,7 @@ interface IPipelineCaptureCounts {
687
492
  readonly uniquePipelines: number;
688
493
  readonly recordedEvents: number;
689
494
  readonly droppedEvents: number;
495
+ readonly nodeBuilds?: number;
690
496
  }
691
497
  /**
692
498
  * What ended the capture, and therefore what "complete" is allowed to mean.
@@ -716,8 +522,26 @@ interface IPipelineCapture {
716
522
  readonly boundaryMs: number;
717
523
  readonly eventsSettled: number;
718
524
  };
525
+ readonly warmUpSettled?: {
526
+ readonly boundaryMs: number;
527
+ readonly eventsSettled: number;
528
+ readonly nodeBuilds: number;
529
+ readonly renderPipelineCreations: number;
530
+ };
531
+ readonly warmUpScopes?: readonly {
532
+ readonly label: string;
533
+ readonly boundaryMs: number;
534
+ readonly eventsSettled: number;
535
+ readonly nodeBuilds: number;
536
+ readonly renderPipelineCreations: number;
537
+ readonly firstDraw?: {
538
+ readonly nodeBuilds: number;
539
+ readonly renderPipelineCreations: number;
540
+ };
541
+ }[];
719
542
  readonly counts: IPipelineCaptureCounts;
720
543
  readonly events: readonly IPipelineCaptureEvent[];
544
+ readonly nodeBuilds?: readonly IPipelineCaptureNodeBuild[];
721
545
  readonly incompleteReasons: readonly string[];
722
546
  }
723
547
  interface IPipelinePassSummary {
@@ -730,9 +554,12 @@ interface IPipelinePassSummary {
730
554
  readonly pass: string;
731
555
  }
732
556
  interface IPipelineContributorSummary {
557
+ readonly afterWarmUpSettledCreations: number;
558
+ readonly afterWarmUpSettledNodeBuilds: number;
733
559
  readonly creations: number;
734
560
  readonly failures: number;
735
561
  readonly label: string;
562
+ readonly nodeBuilds: number;
736
563
  readonly sampleCount: number;
737
564
  /** Sum of observed device-call service durations; absent when the driver did not expose them. */
738
565
  readonly serviceMs?: number;
@@ -755,10 +582,23 @@ interface IPipelineSizeTimeSummary {
755
582
  }
756
583
  interface IPipelineWarmupSummary {
757
584
  readonly afterFirstPresent: number;
585
+ readonly afterWarmUpSettled: number;
758
586
  readonly beforeFirstPresent: number;
759
587
  readonly eventsSettledAtFirstPresent?: number;
588
+ readonly eventsSettledAtWarmUpSettled?: number;
589
+ readonly nodeBuildsAfterWarmUpSettled?: number;
590
+ readonly renderPipelineCreationsAfterWarmUpSettled?: number;
591
+ /** Post-boundary work attributed to material contributors already observed during warm-up. */
592
+ readonly warmedNodeBuildsAfterWarmUpSettled?: number;
593
+ readonly warmedRenderPipelineCreationsAfterWarmUpSettled?: number;
760
594
  readonly total: number;
761
595
  readonly unreported: number;
596
+ readonly scopes: readonly {
597
+ readonly label: string;
598
+ readonly nodeBuilds: number;
599
+ readonly renderPipelineCreations: number;
600
+ readonly observed?: boolean;
601
+ }[];
762
602
  }
763
603
  interface IPipelineSummary {
764
604
  readonly adapter?: Readonly<Record<string, unknown>>;
@@ -783,6 +623,15 @@ declare function formatPipelineSummary(summary: IPipelineSummary): string;
783
623
 
784
624
  interface IBrowserCaptureSession {
785
625
  readonly bridge: IPlaytestBridgeClient;
626
+ /** Console errors collected from page creation through the custom capture callback. */
627
+ readonly errors: readonly string[];
628
+ /** Complete console and page-error observations from page creation onward. */
629
+ readonly consoleEntries: readonly IRunnerConsoleEntry[];
630
+ /** Failed network requests from page creation onward. */
631
+ readonly networkEntries: readonly {
632
+ method: string;
633
+ url: string;
634
+ }[];
786
635
  readonly page: Page;
787
636
  readonly provenance: IPlaytestCaptureProvenance;
788
637
  readonly signal: AbortSignal;
@@ -795,4 +644,4 @@ interface IBrowserCaptureSession {
795
644
  */
796
645
  declare function withBrowserCapture<T>(config: IStandalonePlaytestConfig, capture: (session: IBrowserCaptureSession) => Promise<T>, signal?: AbortSignal): Promise<T>;
797
646
 
798
- export { ANDROID_TRANSPORT_CAPABILITIES, AdbAndroidDriver, DesktopPlaytestDriver, DeviceBridgeTransport, DeviceMailboxTransport, type IAndroidDriver, type IAndroidDriverOptions, type IAndroidPlaytestDependencies, type IAndroidPointer, type IAndroidPointerInjection, type IAndroidTouchViewport, type IBridgeTransport, type IBrowserCaptureSession, type IBrowserPointerChange, type IDesktopPlaytestDependencies, type IDesktopPlaytestDriverOptions, type IDeviceMailbox, type IDeviceMailboxPaths, type IDevicePlaytestDriver, type IDevicePlaytestTarget, type IDevicePlaytestTransport, type IDeviceResponseObservation, type IIosCommandOptions, type IIosDriverOptions, type IIosPlaytestDependencies, ILabeledPlaytestSample, IMovementSampleInterval, type IPipelineCapture, type IPipelineCaptureBoundary, type IPipelineCaptureCounts, type IPipelineCaptureEvent, type IPipelineCaptureProvenance, type IPipelineCaptureShader, type IPipelineContributorSummary, type IPipelinePassSummary, type IPipelineProgramReasonSummary, type IPipelineSizeTimePassSummary, type IPipelineSizeTimeSummary, type IPipelineSummary, type IPipelineWarmupSummary, type IPlaytestBridgeClient, type IRunIosCommand, IRunnerConsoleEntry, IStandalonePlaytestConfig, IStandalonePlaytestReport, type IStandalonePlaytestRunOptions, type IosTransportKind, LocalDeviceMailbox, PERFORMANCE_BROWSER_ARGS, PIPELINE_CAPTURE_VERSION, PIPELINE_EVENT_MARKER, type PipelineCaptureKind, type PipelineCaptureMode, type PipelineCaptureSource, type PipelineCaptureStatus, PlaytestBridgeError, PlaywrightTransport, STANDALONE_PLAYTEST_OBSERVATION_FIELDS, WEBGPU_BROWSER_ARGS, XcrunIosDriver, advanceFixedStep, advanceTimeoutMs, androidMailboxPaths, androidTouchBatches, batchArtifactDirectory, boundedTeardownStep, bridgeWaitTimeoutMs, buildReport, captureVisualSurface, connectPlaytestBridge, connectPlaytestBridgeTransport, deviceMailboxPaths, deviceTimeoutDiagnostic, discoverAdb, formatPipelineSummary, handlePlaytestSignal, initStandalonePlaytest, isRuntimeReadout, keyboardIsShown, openPageAndConnectBridge, pageLifecycleDiagnostic, parseAndroidConsole, parseAndroidTouchViewport, parseLaunchedPid, parsePipelineCapture, parsePipelineEventMarkers, playtestStepDrivesMovement, preflightDisplay, reconcileBrowserPointers, recordToScenario, requireAssertions, resolveBrowserArguments, resolveManagedServerCommand, resolveManagedServerConfig, rotatedTouchPosition, runAndroidPlaytest, runDesktopPlaytest, runDevicePlaytest, runIosPlaytest, runStandalonePlaytest, runStandalonePlaytests, softwareAdapterName, substituteManagedPort, summarizePipelineCapture, tapCommand, touchPositionForViewport, touchRotationFromWindowDump, validateDeviceEndpoint, viewportPresentationCommands, viewportPresentationObserved, viewportRestoreCommands, withBrowserCapture, writeCaptureProvenance, writeObservationArtifacts };
647
+ export { ANDROID_TRANSPORT_CAPABILITIES, DesktopPlaytestDriver, DeviceBridgeTransport, DeviceMailboxTransport, IAndroidAppState, IAndroidDriver, type IAndroidPlaytestDependencies, IAndroidPointer, IAndroidPointerInjection, IBridgeTransport, type IBrowserCaptureSession, type IBrowserPointerChange, type IDesktopPlaytestDependencies, type IDesktopPlaytestDriverOptions, type IDeviceMailbox, type IDeviceMailboxPaths, type IDevicePlaytestDriver, type IDevicePlaytestTarget, type IDevicePlaytestTransport, type IDeviceRequestContext, type IDeviceResponseObservation, type IDisplayStrategy, type IIosCommandOptions, type IIosDriverOptions, type IIosPlaytestDependencies, ILabeledPlaytestSample, IMovementSampleInterval, type IPipelineCapture, type IPipelineCaptureBoundary, type IPipelineCaptureCounts, type IPipelineCaptureEvent, type IPipelineCaptureNodeBuild, type IPipelineCaptureProvenance, type IPipelineCaptureShader, type IPipelineContributorSummary, type IPipelinePassSummary, type IPipelineProgramReasonSummary, type IPipelineSizeTimePassSummary, type IPipelineSizeTimeSummary, type IPipelineSummary, type IPipelineWarmupSummary, IPlaytestBridgeClient, type IRunIosCommand, IRunnerConsoleEntry, IStandalonePlaytestConfig, IStandalonePlaytestReport, type IStandalonePlaytestRunOptions, type IosTransportKind, LocalDeviceMailbox, PERFORMANCE_BROWSER_ARGS, PIPELINE_CAPTURE_VERSION, PIPELINE_EVENT_MARKER, type PipelineCaptureKind, type PipelineCaptureMode, type PipelineCaptureSource, type PipelineCaptureStatus, STANDALONE_PLAYTEST_OBSERVATION_FIELDS, WEBGPU_BROWSER_ARGS, XcrunIosDriver, androidMailboxPaths, batchArtifactDirectory, boundedTeardownStep, buildReport, decideDisplayStrategy, desktopConsoleType, deviceMailboxPaths, deviceTimeoutDiagnostic, formatPipelineSummary, handlePlaytestSignal, initStandalonePlaytest, isRuntimeReadout, openPageAndConnectBridge, pageLifecycleDiagnostic, parseLaunchedPid, parsePipelineCapture, parsePipelineEventMarkers, preflightDisplay, reconcileBrowserPointers, recordToScenario, requireAssertions, resolveBrowserArguments, resolveManagedServerCommand, resolveManagedServerConfig, runAndroidPlaytest, runDesktopPlaytest, runDevicePlaytest, runIosPlaytest, runStandalonePlaytest, runStandalonePlaytests, softwareAdapterName, substituteManagedPort, summarizePipelineCapture, validateDeviceEndpoint, withBrowserCapture, writeCaptureProvenance, writeObservationArtifacts };