fix(cua-driver-rs)(macos): per-element AX messaging timeout + cycle/time guards for heavy webview walks#1755
Draft
f-trycua wants to merge 1 commit into
Draft
fix(cua-driver-rs)(macos): per-element AX messaging timeout + cycle/time guards for heavy webview walks#1755f-trycua wants to merge 1 commit into
f-trycua wants to merge 1 commit into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…ime guards for heavy webview walks get_window_state could hang indefinitely on apps with large or busy accessibility trees (heavy webviews). Reading an AX attribute is a synchronous XPC round-trip to the target app; while a renderer is materializing its tree that round-trip can stay pending forever, wedging the entire walk. Fix: call AXUIElementSetMessagingTimeout(app_elem, 1.5) right after creating the application element. The ceiling is inherited by every descendant, so a wedged element fails fast with kAXErrorCannotComplete in ~1.5s instead of blocking the traversal. Layered backstops in walk_element: - cycle dedup via a visited HashSet keyed on element pointer address, since AX is a graph and a malformed hierarchy can re-vend elements; - a 5s per-walk wall-clock budget that bails between calls (it cannot abort an in-flight call — that is the messaging timeout's job). These complement, not replace, the existing outer thread-level timeout. Refs #1537 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c8e8970 to
584705b
Compare
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.
Problem
get_window_statecan hang indefinitely on apps with large or busy accessibility trees (heavy webviews). Reading an AX attribute is a synchronous XPC round-trip into the target app; while a renderer is materializing its tree, that round-trip can stay pending forever and wedge the entire walk. The outer thread-level timeout then just tears down a stuck walk rather than letting it make progress.Fix
Set a per-element messaging timeout once, on the application element, right after
AXUIElementCreateApplication:AXUIElementSetMessagingTimeout(app_elem, 1.5)— the ceiling is inherited by every descendant element vended through the app element, so a single wedged element fails fast withkAXErrorCannotCompletein ~1.5s instead of blocking the whole traversal. This is the real anti-hang fix.Two layered backstops in
walk_element:visited: HashSet<usize>keyed on the element pointer address. AX is a graph, not a strict tree; a malformed hierarchy can re-vend an element already walked, and this stops that from inflating the walk.These complement, not replace, the existing outer thread-level timeout and the
MAX_DEPTHguard.Scope
platform-macosonly;platform-windows/platform-linuxunaffected.AXUIElementSetMessagingTimeoutis a stable HIServices symbol (since 10.4); declared alongside the otherAXUIElement*FFI bindings.Validation
cargo build --release -p cua-driverpasses.cargo test --no-run -p platform-macoscompiles (the pre-existinglibswift_Concurrency.dylibrpath issue is at the test-binary link step, not introduced here).Refs #1537
🤖 Generated with Claude Code