You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A simulator capture program killed without its stop leaves SimRenderServer faulting on every frame until shutdown #1888
A simulator capture program that dies without running its stop() leaves its frame callbacks registered in the simulator's SimRenderServer. The renderer then logs one ROCKit Invalid connection UUID specified fault per rendered frame, per dead UUID, until the simulator shuts down. Found while triaging #1583.
Measured on this Mac (Xcode 27.2, iOS 26.4 simulator, macOS 26.6.1, helper built from mainc550e87):
helper stopped by stdin close 0 faults on its SimRenderServer
helper SIGKILLed after 30 s 12,605 faults from 1 UUID in 210 s (~60/s, the frame rate)
still ~60/s six minutes later, until simctl shutdown
another simulator up since Nov 19 3 UUIDs, 1 fault each per minute (a still screen renders once a minute)
Two ways Simlock can end the program that way, separate from #1583's viewer-leave order:
src/drivers/ios/screen-capture.ts:175-180stopProgram SIGKILLs after 2 s. The comment at lines 30-32 says the kill keeps "a stuck encoder" from pinning the framebuffer. Measured: a kill pins a registration that does not go away.
The helper does not ignore SIGPIPE (vendor/screen-capture/Sources/SimlockCapture/Lifecycle.swift:298: only SIGTERM, SIGINT and SIGHUP). A daemon that dies closes stdout and stdin together, and the next frame write kills the program (exit status -13, checked on the host with a closed output pipe) before the stdin thread can start stop(). Options.swift:144 expects EPIPE there instead.
Possible directions: signal(SIGPIPE, SIG_IGN) in ExitSources, so EPIPE reaches the existing viewer-gone path. Also, unregister a dead program's UUIDs from the next program, which needs a check on a simulator.
Defect, for the SIGPIPE half. The test runs a child copy of the test bundle. The child sets up as main.swift and runCapture do, then acts as if its daemon died: stdout and stderr readers gone, stdin at end of file. It writes one frame and one log line. On branch bug/1888-repro:
vendor/screen-capture/Tests/SimlockCaptureTests/DaemonGoneTests.swift
testAProgramWhoseDaemonDiedTakesTheViewerGoneWayOutOnItsNextFrameAndLogLine
swift test --package-path vendor/screen-capture --filter DaemonGoneTests
XCTAssertEqual failed: ("signal 13") is not equal to ("exit 0") - the program died on a write to its daemon's closed pipe, before its stop could run
The SIGKILL half is not reproduced. stopProgram (src/drivers/ios/screen-capture.ts:179-180) kills only a program still running 2 s after its stdin closed, and a healthy program exits before that. Proving the faults stop needs a real simulator: run the fixed helper, kill its daemon, and count ROCKit faults on SimRenderServer.
Root cause
vendor/screen-capture/Sources/SimlockCapture/Lifecycle.swift:298: ExitSources ignores SIGTERM, SIGINT and SIGHUP, but not SIGPIPE. So the first write to a closed pipe kills the program, although Options.swift:144 expects it to return EPIPE. A second cause hides behind the first. log() (Options.swift:156) and fail() (:174) use FileHandle.write(_:), which raises an Objective-C exception on EPIPE. The stdin thread calls log("stdin closed") (Lifecycle.swift:310) before onExit, so with only SIGPIPE ignored the program aborts there instead, still before stop().
Simplest fix
signal(SIGPIPE, SIG_IGN) at the top of ExitSources.init, and try? FileHandle.standardError.write(contentsOf:) in log and fail.
SIG_IGN only: ("exit 1") is not equal to ("exit 0") (abort, exit 134 outside XCTest)
both changes: swift test --package-path vendor/screen-capture -> Executed 19 tests, with 0 failures
Alternatives rejected
SIG_IGN alone: the reproduction still fails at log().
F_SETNOSIGPIPE on Wire.fd only: stderr writes would still raise SIGPIPE.
Dropping the SIGKILL in stopProgram: a stuck program would then never end.
Risk
No CI lane runs swift test. Run it by hand on a Mac with Xcode.
Two comments say the program does not ignore SIGPIPE, and both become false with the fix: src/drivers/ios/screen-capture.ts:143-144 and screen-capture.test.ts:49-50. Update them.
Not covered: a SIGKILL or a crash still leaves registrations behind. The issue's other direction (the next program unregisters a dead program's UUIDs) needs a simulator check.
Fast track
Defect: yes
Fix tried: yes
Nothing public added or broken: yes
No ADR or rule changed: yes
One fix: no — clearing a dead program's UUIDs also covers SIGKILL and crashes
The capture program ignores SIGPIPE, and its log() and fail() writes to stderr no longer throw, so a dead daemon leads to stop() (triage report's simplest fix).
A new capture program unregisters the frame callbacks a dead program left in SimRenderServer, so a SIGKILL or crash no longer leaves faults until shutdown. Needs a check on a real simulator.
CI runs swift test --package-path vendor/screen-capture on a macOS runner.
Done when:
The triage reproduction (DaemonGoneTests.swift) passes.
After a capture program is SIGKILLed and a new one starts on the same simulator, SimRenderServer logs no ROCKit Invalid connection UUID specified faults for the dead program's UUIDs (slow lane, real iOS simulator).
A CI job runs the Swift tests and fails the PR when they fail.
The comments at src/drivers/ios/screen-capture.ts:143-144 and screen-capture.test.ts:49-50 match the new SIGPIPE handling.
Done: PR #1893 at 86e0d1e is ready. R1–R8 are fixed and reviewed. The slow-lane test e2e/slow-ios-stream.test.ts passed 4/4 on a real simulator at this head. The Swift tests and the new swift CI job are green.
Not done: merge. The gate saw red CI twice on tests outside this diff. First run: Windows src/ports/windows-command.test.ts (conhost killChildren) and Console e2e/console/breakpoints.spec.ts:110; Console is also red on main at 056e298. After gh run rerun --failed: Windows src/agent-device/edge-release.test.ts (retainOnClose). No flaky-test issue exists for any of them.
Findings: see the Review ledger on the PR.
Blocked on: the maintainer re-runs the Windows job and merges, or files the flaky tests.
Activity
V3RON commentedon Nov 26, 2026
Reproduction
Defect, for the SIGPIPE half. The test runs a child copy of the test bundle. The child sets up as
main.swiftandrunCapturedo, then acts as if its daemon died: stdout and stderr readers gone, stdin at end of file. It writes one frame and one log line. On branchbug/1888-repro:The SIGKILL half is not reproduced.
stopProgram(src/drivers/ios/screen-capture.ts:179-180) kills only a program still running 2 s after its stdin closed, and a healthy program exits before that. Proving the faults stop needs a real simulator: run the fixed helper, kill its daemon, and count ROCKit faults on SimRenderServer.Root cause
vendor/screen-capture/Sources/SimlockCapture/Lifecycle.swift:298:ExitSourcesignores SIGTERM, SIGINT and SIGHUP, but not SIGPIPE. So the first write to a closed pipe kills the program, althoughOptions.swift:144expects it to return EPIPE. A second cause hides behind the first.log()(Options.swift:156) andfail()(:174) useFileHandle.write(_:), which raises an Objective-C exception on EPIPE. The stdin thread callslog("stdin closed")(Lifecycle.swift:310) beforeonExit, so with only SIGPIPE ignored the program aborts there instead, still beforestop().Simplest fix
signal(SIGPIPE, SIG_IGN)at the top ofExitSources.init, andtry? FileHandle.standardError.write(contentsOf:)inlogandfail.Alternatives rejected
SIG_IGNalone: the reproduction still fails atlog().F_SETNOSIGPIPEonWire.fdonly: stderr writes would still raise SIGPIPE.stopProgram: a stuck program would then never end.Risk
swift test. Run it by hand on a Mac with Xcode.src/drivers/ios/screen-capture.ts:143-144andscreen-capture.test.ts:49-50. Update them.Fast track
Written by an agent.
V3RON commentedon Nov 26, 2026
Scope (maintainer, 2026-11-26)
Wide fix, three parts:
log()andfail()writes to stderr no longer throw, so a dead daemon leads tostop()(triage report's simplest fix).swift test --package-path vendor/screen-captureon a macOS runner.Done when:
DaemonGoneTests.swift) passes.Invalid connection UUID specifiedfaults for the dead program's UUIDs (slow lane, real iOS simulator).src/drivers/ios/screen-capture.ts:143-144andscreen-capture.test.ts:49-50match the new SIGPIPE handling.Scope set by the maintainer.
Written by an agent.
fix(ios): a capture program ignores SIGPIPE and its stderr writes can…
ci: run the capture program's Swift tests, and fix the SIGPIPE commen…
test: a new capture program takes the UUIDs a dead one left on its si…
fix(ios): a new capture program unregisters the frame callbacks a dea…
docs: toolchain names the Swift tests' new subjects and reads cleanly (…
fix(ios): a capture program releases only the registration record it …
fix(ios): each capture program keeps its own registration record so o…
6 remaining items
V3RON commentedon Nov 26, 2026
Delivery run
Merged: none
Parked: #1888 — R8 (slow-lane fault query not scoped to the leased simulator) open at the review round cap, PR #1893
Written by an agent.
test: count only the leased simulator's renderer faults (#1888)
V3RON commentedon Nov 27, 2026
Handoff
Done: PR #1893 at 86e0d1e is ready. R1–R8 are fixed and reviewed. The slow-lane test
e2e/slow-ios-stream.test.tspassed 4/4 on a real simulator at this head. The Swift tests and the newswiftCI job are green.Not done: merge. The gate saw red CI twice on tests outside this diff. First run: Windows
src/ports/windows-command.test.ts(conhost killChildren) and Consolee2e/console/breakpoints.spec.ts:110; Console is also red onmainat 056e298. Aftergh run rerun --failed: Windowssrc/agent-device/edge-release.test.ts(retainOnClose). No flaky-test issue exists for any of them.Findings: see the Review ledger on the PR.
Blocked on: the maintainer re-runs the Windows job and merges, or files the flaky tests.
Written by an agent.
V3RON commentedon Nov 27, 2026
Delivery run
Merged: #1893 (#1888)
Parked: none
Asleep: 41 min
Written by an agent.