Repository navigation
fix(daemon): concurrency and cancellation safety (review P0-B) - #197
Merged
Merged
Conversation
- ictl-ax: a request dropped halfway (a background check giving way) abandons the accessibility session instead of leaving its stream mid-message; writes time out; a closed connection ends the wait; an unanswered request keeps the session - background checks never restart the phone's accessibility daemon - an action counts as waiting for the phone only while it waits for the lock, not while its task is paused - main loop: an asked-for supervision round that couldn't run is retried 200 ms later; at most 256 clients at once; finished connections are reaped first - scoped tasks: the front app is checked again once the action holds the device lock; WebEval is checked against the app that shows the page - TapElement scroll.max is bounded (1..=15); scroll search and wait_for stop when the task is paused or the caller goes away Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… lock, tap check, AX reader) - scope_recheck: an action the user just allowed on a screen whose app WDA didn't name goes through while it is still unnamed; an unnamed front app otherwise gets the full "can't tell" text (it said "became ") - WebEval in a scoped task asks the user without holding the Web Inspector, then starts over (lock, task state, device, page) and runs only on the app allowed; a page whose host isn't known (unlisted host, WebKit's own process) counts as an unknown app and never joins the scope - tap_element checks may_continue right before tapping - ictl-ax: a request dropped halfway also stops the session's reader; the reader's replies time out after 5 s - main loop: a round that ran clears a pending retry; supervision rounds come before new clients; scope_gate's look-up counts as waiting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Review fixes (685220d):
Device (iPhone 15 Pro Max, iOS 27.2.1): while a scoped task's |
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.
What and why
P0, second batch, from the same full review of
mainafter #195 (the daemon's concurrency and cancellation). Independent of #196; based onmain.ictl-axSession): a background check (the control page's alert and status polls) that gives way to an action is dropped mid-request, which left the DTX stream mid-message for the next request. Now a request dropped before its answer marks the session abandoned (is_closed), so it is opened again; a closed connection ends the wait; writes time out after 5 s as an I/O timeout; an unanswered request still keeps the session.core::BACKGROUNDtask-local,restart_stuck_ax): they may be dropped halfway; only actions decide that.Waitingonly while waiting for the lock (lock_admitted(…, counted)): an action held while its task was paused counted as waiting, and the page's background checks gave way for the whole pause. The Web lane's lock never counts.Daemon::wake) that couldn't take the device was only noticed when the loop next woke, up to the 10 s tick; now the loop awaits the running round and asks again 200 ms later. At most 256 clients at once (more wait in the socket's queue); finished connections are reaped before new ones are accepted.scope_gatelets the lock go before asking the user, so the app in front could change before the action ran;scope_recheckchecks again once the action holds the device lock (no question then: out of scope by now is refused).WebEvalis checked against the app that shows the page (Check::Page, in the Web lane after the page is picked), not the one in front.TapElement.scroll.maxis bounded by the daemon too (1..=15; a rawu32::MAXheld the phone for hours). The scroll search andwait_for(WDA and native) stop as soon asmay_continuesays no (task paused or taken over, caller gone); the search taps nothing then. The search's end check usesunchanged_viewport(complete, non-empty reads only), asscroll_collectdoes.Tests
1. Unit tests
cargo test --workspace --all-features --locked: 560 passed; clippy-D warnings;cargo fmt --checkfor all 11 packages;tests/check_regression_cases.py: 0 missinga_cancelled_request_abandons_the_session,an_unanswered_request_keeps_the_session,a_closed_connection_ends_the_wait(ictl-ax);waiting_for_a_paused_task_doesnt_hold_off_the_checks,a_scoped_action_is_checked_again_with_the_lock_held,a_tap_by_text_scrolls_within_bounds;within_scopeandCheck::Pageinan_approved_app_joins_the_scope_for_the_rest_of_the_taskandwhat_each_request_checks_against_the_scopeserve) itself; tested on the device (below)2. Real-device regression
tests/device/run.py: 16 calls, 0 failed3. Regression cases
4. Real-device proof
alert_check/statuswith the background flag nonstop while 24 actions ran (swipes, scroll-search taps, Home, launches), twice: 0 failed actions, ~9300 checks gave way, no AX reconnect or axauditd restart in the log; 4 s after the actions the checks answered againTapElementwithscroll.max16 or 0: refused at oncewait_forfor 20 s, task paused at 2.5 s: answered "interrupted" at 2.7 s (it held the phone for the whole timeout before)not_sent,preflight)web_evalon Safari's page by the Settings-scoped task: asked once for Safari; rejected → not run (not_sent,preflight); approved → run; the next call not asked againChecklist
max_scrollsto 1..=15🤖 Generated with Claude Code