feat: bound accessibility snapshot requests to avoid indefinite hangs - #1214
Open
mykola-mokhnach wants to merge 2 commits into
Open
feat: bound accessibility snapshot requests to avoid indefinite hangs#1214mykola-mokhnach wants to merge 2 commits into
mykola-mokhnach wants to merge 2 commits into
Conversation
…#1210) An app that stops answering accessibility requests could previously block WDA forever, since XCTest offers no bounded timeout for the underlying snapshot request. Adds a new accessibilityDeadline setting/capability that, when set, aborts the request with a clear error instead of waiting indefinitely, caching the unresponsive state briefly so XCTest's own internal retries fail fast instead of each re-waiting the full timeout. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Aug 18, 2026
Collaborator
|
I will review it and run some tests tomorrow, very hectic day today. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1210: an app that stops answering accessibility requests could
previously block the whole WDA server forever, since XCTest offers no
bounded timeout for the underlying accessibility snapshot request that
backs most element/attribute lookups (including
.identifier, active-appdetection, etc.).
accessibilityDeadlinesetting/capability (NSTimeInterval,disabled by default). When set to a value > 0, a swizzle on
-[XCAXClient_iOS requestSnapshotForElement:attributes:parameters:error:]first confirms the target app's main run loop is genuinely responsive
(via the private
notifyWhenEventLoopIsIdleForApplication:API, wrappedin
FBXCAXClientProxy) before letting the real snapshot request proceed.If the app doesn't confirm responsiveness within the deadline, the
request is aborted with a clear "illegal/unresponsive application state"
error instead of risking an indefinite hang.
giving up. To avoid multiplying the configured deadline by the retry
count, a short-lived per-pid cache remembers "this app was just confirmed
unresponsive," so those retries fail fast instead of each re-running the
full wait.
handleActiveAppInfo:(GET /wda/activeAppInfo) is made resilient to.identifierreturningnil(which can legitimately happen once the newdeadline aborts the underlying fetch) - it now reports
"unknown"forthe app name instead of crashing.
Test plan
FBConfigurationTests.testAccessibilityDeadlineAbortsSnapshotRequestForDeadlockedAppfreezes the
IntegrationAppfixture's main thread (Deadlock appbutton,reworked to sleep instead of self-deadlock so it doesn't trip the OS
watchdog) and asserts that a snapshot request against it aborts within
bounds instead of hanging. Skipped on CI (
CIenv var) since itdeliberately freezes the app for ~20s.
accessibilityDeadlineset, a frozen app now fails gracefully in a fewseconds; with it unset (default), original unbounded behavior is
preserved unchanged.
WebDriverAgentLiband the new test target build and pass locally.