Skip to content

Reduce XCTest permission watchdog CPU usage and make its polling interval tunable#163

Merged
V3RON merged 2 commits into
mainfrom
perf/xctest-permission-watchdog-polling
Jul 15, 2026
Merged

Reduce XCTest permission watchdog CPU usage and make its polling interval tunable#163
V3RON merged 2 commits into
mainfrom
perf/xctest-permission-watchdog-polling

Conversation

@V3RON

@V3RON V3RON commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What is this?

This PR sharply reduces the CPU cost of the iOS permission-dialog watchdog that runs inside the XCTest agent when permissions is enabled. Previously, every watchdog tick evaluated 11 known button labels against SpringBoard, and each evaluation triggered a separate cross-process accessibility snapshot — roughly one snapshot every 100 ms, continuously, for the whole session. On busy CI runners (notably macos-26-arm64) this kept the agent, testmanagerd, and SpringBoard permanently busy and degraded overall test performance. It also makes the watchdog's polling interval tunable without rebuilding the agent.

How does it work?

The watchdog's idle path now costs a single accessibility snapshot per tick: one query matches SpringBoard buttons against the full set of known permission-button labels with a label IN {…} predicate. Only when that guard matches — meaning a permission dialog is actually on screen — does the watchdog fall back to the existing priority-ordered label loop, so tap selection on multi-button dialogs (for example preferring "While Using the App" over "Allow Once") behaves exactly as before.

The tick interval keeps its 1-second default so permission dialogs are still accepted quickly enough for tight test timeouts, but it can now be overridden through the HARNESS_XCTEST_AGENT_TICK_INTERVAL_MS environment variable: the harness forwards it from its own environment into the agent's launch environment, and the agent falls back to the default when the value is unset or invalid. Combined with the single-snapshot guard, idle snapshot volume drops from ~11 per second to ~1 per second.

Why is this useful?

  • iOS test runs with permissions enabled no longer pay a constant CPU tax for the whole session, which directly improves test performance and stability on CI runners.
  • Permission auto-acceptance behaves identically — the same dialogs are detected and the same buttons are tapped.
  • CI environments can tune the polling cadence via an environment variable without rebuilding the XCTest agent.

The branch also carries the playground testTimeout raise to 10 s (cherry-picked), since slow CI UI interactions on macos-26-arm64 runners were already hitting the previous 5 s budget independently of the watchdog.

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-harness Ready Ready Preview, Comment Jul 15, 2026 7:32am

Request Review

@V3RON
V3RON force-pushed the perf/xctest-permission-watchdog-polling branch from 0af8935 to 4ff6f26 Compare July 15, 2026 07:32
@V3RON
V3RON merged commit 50808c7 into main Jul 15, 2026
10 of 11 checks passed
@V3RON
V3RON deleted the perf/xctest-permission-watchdog-polling branch July 15, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant