iOS Simulator screen stream: ROCKit invalid-connection fault storm and multi-second stalls

未关闭
#1,583 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
37/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
ios, typescript
领域
backend, mobile

调研方向

Start with dist/drivers/ios/screen-capture.js, dist/stream/worker-link.js, dist/stream/captures.js, and dist/stream/feed.js; trace the gateway stream route and correlate each request with helper PID and exit reason. Reproduce by opening the lease stream for about six seconds, closing it, then reopening and watching SimRenderServer logs for invalid connection UUID faults. Done means the helper and native connection lifecycle is understood and a fix is verified to stop sustained faults and stalls across reconnects.

由索引模型根据 Issue 内容生成。

描述

bug:new

Environment

  • Measured: Simlock 0.7.0, packaged iOS screen-capture driver and helper; iOS Simulator runtime 26.5, running in a macOS VM. Measurements on 2026-11-15. macOS and Xcode versions and host hardware are not established here.
  • Measured: The fault storm was seen on every streamed simulator examined, including simulators held by other leases, between 19:56 and 20:16 local time. This does not establish behavior on every installation.

Symptoms and evidence

Measured: Opening a stream was followed by two simlock-screen-capture process starts, PID 4985 at 20:24:43 and PID 5151 at 20:24:52 local time. This establishes two starts, not that their lifetimes overlapped or why the second was started. From about 20:24:49, the streamed device's SimRenderServer (PID 3502) emitted approximately 120–270 faults per second. Each was followed by an Activity for state dumps entry (subsystem ROCKit, category RuntimeIssues, sender ROCKit.framework). The fault text included:

ROCKit Soft Assertion Failure ... Failed Condition: errorPropagated -- Runtime error encountered without error propagation channel, aborting. Error: NSPOSIXErrorDomain Code=22 (Invalid connection UUID specified.) connectionUUID=...

Measured: One connection UUID accounted for about 17,600 faults in three minutes; 15 others accounted for 605 each. The message's word “aborting” does not by itself establish that the server process exited.

Measured: Over a 180-second run, the app reported 7,441 unique and 3,232 lost frames, about 59.3 frames/s combined. The received stream nonetheless had gaps of roughly 2–9 seconds. After gaps, chunks resumed at about 16 ms spacing, beginning with a large delta frame and no backlog burst. Per-second guest logs show SimRenderServer and the device's processes silent during each observed stall, followed by a catch-up burst of 500–1,300 lines; ControlCenter and airportd continued logging.

Hypothesis: The gap pattern points toward interruption before or during guest-side capture/delivery rather than ordinary transport buffering. Log silence is consistent with a blocked SimRenderServer, but does not by itself prove where it blocked or exclude every downstream cause. The app's aggregate frame count does not establish uninterrupted frame production at every instant.

Reproduction to try

  1. On a Mac with Simlock 0.7.0 and an iOS 26.5 simulator, start the worker and lease a simulator using the documented workflow, for example simlock lease --platform ios --device "iPhone 16". Launch an app with continuous visible animation or a frame counter.

  2. Open one Simlock screen stream using the usual viewer. Keep it open for at least three minutes. Record received frame or chunk timestamps and sizes, and the app's frame count. Observe helper starts and exits, for example with ps sampling, including command arguments and parent PIDs.

  3. In another terminal, capture the relevant unified logs while the stream is open, for example:

    log stream --style compact --info --debug --predicate 'process == "SimRenderServer" OR process == "simlock-screen-capture"'
    

    Count Invalid connection UUID specified faults by second and UUID, and correlate stream gaps with SimRenderServer and other process logs. Compare an equivalent interval without a stream, then close and reopen the viewer and check whether the faults persist. Redact identifiers before sharing logs.

Expected: A continuous stream, clean helper lifecycle, and no sustained invalid-connection fault storm. Observed: The rates and stalls above. Unverified: This exact procedure has not been rerun as a minimal independent reproduction; the trigger for the second helper and whether a single open suffices are unknown.

Mechanism to investigate

  • Code-backed: <simlock>/dist/drivers/ios/screen-capture.js:37–48, 53–79 starts a helper for each successful capture open. The driver checks the abort signal before starting, but does not subscribe to it after starting. The returned close operation is idempotent.
  • Code-backed: <simlock>/dist/stream/worker-link.js:11–22, 32–40 registers a slot and starts a feed for each serve call, and releases on abort or close. <simlock>/dist/stream/captures.js:23–36, 50–66 keeps a set of slots per device; it does not enforce one capture per device. Multiple opens can therefore spawn multiple helpers, and a new open need not wait for another slot's close. These files alone do not show an automatic restart or prove concurrent helpers in this incident.
  • Code-backed: <simlock>/dist/drivers/ios/screen-capture.js:90–109, 123–128 closes on stream cancellation, read error, or completion; stopping closes stdin, waits up to two seconds, then sends SIGKILL and waits up to two more seconds. This JavaScript does not call a display detach API. Whether the native helper detaches on stdin EOF or before a forced kill is not established by the JS. <simlock>/dist/stream/feed.js:4–8, 35–38, 80–87 has a 30-second default silence bound and closes on read failure; the reported 2–9-second gaps alone do not reach that default.
  • Binary inspection: Strings in the packaged helper reference SimulatorKit.framework and framebuffer/display descriptors. Strings do not establish the connection lifecycle, an actual ROCKit API call, or a detach implementation.
  • Hypothesis: A capture client exits or is replaced without fully tearing down a display/ROCKit connection. SimRenderServer may then repeatedly service a stale connection UUID and fault, possibly on frame-related work, with periodic blocking and stream stalls. The fault storm starts before the second observed helper start, so that second start cannot explain the onset in this timeline. A pre-existing stale connection, an earlier lifecycle event, or a different Apple/runtime defect could also explain it.

Suggested investigation and fixes

  1. Trace each stream request, helper PID, exit reason, native connection UUID and detach completion; correlate those with fault onset and stalls. Determine whether starts are retries, separate viewers or another path.
  2. Consider a single shared capture per device/stream with reference-counted viewers, or serialize replacement so the previous helper has exited and detached before the next attaches. Preserve intended multi-viewer behavior.
  3. In the native helper, explicitly unregister and detach the display/framebuffer connection on normal EOF, cancellation and handled errors before exiting. Ensure close waits for teardown; investigate how to recover when forced termination prevents cleanup.
  4. Investigate whether the relevant SimulatorKit/ROCKit interface supports an error-propagation handler, and install and handle one where supported. Avoid assuming the assertion can be fixed solely in Simlock.
  5. Add lifecycle coverage for rapid open/close, overlapping requests, failed startup and forced termination, plus an integration check that faults cease and frames continue after reconnect. Compare the same scenario without Simlock to isolate a Simulator defect.

Explicitly unverified

  • The exact macOS, Xcode and hardware versions; whether physical Macs or other simulator runtimes reproduce this.
  • Whether the two helpers overlapped, which requests caused them, whether either was killed, or whether a restart happened.
  • Which client owns any faulting UUID, whether it is stale, and whether native teardown or an error handler is absent.
  • Whether the fault storm causes the stalls, the precise blocking location, or whether a transport or encoder issue contributes.
  • Whether the storm occurs without a Simlock stream, persists after closing it, or is specific to Simlock rather than an Apple framework issue.
  • Whether the proposed changes eliminate faults or stalls; none has been tested.

Addendum (same day): trigger and a logging A/B

  • Measured: Our test harness opens a short probe stream through the gateway (about 6 s, ~7 MB) and closes it immediately before the real stream. That fits the two helper starts per run. A viewer that opens and closes a stream quickly (a reconnect, a preview) may leave the same state; the storm was also present on simulators our harness never touched.
  • Measured (A/B, 4 x 300 s, ABBA): turning ROCKit logging off in the guest (log config --subsystem ROCKit --mode level:off) did not consistently reduce stalls (pairs: 23 -> 7 and 7 -> 8 stalls >= 0.3 s). So the cost is not the logging itself. Across arms, stalls were higher when the storm ran for the whole arm (326 s of SimRenderServer log activity: 12 unexplained stalls) than when it was intermittent (110 s: 2). This is a correlation only.
  • Likely quickest trigger (from our runs, not yet reduced further): open the gateway's stream for a lease (GET /v1/leases/<lease>/stream), read for about 6 s, close it, then open it again and keep it open. Then watch SimRenderServer's log for Invalid connection UUID specified.
主要语言
TypeScript
星标
705
派生
40
平均合并
12 小时 9 分钟
30 天内合并 PR
376

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/simlock 的其他 Issue

查看 callstackincubator/simlock 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。