Skip to content

Commit 49db3b8

Browse files
committed
fix(recording): preserve request scope for Apple clock capture
1 parent 144bd59 commit 49db3b8

8 files changed

Lines changed: 17 additions & 6 deletions

File tree

‎packages/contracts/src/screen-recording-runtime-host.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type AppleScreenRecordingHost = Readonly<{
7777
device: DeviceInfo,
7878
appBundleId: string,
7979
signal?: AbortSignal,
80+
requestId?: string,
8081
): Promise<AppleScreenRecordingClockAnchor | undefined>;
8182
isRunnerBundleId(bundleId: string): Promise<boolean>;
8283
}>;

‎packages/contracts/src/screen-recording-runtime.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export type ScreenRecordingLiveHandle = LiveResourceHandle<ScreenRecordingComple
132132

133133
export type ScreenRecordingStartInput = Readonly<{
134134
sessionId: string;
135+
requestId?: string;
135136
outputPath: string;
136137
clientOutputPath?: string;
137138
scope: RecordingScope;

‎packages/daemon/src/sessions/handlers/record-runtime.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ function screenRecordingStartInput(
342342
): ScreenRecordingStartInput {
343343
return {
344344
sessionId: params.sessionName,
345+
requestId: params.req.meta?.requestId,
345346
outputPath: outputPaths.outputPath,
346347
clientOutputPath: outputPaths.clientOutputPath,
347348
scope: prepared.scope,

‎packages/platform-apple/src/recording/runtime.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ async function startAppleSimulatorRecording(params: AppleRecordingStartParams) {
103103
device,
104104
input.activeSessionApp.bundleId,
105105
signal,
106+
input.requestId,
106107
)
107108
: undefined;
108109
// The recorder owns its own file and the export is produced from a copy of it (ADR 0024 2.3), so a

‎src/platform-runtime-screen-recording-apple-host.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export function createAppleScreenRecordingHost(
3737
await import('./platform-runtime-screen-recording-apple-runner-host.ts');
3838
await retrieveAppleRunnerRecording(device, remotePath, outputPath, host.env, signal);
3939
},
40-
captureClockAnchor: async (device, appBundleId, signal) => {
40+
captureClockAnchor: async (device, appBundleId, signal, requestId) => {
4141
const { captureAppleClockAnchor } =
4242
await import('./platform-runtime-screen-recording-apple-runner-host.ts');
43-
return await captureAppleClockAnchor(device, appBundleId, signal);
43+
return await captureAppleClockAnchor(device, appBundleId, signal, requestId);
4444
},
4545
isRunnerBundleId: async (bundleId) => {
4646
const { isAppleRunnerBundleId } =

‎src/platform-runtime-screen-recording-apple-runner-host.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export async function captureAppleClockAnchor(
7272
device: DeviceInfo,
7373
appBundleId: string,
7474
signal?: AbortSignal,
75+
requestId?: string,
7576
) {
7677
try {
7778
const [simulatorTransport, runnerTransport] = await Promise.all([
@@ -93,7 +94,7 @@ export async function captureAppleClockAnchor(
9394
const result = await runAppleRunnerCommand(
9495
device,
9596
{ command: 'snapshot', appBundleId, interactiveOnly: true, depth: 1 },
96-
{ signal },
97+
{ signal, requestId },
9798
);
9899
const wallClockAtMs = Date.now();
99100
return typeof result.currentUptimeMs === 'number' &&

‎src/platform-runtime-screen-recording-host.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function createLazyAppleHost(host: HostEnvironment): ScreenRecordingRuntimeHost[
8686
await (await load()).inspectRunner(device, sessionId, authority),
8787
retrieveRunnerRecording: async (device, remotePath, outputPath, signal) =>
8888
await (await load()).retrieveRunnerRecording(device, remotePath, outputPath, signal),
89-
captureClockAnchor: async (device, appBundleId, signal) =>
90-
await (await load()).captureClockAnchor(device, appBundleId, signal),
89+
captureClockAnchor: async (device, appBundleId, signal, requestId) =>
90+
await (await load()).captureClockAnchor(device, appBundleId, signal, requestId),
9191
isRunnerBundleId: async (bundleId) => await (await load()).isRunnerBundleId(bundleId),
9292
});
9393
}

‎test/integration/provider-scenarios/ios-record-trace.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ test('iOS simulator recording reports host contention and recovers through the f
7070
const recordingPath = path.join(tmpDir, 'sim-recording.mp4');
7171
const recorderPath = nativeRecordingPath(recordingPath);
7272
const collectedPath = collectedRecordingPath(recordingPath);
73-
const runnerTranscript = createProviderTranscript([]);
73+
const runnerTranscript = createProviderTranscript([
74+
{ command: 'ios.runner.snapshot', result: { currentUptimeMs: 100 }, repeat: true },
75+
]);
7476
const appleRunnerProvider = createAppleRunnerProviderFromTranscript(
7577
runnerTranscript,
7678
'ios.runner',
@@ -171,6 +173,10 @@ test('iOS simulator recording reports host contention and recovers through the f
171173
assertRecordingStopped(recordStop, recordingPath, { showTouches: false });
172174
assert.equal(fs.existsSync(ownedProcessRecordPath), false);
173175

176+
assert.equal(
177+
runnerTranscript.calls.filter(({ command }) => command === 'ios.runner.snapshot').length,
178+
2,
179+
);
174180
runnerTranscript.assertComplete();
175181
// The recorder is told its own path, and the caller's path arrives from a copy of it
176182
// (ADR 0024 2.3), so neither sibling is left behind for the next run to wonder about.

0 commit comments

Comments
 (0)