iOS: resolveRunnerWindow fails when an unused trailing window disappears
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- ios, swift
- Lĩnh vực
- mobile, testing-qa
Hướng nghiên cứu
Bắt đầu trong apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift tại resolveRunnerWindow(app:), sau đó chạy bản tái hiện native được liên kết bằng ./reproduce.sh . Hoàn tất khi resolver trả về cửa sổ đầu tiên có thể sử dụng và không rỗng mà không đọc các cửa sổ phía sau không cần thiết, giữ nguyên fallback app.frame và bản tái hiện chạy qua mà không gặp lỗi stale-element.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug
resolveRunnerWindow(app:) eagerly reads the frame of every app window before returning the first usable one. If an unused trailing window disappears between its exists check and its frame read, XCTest records a failure even though the first/main window is still available.
Affected implementation: Agent Device 0.21.15; also still present in upstream source at 3660c7fa.
Small native reproduction
Public repo: https://github.com/wcastand/agent-device-window-race-repro
Verified commit: b1baf97
The fixture is a small UIKit app with a persistent main UIWindow. It shows a second window every 5 seconds, then hides/releases it after 600 ms. Two XCUITests repeatedly call the extracted original resolver or the proposed short-circuit version using real XCUIApplication/XCUIElement objects. No Expo/React Native, backend, account, mocked failures, or hooks/delays inside the resolver are involved.
git clone https://github.com/wcastand/agent-device-window-race-repro.git
cd agent-device-window-race-repro
./reproduce.sh <iOS-simulator-UDID>
The Xcode project is included; no package install or signing team is needed. Each loop is bounded to 60 seconds / 6,000 calls. This is a natural timing race, so a run can miss it. The script returns success only if the original produces the specific stale-element failure and the patched test passes; setup errors and missed races are rejected.
Observed vs expected
On Xcode 27.0 (27A266a), macOS 27.0 arm64, iPhone 18 Pro simulator / iOS 27.0, the script exited 0:
- Original: failed on call 332 (zero-based iteration 331).
- Patched: completed 3,843 calls over one minute, no failures.
- The original failure was also observed separately on iPhone 17 / iOS 26.5.
Checking existence of `Window (Element at index 1)`
Find the Window (Element at index 1)
Find the Window (Element at index 1) (retry 1)
Find the Window (Element at index 1) (retry 2)
Failed to get matching snapshot: No matches found for Element at index 1 from input {(
Window (Main)
)}
Expected: return the first usable window without resolving later windows that cannot affect the result. The repro isolates the native resolver; it does not run the full CLI/daemon or reproduce a keyboard-specific lifecycle.
Proposed patch
Downloadable patch, checked against the upstream source path:
--- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift
+++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift
@@ -226,12 +226,13 @@
/// display can never name a different window than the one the reference frame was measured on.
func resolveRunnerWindow(app: XCUIApplication) -> (window: XCUIElement?, frame: CGRect) {
let windows = app.windows.allElementsBoundByIndex
- var frames: [CGRect?] = []
- for window in windows {
- frames.append(window.exists ? window.frame : nil)
- }
- if let index = Self.firstUsableWindowIndex(frames: frames) {
- return (windows[index], frames[index] ?? .zero)
+ // Stop at the first usable window. Later keyboard/overlay windows can disappear
+ // between exists and frame, recording an XCTest failure before a valid tap.
+ for window in windows where window.exists {
+ let frame = window.frame
+ if !frame.isEmpty {
+ return (window, frame)
+ }
}
return (nil, app.frame)
}
This preserves first-non-empty-window selection and the app.frame fallback. It avoids unnecessary trailing-window reads; it does not make exists + frame atomic or claim to fix disappearance of the selected window.
- Ngôn ngữ chính
- TypeScript
- Star
- 4.8k
- Fork
- 315
- Merge trung bình
- 11 giờ 25 phút
- Pull request đã merge (30 ngày)
- 545
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của callstack/agent-device
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
callstack/agent-device#3062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
callstack/agent-device#1869 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
callstack/agent-device#3060 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Android test-IME fill commits into a stale InputConnection session after focus moves to a new fieldĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
callstack/agent-device#3052 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 75/100
callstack/agent-device#3047 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của callstack/agent-device
Issue tương tự
-
refactor
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OHDSI/Data2Evidence#3450 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
redhat-developer/rhdh-plugin-export-overlays#4011 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
automation missing-model model-sync provider:ofox
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/models.dev#8421 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SlackAdapter and TelegramAdapter are not assignable to Adapter under exactOptionalPropertyTypesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày