macOS runner aborts in CGS_REQUIRE_INIT on the first synthesized event with Xcode 27.2 (XCTDisplayInterface → SLSGetDisplaysWithRect)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- macos, swift
- 领域
- desktop-dev, testing
调研方向
The fix belongs in dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift, where the reporter proposes a class-level setUp that touches NSApplication.shared under #if os(macOS). Start by reading the existing instance setUp there, then confirm the crash on a macOS machine with Xcode 27.2 by clicking an element in a target app. Done means a fresh runner synthesizes click, fill and scroll events without the CGS_REQUIRE_INIT assertion, and the change is checked against the other macOS runner paths.
由索引模型根据 Issue 内容生成。
描述
[!NOTE]
🤖 Opus 5.5 responding on behalf of Sam
Summary. With Xcode 27.2, the macOS runner aborts on the first event it synthesizes in a fresh runner process (a click, coordinate tap, fill or scroll):
Assertion failed: (did_initialize), function CGS_REQUIRE_INIT, file CGInitialization.c, line 44.
The CLI then reports Error (COMMAND_FAILED): fetch failed. snapshot -i and get text keep working. Connecting the runner process to the window server in RunnerTests' class setUp fixes it locally (patch below).
Environment
- agent-device 0.21.15,
--platform macos, target app Brave Browser (Chromium) - Xcode 27.2 (27B52);
xcodebuild -checkFirstLaunchStatusexits 0 - macOS 26.6.2 (25G83), Apple silicon
I haven't tried 0.21.35. The release notes for 0.21.16–0.21.35 don't mention this, and a code search of main found no NSApplication warm-up in the runner tests.
Repro
agent-device open "Brave Browser" --platform macosagent-device snapshot -iworks.agent-device click @eNon any element. runner.log:
Tap "<window title>" Window[0.00, 0.00] -> (452.0, 114.0)
Find the "<window title>" Window
Check for interrupting elements affecting "<window title>" Window
Synthesize event
Assertion failed: (did_initialize), function CGS_REQUIRE_INIT, file CGInitialization.c, line 44.
Crashed thread (AgentDeviceRunnerUITests-Runner crash report, EXC_CRASH SIGABRT):
libsystem_kernel.dylib __pthread_kill
libsystem_pthread.dylib pthread_kill
libsystem_c.dylib abort
libsystem_c.dylib __assert_rtn
SkyLight SLSGetDisplaysWithRect
SkyLight SLGetDisplaysWithRect
XCTAutomationSupport static XCTDisplayInterface.allDisplayIDs(containing:)
XCTAutomationSupport static XCTDisplayInterface.firstDisplayID(containing:)
XCTAutomationSupport -[XCElementSnapshot displayID]
XCUIAutomation +[XCUIElement(XCUIElementEventSynthesis) _dispatchEventWithEventBuilder:eventSynthesizer:…]
Observations
- A runner process started before Xcode 27.2 was installed kept pressing.
- Every runner started after the install crashed on its first synthesized event, with one exception: a run where a system dialog was on screen and XCTest's UI-interruption handling ran before the synthesis. So the crash seems to depend on whether anything has connected the runner process to the window server before the first event.
- Rebuilding the runner from an empty cache (
prepare ios-runner --platform macos) didn't change it. - Another project hit the same assert on Xcode 27 and fixed it the same way: https://github.com/perezstudio/axo-browser/pull/90 ("the UI test runner has no
NSApplication. A fresh runner whose first test starts with a key press crashed inCGS_REQUIRE_INIT, so each UI test class now connects it to the window server inclass setUp.")
Local patch
In dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift, after the instance setUp(). AppKit is already imported on macOS.
#if os(macOS)
override class func setUp() {
super.setUp()
MainActor.assumeIsolated { _ = NSApplication.shared }
}
#endif
After the rebuild (the runner cache key changed with the source), a click, a fill and a scroll on Brave all worked: 5 synthesized events, no assert. At startup the patched runner also logs a few [Connection] Unable to get synchronousRemoteObjectProxy and Unable to re-register with Process Instance Registry lines, which didn't affect any command.
The opt-in native macOS backend (ADR 0031) avoids XCTest altogether, but XCTest is still the default macOS backend. Would you consider adding this, or an equivalent window-server connection, to the macOS runner?
- 主要语言
- TypeScript
- 星标
- 5.3k
- 派生
- 377
- 平均合并
- 13 小时 18 分钟
- 30 天内合并 PR
- 653
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
callstack/agent-device 的其他 Issue
-
iOS alert wait: the last poll can get ~30 ms and turns "no alert" into a failed read可能已有人在做 @pcbeingused333 于 3 天前认领。 未关闭bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 77/100
callstack/agent-device#4018 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
callstack/agent-device#1869 ·
维护者通常 1 天内回复
-
needs-triage
难度 5/5 一周以上 新手友好度 5/100
callstack/agent-device#4205 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
callstack/agent-device#4204 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
callstack/agent-device#4203 ·
维护者通常 1 天内回复
查看 callstack/agent-device 的全部 Issue
相似的 Issue
-
test: claim-conflict drop leaves both facts active and is never re-proposed (untested review cell)未关闭
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
[Feature]: Usage page should show API-equivalent cost and say when a connected plan shows info only未关闭enhancement from-x
难度 2/5 1-3 小时 新手友好度 66/100
nightly-labs/openbot#4867 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
egonSchiele/agency-lang#1377 ·
维护者通常 1 天内回复
-
normalizePath removes the Windows device namespace prefix可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
caprover/caprover-frontend#273 ·
维护者通常 1 天内回复