#244

[0.3.1 (752)] 手动结束 iOS Automation Mode 后操作失效,旧会话仍被复用且缺少恢复引导

OpenYANGTHEKINGopened 9d ago

What happened

在官方 Poki 0.3.1 (752) 中,用户手动结束 iPhone 顶部系统提示中的 Automation Mode/自动化模式 后,返回 Poki 继续发起操作,读屏和操作均失败。这里关闭的是 iOS 顶部的自动化模式,不是“设置 → 开发者 → 启用 UI 自动化”,也不是 Poki 内的关闭开关。

用户体验是“关掉一次后就恢复不了了,也执行不了任何操作”,容易误以为必须始终保留自动化模式,且看不到清晰的重新启用/恢复路径。

现场日志观察:

  • 关闭前,应用内自动化会话曾成功打开。
  • 失败时,Poki 仍反复将 generation 1 报为 already open / ready。
  • 读屏返回 no_front_app;操作返回 Not authorized for performing UI testing actions.。
  • 本次故障前本地开发者连接已恢复为 working,runner 进入过 running。历史日志另有旧的网络连接失败,但不能把它们混作本次故障的原因。

这些现象与“系统授权已结束,但应用仍复用旧会话状态”一致,属于推断;尚未证明底层状态失配的完整机制。用户点击系统关闭的准确时刻没有单独记录,日志中的自动待机事件也不等于这次手动点击。

期望改善:

  1. 系统手动结束 Automation Mode 后,及时识别权限失效,撤销旧的 ready 状态,停止无意义的读屏/点击重试。
  2. 当用户明确再次启用或发起操作时,提供“重新启用自动化”的明确入口,说明是否需要 iOS 再次确认。
  3. 如果当前实现必须重新启动 Poki 才能建立新会话,直接给出清晰、简短的恢复引导;不要让用户自行猜测需要退出重开。
  4. 尊重用户手动停止的选择;恢复流程应由用户主动触发,而不是立即自动把模式重新打开。

发布提交 e5071ac 的 AppModel.swift 已记录同一进程关闭会话后重开可能无法读屏;stopSession 路径 会结束会话并退出应用。希望从 iOS 顶部手动停止时也有相应的状态处理和恢复体验。

Steps to reproduce

  1. 在 iPhone 上运行官方 Poki 0.3.1 (752) Alpha,开启自动化,观察系统顶部 Automation Mode 提示。
  2. 在系统顶部的 Automation Mode 提示中手动结束该模式。
  3. 返回仍在运行的 Poki,再发起读屏或手机操作。
  4. 观察读屏失败及操作未授权,Poki 日志仍称原会话为 already open。
  5. 现场已完整重启一次 Poki尝试恢复;新进程日志显示 session turned on 和开发者连接 working,但截至提交时尚未收到重启后具体手机操作成功的确认。因此不把“重启应用成功”描述为“自动化已恢复”。

关闭前应用运行约数分钟,附近有 1 分钟无任务后的自动待机记录;精确手动关闭时刻未记录。本报告来自一台设备的一次现场排查,未进行多轮稳定性测试。

Area

Automation on the phone (reads, taps, typing)

App version

官方 Poki 0.3.1 (752) Alpha,发布提交 e5071ac。当前安装包没有本机源码修改。

Installed with

Poki Setup 0.2.2 (661),macOS 27.2.1,Xcode 27.2,免费 Apple 账号签名。

iPhone and iOS

iPhone(硬件标识 iPhone18,2),iOS 26.6.2。Developer Mode 已开启,开发者镜像文件已校验并保存在应用内。

Debug log

以下只摘录与当前故障有关的行;用省略号截去无关尾部。未附私人任务目标、屏幕内容、设备唯一标识、账号或密钥。

01:41:16.366 [loopback] back: 10.7.0.1 answers again
01:41:39.558 [runner] running
01:41:44.522 [runner] in-process session ready for the launcher is ready (generation 1, already open, 3.08 s, first snapshot and screenshot 1.89 s)

01:44:33.739 [runner] in-process session ready for the launcher is ready (generation 1, already open, 0.00 s)
01:44:35.082 [agent] failed: Look at the screen · failed: read: failed (no element tree: the runner refused GET /source: no element tree: no_front_app; ...
01:44:58.871 [agent] failed: Press Home button · failed: read: failed (no element tree: the runner refused GET /source: no element tree: no_front_app; ... error: action 1 was not sent: the runner refused POST /wda/homescreen: Not authorized for performing UI testing actions.
01:45:50.040 [runner] in-process session ready for Poki came to the front (generation 1, already open, 0.00 s)

完整重启后的新进程记录(仅证明启动和本地连接,不证明操作恢复):

01:47:22.605 [app] Poki started (0.3.1 build 752)
01:47:23.107 [session] turned on
01:47:24.412 [loopback] developer service: working(ms: 1600)

Activity

1
JosssphZhou8d ago

Thanks for documenting the stale ready state after manually stopping Automation Mode. #291 is related, but it is not yet a verified fix. Recovery must reflect the actual system state and require an intentional restart by the owner rather than silently reopening the session. We are keeping this issue open.