[Bug]: existing-profile attach misses Chrome's consent prompt when Chrome has several windows open
Primary area
Cua Driver
Summary
On macOS, browser_prepare with strategy: existing_profile against a Chrome window that is fullscreen on another Space refuses with browser consent did not settle within its bounded attempt. Chrome does show "Allow remote debugging?", but as its own window on another Space, and the active Space switches to it. The prompt reaches the screen about 4.5 s into the call, when the driver's consent window is ending. It stays open after the refusal, and pressing Allow then attaches nothing.
Reproduction
- Turn on "Allow remote debugging for this browser instance" at
chrome://inspect/#remote-debuggingin Chrome's default profile, put its windows in fullscreen and work in another fullscreen app. - Run the daemon from its LaunchAgent in unrestricted mode, with Full Disk Access so it can read
DevToolsActivePort(#4275). cua-driver call browser_prepare '{"pid": <chrome pid>, "window_id": <fullscreen window id>, "session": "s", "strategy": {"kind": "existing_profile"}}'
4 of 4 attempts.
Expected behavior
The driver finds the prompt and presses Allow, as in the native check on #4595, or refuses with a reason that says the prompt opened where it couldn't reach it.
Actual behavior
{
"refusal": {
"code": "browser_wrong_target_refused",
"message": "browser consent did not settle within its bounded attempt"
},
"status": "refused"
}
The call took 6.0 s. list_windows for the Chrome pid, polled about every 0.5 s, with its top-level current_space_id, next to the seconds since the last keyboard or mouse input (HIDIdleTime from IOHIDSystem). Times from the start of browser_prepare:
-20.0 s active Space 1239 (the fullscreen app in use), input idle 22 s
1.5 s active Space 6, input idle 43 s; new window 33959 "Allow remote debugging?", is_on_screen false
4.6 s window 33959 is_on_screen true, space_ids [6]
6.0 s browser_prepare returns the refusal; window 33959 still on screen
17 s first input since the call; active Space back to 1239 by 19 s
66 s window 33959 still open on Space 6 when polling stopped
No input moved the Space: idle time kept rising through the switch. On an earlier run I pressed Allow after the refusal; nothing attached, and the daemon held no connection to Chrome's debugging port. I don't know whether AX can reach the prompt window.
Environment
Cua Driver 0.33.3, release app, daemon from its LaunchAgent in unrestricted mode with Accessibility, Screen Recording and Full Disk Access granted. macOS 27.0 (26A428), Apple silicon, Stage Manager on. Google Chrome 154.0.8037.95, default profile, every window fullscreen.
Evidence
The poll above. consent_surface_ids scans the approved window and Chrome's other titled windows, leaves out windows titled "Allow remote debugging?", and looks for the Allow button inside an AXSheet in those trees:
https://github.com/trycua/cua/blob/2b3e4e548c6d27f918f5367f84c094151aa10c8f/libs/cua-driver/rust/crates/platform-macos/src/browser/consent_ui.rs#L61-L80
Here the prompt opened as its own window on Space 6 while the approved window was on Space 47. The 4 s budget starts 500 ms into the claim, so it ends at about 4.5 s, around when the prompt reached the screen (4.2 s and 4.6 s on two runs): https://github.com/trycua/cua/blob/2b3e4e548c6d27f918f5367f84c094151aa10c8f/libs/cua-driver/rust/crates/cua-driver-core/src/browser/prepare.rs#L76
Workaround and additional context
Not tried: taking the window out of fullscreen before attaching.
Related: #3440 had the same refusal with separate, AX-unresolved "Allow remote debugging?" windows and was closed because it didn't reproduce on the signed-app path. This is the signed release app; what differs is that the approved window is fullscreen on another Space. #3458 covers AX for windows off the current Space, and #4595 kept the 4 s bound.
Submission checks
- [x] I searched for duplicate issues and active pull requests.
- [x] This issue describes a single problem.
- [x] I removed credentials, private data, sensitive screenshots, and vulnerability details from this public report.
Correction: fullscreen isn't the cause. More runs on the same machine:
- Non-fullscreen Chrome window on the desktop Space while I worked in another fullscreen app: same refusal, and the active Space still switched to the prompt.
- Non-fullscreen window on the current Space, with me looking at it and not touching anything: same refusal. The prompt was on screen 2.6 s into the call and the call refused at 7.1 s.
get_window_stateon that window while the prompt was up shows the sheet in its tree: anAXSheet"Allow remote debugging?" with its Allow button (elements 653 to 659 of 903). The prompt's own 448x240 window staysax_unresolved, as in #3440.
What changes the outcome is how many windows Chrome has open. A throwaway Chrome with its own --user-data-dir and remote debugging allowed, same approved window, me on the same Space:
| Chrome windows | Result | Time |
|---|---|---|
| 1 | attached_existing_profile, displayed_consent_prompt: true |
4.6 s |
| 10 (9 more with a page of 800 links, buttons and paragraphs) | browser consent did not settle within its bounded attempt |
7.0 s |
consent_surface_ids returns every titled window of the browser pid, approved window first, and handle walks each of them (up to 5,000 elements) before it checks its deadline:
https://github.com/trycua/cua/blob/2b3e4e548c6d27f918f5367f84c094151aa10c8f/libs/cua-driver/rust/crates/platform-macos/src/browser/consent_ui.rs#L282-L330
With get_window_state, the 10 windows of my real Chrome took 0.4 to 1.6 s each, 9.6 s together. So the first pass reads the approved window before the prompt exists and is still walking the others when the 4 s run out. That last step is inference from these timings.
Fullscreen adds the Space switch on top. I've retitled the issue to match.
Thanks for the report, @FredAmartey. I've labelled it and assigned @injaneity to take a look. There is a related PR in #4647, which we'll review on its own.