Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ What changed in each release, one line per change. Versions follow [Semantic Ver
### Fixes

- Native control (iOS 27): the floating search bar at the bottom of Settings counts as covering the rows under it, as it does through WDA. Tapping a row under it by text taps its visible part instead of opening the search.
- Launching a system app for the first time no longer hangs for 60 seconds behind its privacy notice and restarts WDA; it returns at once and says the notice is in the way.
- A WDA probe that answers, even with an error, resets the timeout count instead of accumulating unrelated slow requests into a stall. Recovery logs state the reason, and timeout logs include the endpoint and elapsed time.

## [0.2.7] - 2026-11-15
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
### 修复

- 原生控制(iOS 27):设置首页底部悬浮的搜索栏算作挡住它下面的行,和经 WDA 时一样。按名字点被压在栏下的行,改点露出来的部分,不会再打开搜索。
- 第一次启动系统 App 时,不再被隐私说明页卡住 60 秒、还把 WDA 判成卡死重启;马上返回,并说明被说明页挡着。
- WDA 的短探测正常应答或返回远端错误时清零超时计数,不再把多个独立慢请求累计成卡死;恢复日志写明判定依据,请求超时日志包含端点和耗时。

## [0.2.7] - 2026-11-15
Expand Down
72 changes: 70 additions & 2 deletions crates/ictl-wda/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ const MJPEG_SCALE: u32 = 100;

/// 主屏、锁屏、系统弹窗所属的进程
pub const SPRINGBOARD: &str = "com.apple.springboard";
/// 系统 App 第一次打开前的隐私说明页(「欢迎使用“备忘录”… 接受并继续」)。它在自己的进程里,盖在要启动的 App 上面,
/// 点了它的按钮 App 才会到前台
pub const PRIVACY_SHEET: &str = "com.apple.PDUIApp";
/// IOHID 消费者页(Consumer)
const HID_PAGE_CONSUMER: u32 = 0x0C;
/// 消费者页里的电源键
Expand Down Expand Up @@ -264,6 +267,12 @@ pub enum Launch {
Slow,
}

/// WDA 不认识这个路径(旧版本没有的接口)时的报错,同 [`WdaClient::interface_rotation`]
fn unknown_route(kind: &str, message: &str) -> bool {
matches!(kind, "unknown command" | "unknown method" | "unsupported operation")
|| (kind == "http" && matches!(message, "404" | "405"))
}

/// [`WdaClient::check_lock`] 的结果
#[derive(Debug)]
pub struct LockCheck {
Expand Down Expand Up @@ -1002,8 +1011,19 @@ impl<T: Transport> WdaClient<T> {
/// 等待期间查前台出错不算失败(启动命令已经成功了)
pub async fn launch_app(&mut self, bundle_id: &str) -> Result<Launch> {
let started = tokio::time::Instant::now();
self.in_session("POST", "/wda/apps/launch", Some(json!({"bundleId": bundle_id})), Duration::from_secs(60))
.await?;
// 不经 XCTest 启动(LSApplicationWorkspace),发出就返回,到没到前台由下面自己查。`/wda/apps/launch` 要等 XCTest
// 看到 App 在前台:系统 App 第一次打开时隐私说明页盖在上面,它就一直等到 60 秒超时,WDA 也被判卡死重启
// (iPhone 12 mini,iOS 26.4.1,「备忘录」「提醒事项」都是 65 秒)。这时它回「failed to launch」,说明页已经出来了
let body = json!({"bundleId": bundle_id});
match self.call("POST", "/wda/apps/launchUnattached", Some(body.clone()), DEFAULT_TIMEOUT).await {
Ok(_) => {}
Err(WdaError::Remote { message, .. }) if message.contains("failed to launch") => {}
// older WDA without the route: launch as before
Err(WdaError::Remote { kind, message }) if unknown_route(&kind, &message) => {
self.in_session("POST", "/wda/apps/launch", Some(body), Duration::from_secs(60)).await?;
}
Err(e) => return Err(e),
}
let t0 = tokio::time::Instant::now();
let deadline = t0 + Duration::from_secs(8);
let mut foreground = false;
Expand All @@ -1013,6 +1033,15 @@ impl<T: Transport> WdaClient<T> {
foreground = true;
break;
}
Ok(a) if a == PRIVACY_SHEET => {
return Ok(Launch::Blocked(
ictl_l10n::tr!(
"第一次打开时的隐私说明页(点「继续」或「接受并继续」后才进入 App)",
"the privacy notice shown on first launch (tap Continue or Accept & Continue to get into the app)"
)
.into(),
));
}
// 系统弹窗(权限请求)挡着时前台一直是 SpringBoard,原来要白等满 8 秒。
// 刚启动的一瞬间前台也还是 SpringBoard,过 1 秒还是才去查弹窗(查一次约 0.4 秒)
Ok(a) if a == SPRINGBOARD && bundle_id != SPRINGBOARD && t0.elapsed() >= Duration::from_secs(1) => {
Expand Down Expand Up @@ -1317,6 +1346,45 @@ mod tests {
assert_eq!(steps.iter().filter(|s| s["type"] == "pointerDown").count(), 1);
}

/// 启动不经 XCTest(`launchUnattached`),发出就返回;系统 App 第一次打开时它回 failed to launch,前台是隐私说明页,
/// 马上报被挡住,不再等 60 秒
#[tokio::test]
async fn a_first_launch_privacy_notice_is_reported_at_once() {
let fail = r#"{"value":{"error":"unknown error","message":"LSApplicationWorkspace failed to launch app"}}"#;
let m = Mock::with(&[(500, fail), (200, r#"{"value":{"bundleId":"com.apple.PDUIApp"}}"#)]);
let mut w = WdaClient::new(&m);
let t0 = std::time::Instant::now();
let r = w.launch_app("com.apple.mobilenotes").await.unwrap();
assert!(matches!(r, Launch::Blocked(ref t) if !t.is_empty()), "{r:?}");
assert!(t0.elapsed() < Duration::from_secs(1));
let seen = m.seen.lock().unwrap();
assert_eq!(seen[0].1, "/wda/apps/launchUnattached");
assert!(seen.iter().all(|(_, p, _)| !p.ends_with("/wda/apps/launch")));
}

/// 旧版 WDA 没有 launchUnattached:照旧经会话启动
#[tokio::test]
async fn an_older_wda_without_unattached_launch_launches_as_before() {
let m = Mock::with(&[
(404, r#"{"value":{"error":"unknown command","message":"Unhandled endpoint"}}"#),
(200, r#"{"sessionId":"A"}"#),
(200, r#"{"value":null}"#),
(200, r#"{"value":{"bundleId":"com.apple.PDUIApp"}}"#),
]);
let mut w = WdaClient::new(&m);
assert!(matches!(w.launch_app("com.apple.mobilenotes").await.unwrap(), Launch::Blocked(_)));
let seen = m.seen.lock().unwrap();
assert_eq!(seen[2].1, "/session/A/wda/apps/launch");
}

/// 别的错误照样报出来,不当成启动了
#[tokio::test]
async fn other_launch_errors_are_errors() {
let m = Mock::with(&[(500, r#"{"value":{"error":"invalid argument","message":"bad bundle"}}"#)]);
let mut w = WdaClient::new(&m);
assert!(matches!(w.launch_app("x").await, Err(WdaError::Remote { .. })));
}

/// 依次点几个点:每个点一根手指,第 k 根先空等前面的点按完;各手指的节拍数对得上,按下抬起一个接一个、不重叠
#[test]
fn a_sequence_is_one_finger_per_point_in_turn() {
Expand Down
1 change: 1 addition & 0 deletions docs/dev/regression-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,4 @@
| 150 | Agent 在原地打转:同一个点击原样做了好几次、界面一直没变,每次的结果都是同一句「界面和操作前一样…不要原样再做一遍」,看不出已经是第几次了 | 守护进程记下最近一个操作的原样请求和它连续几次做完界面没变:同一个请求再次没变时,从第二次起在这句后面说「这已经是连续第 N 次…换个做法,还不行就告诉用户卡在了哪一步」;换了操作、参数不同或界面变了重新数,没法比(操作前没看过界面)的那次不数也不清零 | 单测 `the_same_action_leaving_the_screen_unchanged_is_counted` + 真机(iPhone 12 mini,iOS 26.4.1:主屏幕空白处原样点 4 次,第 2~4 次带次数;换个点、再点回来、点开「设置」都不带)|
| 151 | 要点的项在长列表屏幕外(设置首页的「隐私与安全性」):`iphone_tap_element` 只看当前屏幕,Agent 只能自己滑一下、读一次元素地来回;普通 0.3 秒快滑带惯性,手指移 300 点内容滚 618 点,会把要找的甩过去;找到的那一行可能正停在底部工具栏下面,整个被盖住 | `scroll`(`down` / `up`):每次在屏幕正中慢滑 35% 屏高(1 秒,几乎不带惯性,前后两屏有重叠),等列表停下再读树;要点的匹配存在且没被整个盖住才算找到;元素树不再变化算到了尽头,停下并在结果里说滑了几次 | 单测 `tap_element_scroll_search_is_optional_and_checked`、`a_search_scroll_is_a_short_vertical_stroke_in_the_middle`、`requests_round_trip_as_tagged_json` + 真机(iPhone 12 mini,iOS 26.4.1:设置首页往下找「隐私与安全性」滑 4 次点中;滑到底后往上找「通用」滑 3 次点中;找不存在的项滑到底 6 次停下)|
| 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;冷启动「时钟」后马上点标签页照常点中)|
Loading