Repository navigation
fix(recording): render the touch overlay at most 30 fps and inside the record request #3219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b50f71a
71650bb
ea2a631
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { runCmd } from '@agent-device/host-kit/command'; | ||
| import { Deadline } from '@agent-device/host-kit/retry'; | ||
| import { AppError } from '@agent-device/kernel/errors'; | ||
| import { findProjectRoot } from '@agent-device/host-kit/version'; | ||
| import { | ||
|
|
@@ -23,6 +24,20 @@ export function getRecordingOverlaySupportWarning( | |
| return 'touch overlay burn-in is only available on macOS hosts; returning raw video plus gesture telemetry'; | ||
| } | ||
|
|
||
| /** | ||
| * `record stop` is one daemon request, which the client abandons after `record`'s 90 s envelope: | ||
| * the caller gets "Daemon request timed out" while the daemon finishes the stop. So the overlay must | ||
| * end well inside it. Compiling the helper, its export and its exit all come out of this budget; | ||
| * past it the stop keeps the raw video and its gesture telemetry, with a warning. | ||
| */ | ||
| export const OVERLAY_BUDGET_MS = 70_000; | ||
|
|
||
| /** | ||
| * The helper's time outside its export: starting up, then verifying the composited output or | ||
| * cancelling the export, and exiting. | ||
| */ | ||
| const HELPER_EXIT_GRACE_MS = 5_000; | ||
|
|
||
| let overlayScriptPath: string | undefined; | ||
| let exportSupportScriptPath: string | undefined; | ||
|
|
||
|
|
@@ -44,8 +59,10 @@ async function exportProcessedVideo(params: { | |
| scriptPath: string; | ||
| scriptArgs: string[]; | ||
| commandDescription: string; | ||
| budgetMs: number; | ||
| }): Promise<void> { | ||
| const { videoPath, scriptPath, scriptArgs, commandDescription } = params; | ||
| const deadline = Deadline.fromTimeoutMs(params.budgetMs); | ||
| await waitForStableFile(videoPath); | ||
| await waitForPlayableVideo(videoPath); | ||
|
|
||
|
|
@@ -54,11 +71,30 @@ async function exportProcessedVideo(params: { | |
| const executablePath = await compileSwiftSourceFile({ | ||
| sourcePath: scriptPath, | ||
| extraSourcePaths: [getExportSupportScriptPath()], | ||
| // `runCmd` reads a timeout of 0 as none. | ||
| timeoutMs: Math.max(1, deadline.remainingMs()), | ||
| }); | ||
| await runCmd(executablePath, ['--input', videoPath, '--output', outputPath, ...scriptArgs], { | ||
| timeoutMs: 120_000, | ||
| env: buildSwiftToolEnv(), | ||
| }); | ||
| const helperMs = deadline.remainingMs(); | ||
| const exportMs = helperMs - HELPER_EXIT_GRACE_MS; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The process-kill timer ( Prompt for AI agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Measured on a 600 s simulator recording with this helper:
The shared 5 s covers each about 20 times, so |
||
| if (exportMs <= 0) { | ||
| throw new AppError( | ||
| 'COMMAND_FAILED', | ||
| `No time was left for the export within the ${params.budgetMs}ms budget`, | ||
| ); | ||
| } | ||
| await runCmd( | ||
| executablePath, | ||
| [ | ||
| '--input', | ||
| videoPath, | ||
| '--output', | ||
| outputPath, | ||
| ...scriptArgs, | ||
| '--timeout-ms', | ||
| String(Math.round(exportMs)), | ||
| ], | ||
| { timeoutMs: helperMs, env: buildSwiftToolEnv() }, | ||
| ); | ||
| await waitForPlayableVideo(outputPath); | ||
| fs.renameSync(outputPath, videoPath); | ||
| } catch (error) { | ||
|
|
@@ -109,5 +145,6 @@ export async function overlayRecordingTouches(params: { | |
| scriptPath: getOverlayScriptPath(), | ||
| scriptArgs: ['--events', telemetryPath, '--quality', exportQuality], | ||
| commandDescription: `Failed to add touch overlays to the ${targetLabel}`, | ||
| budgetMs: OVERLAY_BUDGET_MS, | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.