Repository navigation
fix: capture screen recordings on tvOS and in CDP attach mode - #5
Merged
Merged
Conversation
simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown.
simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it.
WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer.
Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
DouweBos
added a commit
that referenced
this pull request
Oct 9, 2026
* fix(ios): bound simulator screen recording teardown simctl can ignore the SIGINT that stops recordVideo (seen on headless tvOS simulators), and the unbounded waitFor in stopScreenRecording then hangs the whole suite. Wait with a timeout and force-kill the recorder plus its descendants on expiry, escalate to SIGKILL inside screenrecord.sh so the moov atom still gets a chance to flush, and never let normalization throw out of teardown. * fix(ios): record the external display on tvOS simulators simctl io recordVideo defaults to --display internal, which tvOS does not have, so it never processed a frame, wrote no file, and ignored the SIGINT that stops it - which is what wedged the recorder teardown. Pass --display external for tvOS simulators, plumbing the platform down from the session manager, which already knows it. * feat(web): record the screen over CDP in attach mode WebScreenRecorder is Selenium-backed, so attaching to a running Chrome/Electron left startScreenRecording a silent no-op that produced an empty file. Drive Page.startScreencast over the raw CDP socket instead and feed the frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer. * fix: handle unsupported screen recording uniformly Drivers signalled 'cannot record' three different ways - TODO(), error() and a silent no-op - so the same situation crashed, failed a flow or produced an empty file depending on the platform. Report it as ScreenRecordingUnsupported and let each caller decide: flows and debug artifacts skip the recording with a warning and no 0-byte file, while 'maestro record' fails with a clear message. Also stop marking a session as recording before the driver actually started, which left every later recording a silent no-op.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Screen recording get-well: everything that was silently broken about capturing video, in one place. Four commits, each independently reviewable.
1. tvOS simulators never captured anything (
fix(ios))simctl io recordVideotakes--display, defaulting tointernal. tvOS only supportsexternal.screenrecord.shnever passed the flag, so on a tvOS simulator simctl was asked to record a display that does not exist: it never processed a first video frame, wrote nothing, and — in that pre-start state — did not respond to SIGINT. The script'swaitnever returned,stopScreenRecording's unboundedwaitFor()blocked, and a suite stalled for 59 minutes with orphanedsimctlprocesses and a 0-byte mp4.Reproduces across Xcode 16.2–26.3 × tvOS 18.5/26.1/26.2. Newer simctl (26.5) masks it by auto-selecting a display, so it only fails on older toolchains.
Fix: pass
--display externalfor tvOS simulators; iOS keeps simctl's default. The platform is plumbed fromMaestroSessionManager(which already computesisTV(deviceId)to pick the driver bundle) intoSimctlIOSDeviceand on tostartScreenRecording, falling back to the lookup only for callers that don't know. Theexternalalias is deliberate — display names/IDs (--display TVOut,--display 2) are rejected by Xcode ≤ 26.3.Verified end-to-end on a booted Apple TV 4K (tvOS 26.5):
ffprobereports 51 frames over 8.5s, recorder exits cleanly on SIGINT.2. No teardown may block a suite forever (
fix(ios))The safety net, not the fix — but still correct whatever the cause.
stopScreenRecordingwaits with a timeout (2 min default, overridable), then warns and force-terminates the recorder and its descendants —ProcessHandle.descendants()collected before killing the parent, since killing only the bash script is what left orphanedxcrun/simctlin CI.screenrecord.shescalates itself: afterkill -SIGINTit polls for 60s, thenkill -KILL, so the moov atom gets a fair chance to flush first.Mp4DurationNormalizercatchesThrowable, so a truncated recording can't throw out of teardown.(
xcrunexecs into simctl rather than forking, so signal targeting was never the problem.)3. CDP attach mode recorded nothing (
feat(web))WebScreenRecorderis Selenium-backed, so attaching to a running Chrome/Electron over CDP madestartScreenRecordinga no-op returning an empty file. It now drivesPage.startScreencastover the raw CDP socket and feeds frames to the same encoder, acking each frame so Chrome's delivery gates on the consumer, and joining the screencast before finishing the encoder so no frame is mid-encode.4. "Cannot record" handled uniformly (
fix)Drivers signalled it three different ways —
TODO()(physical iOS via devicectl),error("Not supported")(XCTest), a silent no-op (CDP attach), plain exceptions (Roku, Vega) — so the same situation crashed, failed a flow, or produced an empty file depending on the platform. Now:ScreenRecordingUnsupported(a typedUnsupportedOperationExceptioninmaestro-utils) is what drivers throw.startRecordingin a flow and the debug-bundle full-run recording skip with a warning/insight and delete the empty artifact — recording is incidental, it shouldn't fail the run.maestro recordfails with a clearCliError— recording is the entire point there.Maestro.startScreenRecordingno longer marks the session as recording before the driver succeeds; it used to leave the flag stuck, silently no-oping every later recording in the session.Tests
ScreenRecordCommandTest— runs the realscreenrecord.shagainst a stubxcrunonPATHand asserts the command line: tvOS gets--display external, iOS gets none. Fails when the display selection is removed.LocalSimulatorUtilsScreenRecordingTest— a recorder that trapsINT/TERMand holds a child must not blockstopScreenRecordingand must leave no descendants. Hangs (build killed by timeout) against the old unboundedwaitFor().CdpScreencastTest— real WebSocket server standing in for DevTools: frames reach the consumer and each one is acked; a dead endpoint surfaces a failure instead of hanging.MaestroScreenRecordingTest— a failed start doesn't disable later recordings (fails without the flag fix); a second concurrent recording stays a no-op.IntegrationTestcase 099 — a driver that can't record skips the recording, the flow still passes, and no empty mp4 is left (fails without the Orchestra catch)../gradlew :maestro-ios-driver:test :maestro-client:test :maestro-web:test :maestro-orchestra:test :maestro-test:test :maestro-cli:compileKotlinis green.