From 4b096dcf2d59b1342528f84f05d7198f48e2806f Mon Sep 17 00:00:00 2001 From: Derrors <33656531+Derrors@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:18:51 +0800 Subject: [PATCH 1/2] test(terminal): a busy runner gets more attempts to send a key byte by byte The fragmented-key check throws away an attempt whose writes took longer than 0.2 s (the script was held up, which proves nothing about the menu) and tries again, five times at most. A busy macOS runner stretched every sleep for longer than that: five attempts in a row took 0.21-0.33 s, and macos-terminal failed twice on 2026-11-18 (#151, #152) with nothing wrong in the menu. It now tries up to 30 times within 20 s, says how many attempts a key took when it needed more than one, and the failure names the count. The budget, the gap between bytes and what is checked are unchanged. Co-Authored-By: Claude Opus 5.5 --- tests/terminal.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/terminal.py b/tests/terminal.py index a8c0e1a..88318c1 100644 --- a/tests/terminal.py +++ b/tests/terminal.py @@ -339,14 +339,18 @@ def main(): # That holds only if this script itself isn't held up between the # writes (a busy macOS runner stalled it past the budget, and ↓ came # out as "B"): an attempt whose writes took longer proves nothing - # and is run again. + # and is run again. A busy runner can stretch every sleep for a + # while (five attempts in a row took 0.21-0.33s), so it gets many + # attempts, bounded in time. spread = 0.2 + attempts, patience = 30, 20.0 for fragmented_env, keys, result in [(env, b"\x1b[B", 2), (env, b"\x1bOB", 2), (yes_env, "否".encode(), 0), (yes_env, "不".encode(), 0)]: took = [] - while len(took) < 5: + give_up = time.monotonic() + patience + while len(took) < attempts and time.monotonic() < give_up: session = Session(command, fragmented_env) try: session.expect("Esc") @@ -359,11 +363,14 @@ def main(): session.send(b"\r") if took[-1] <= spread: session.finish(f"MENU_RESULT={result}") + if len(took) > 1: + print(f"note: sending {keys!r} took {len(took)} attempts " + f"(the slow ones: {[round(t, 2) for t in took[:-1]]})", flush=True) break finally: session.close() else: - raise AssertionError(f"could not send {keys!r} within {spread}s: took {took}") + raise AssertionError(f"could not send {keys!r} within {spread}s in {len(took)} attempts: took {took}") # A partial control sequence that times out is ignored, not Esc. session = Session(command, env) try: From 2455f3d66e147b6516c5477132addb62bcd52330 Mon Sep 17 00:00:00 2001 From: Derrors <33656531+Derrors@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:18:51 +0800 Subject: [PATCH 2/2] docs: what the axauditd stall in regression case #155 was traced to Only right after the lock button with a read following; what was tried and didn't reproduce it; the cause is inside axauditd. Co-Authored-By: Claude Opus 5.5 --- docs/dev/regression-cases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.md index be65897..0b4e857 100644 --- a/docs/dev/regression-cases.md +++ b/docs/dev/regression-cases.md @@ -158,4 +158,4 @@ | 152 | 原生控制(iOS 27):设置首页底部悬浮的搜索栏在扁平的元素树里只是一个直接挂在 Application 下的 `SearchField`,没有 WDA 树里那层 Toolbar,不算遮挡;被压在栏下的行(如「隐私与安全」在 y≈866)按名字点会点它的中心,打开的是搜索;`iphone_tap_element` 带 `scroll` 时也会停在这样的位置 | 直接挂在 Application 下、在屏幕下部 40% 的 `SearchField` 按底部悬浮栏处理:盖得住下面的行;范围按真机量的算:输入框(顶 866)往上 58 点内的点击都被栏吞掉(806 还能进下面那一行,812、820、826 都不行),左右和往下多 34 点;一半压在这片范围里的改点上面露出来的部分,整个在里面的报被挡住 | 单测 `a_native_floating_search_field_covers_the_rows_under_it`(真机导出的树 `settings-floating-search-native-ios27.xml`)+ 真机(设置首页把行滑到搜索栏下,按名字点、带 scroll 找) | | 153 | 第一次启动系统 App(备忘录、提醒事项)时,系统先在另一个进程(`com.apple.PDUIApp`)里显示隐私说明页盖在上面;`/wda/apps/launch` 要等 XCTest 看到 App 到前台,一直等到 60 秒超时,接着 WDA 被判卡死重启,`iphone_launch_app` 报超时(65 秒) | 先用 `/wda/apps/launchUnattached`(不经 XCTest,发出就返回),再照旧轮询前台:前台是隐私说明页就马上报「被挡住」,结果和权限弹窗一样提示先点它的按钮;它回「failed to launch」时说明页已经出来,照样往下查;旧版 WDA 没有这个接口时退回 `/wda/apps/launch` | 单测 `a_first_launch_privacy_notice_is_reported_at_once`、`an_older_wda_without_unattached_launch_launches_as_before`、`other_launch_errors_are_errors` + 真机(iPhone 12 mini,iOS 26.4.1:没打开过的「备忘录」0.7 秒返回、WDA 不重启,0.2.7 是 65 秒并重启 WDA;冷启动「时钟」后马上点标签页照常点中)| | 154 | `iphone_tap_element` 没找到(或序号超出、整个被盖住)时什么都没点,带 `then` 却先等界面稳定 0.7~0.8 秒,再拿它点之前读的树比较,说「界面和操作前一样:操作可能没生效(点在了空白处…),不要原样再做一遍」,好像点过了 | 没点就清掉「操作前的界面」,不做比较;MCP 端看到没点到东西时不等稳定,直接用按名字点击刚读的树列元素或截图 | 真机(iPhone 12 mini,iOS 26.4.1:设置里按不存在的文字点,带 `then=elements` 和 `then=screenshot`,0.2.7 是 1.3~1.45 秒带那句提示,本分支 0.6~0.9 秒不带;只换守护进程(旧 MCP)时仍等稳定但也不带;按存在的文字点照常等稳定、说界面变了)| -| 155 | 原生控制(iOS 27):手机上的 axauditd(remoteAXService 背后的进程)卡住后,每次读界面都超时(先 `remoteAXService: request`,之后每次握手 `deviceAPIVersion`),守护进程一直「准备手机失败,稍后重试」,重连、重建隧道、重启守护进程都没用,只有重新插线才恢复。iPhone 15 Pro Max(iOS 27.2.1)上见过三次:两次在部署重启守护进程后,一次在自动解锁后 | 无障碍服务不应答单独成一种错误(`DeviceError::AxUnanswered`,文字同超时);读界面、读前台 App 碰到它时经 CoreDevice 结束 axauditd(下次连接系统自动拉起),再读一次;同一台设备一分钟内最多一次,事件日志记「已重启手机上的 axauditd」 | 单测 `an_unanswered_accessibility_service_is_told_apart_and_reads_as_a_timeout`、`only_axauditd_is_the_accessibility_daemon` + 真机(经 AppService 给 axauditd 发 SIGSTOP 冻住:main 上一直报超时,修复后下一次读界面直接成功、axauditd 换了进程号) | +| 155 | 原生控制(iOS 27):手机上的 axauditd(remoteAXService 背后的进程)卡住后,每次读界面都超时(先 `remoteAXService: request`,之后每次握手 `deviceAPIVersion`),守护进程一直「准备手机失败,稍后重试」,重连、重建隧道、重启守护进程都没用,只有重新插线才恢复。iPhone 15 Pro Max(iOS 27.2.1)上见过三次:两次在部署重启守护进程后,一次在自动解锁后。2026-11-18 排查:只在锁屏键按下后马上读界面时出现(完整场景回归里约 35 次锁屏碰上 2 次),卡住前 axauditd 不报错、日志停住 8 秒,像在等一个不回的应答;没能复现的有:客户端请求中途断开或不发 clientNeedsAccessibility: false(10 次)、40 个半开连接加 48 次切换 App、锁屏状态下重启守护进程(5 次)、锁屏前后每 0.1 秒读一次(20 轮,带或不带 SpringBoard 的元素)。根因在 axauditd 内部,要抓它卡住时的调用栈(sysdiagnose)才看得到 | 无障碍服务不应答单独成一种错误(`DeviceError::AxUnanswered`,文字同超时);读界面、读前台 App 碰到它时经 CoreDevice 结束 axauditd(下次连接系统自动拉起),再读一次;同一台设备一分钟内最多一次,事件日志记「已重启手机上的 axauditd」 | 单测 `an_unanswered_accessibility_service_is_told_apart_and_reads_as_a_timeout`、`only_axauditd_is_the_accessibility_daemon` + 真机(经 AppService 给 axauditd 发 SIGSTOP 冻住:main 上一直报超时,修复后下一次读界面直接成功、axauditd 换了进程号) |