Context
Harness runs unreliably on small CI hosts (e.g. GitHub macos-latest: 3 vCPU / 7 GB). One constant source of load inside the simulator is the XCTest agent's tick loop.
Every tick (default 1 s, HarnessXCTestAgentUITests.swift testAgentSession) does:
observeTargetApplication() → targetApplication.state query
PermissionPromptWatchdog.tick() → springboard.buttons.matching(NSPredicate(label IN ...)).firstMatch.exists
The SpringBoard query is a full accessibility-tree snapshot served by testmanagerd, so the sim pays for an AX snapshot every second for the whole run — including during the app's launch/connect window, which is exactly when the host is most starved. configurePermissions is sent right at ensureStarted (packages/platform-ios/src/xctest-agent.ts), so auto-accept polling is active before the app under test has even been launched.
Proposal
- Only run the watchdog query when the target app is
.runningForeground (skip while it is not running / launching).
- Defer enabling
autoAcceptPermissions until the app has reported ready over the bridge, rather than at agent start.
- Make the tick interval host-adaptive: the CLI already forwards
HARNESS_XCTEST_AGENT_TICK_INTERVAL_MS; derive a default (e.g. 2–3 s) from getHostCapabilities() on constrained hosts instead of the fixed 1 s.
- Cheapen the probe: check
springboard.alerts.firstMatch.exists first and only enumerate buttons when an alert is present.
Files
packages/platform-ios/xctest-agent/HarnessXCTestAgentUITests/HarnessXCTestAgentUITests.swift
packages/platform-ios/xctest-agent/HarnessXCTestAgentUITests/PermissionPromptWatchdog.swift
packages/platform-ios/src/xctest-agent.ts (getLaunchEnvironment, ensureStarted)
packages/platform-ios/src/xctest-agent-capabilities.ts
Part of a broader effort to make Harness reliable on constrained CI runners.
Context
Harness runs unreliably on small CI hosts (e.g. GitHub
macos-latest: 3 vCPU / 7 GB). One constant source of load inside the simulator is the XCTest agent's tick loop.Every tick (default 1 s,
HarnessXCTestAgentUITests.swifttestAgentSession) does:observeTargetApplication()→targetApplication.statequeryPermissionPromptWatchdog.tick()→springboard.buttons.matching(NSPredicate(label IN ...)).firstMatch.existsThe SpringBoard query is a full accessibility-tree snapshot served by
testmanagerd, so the sim pays for an AX snapshot every second for the whole run — including during the app's launch/connect window, which is exactly when the host is most starved.configurePermissionsis sent right atensureStarted(packages/platform-ios/src/xctest-agent.ts), so auto-accept polling is active before the app under test has even been launched.Proposal
.runningForeground(skip while it is not running / launching).autoAcceptPermissionsuntil the app has reported ready over the bridge, rather than at agent start.HARNESS_XCTEST_AGENT_TICK_INTERVAL_MS; derive a default (e.g. 2–3 s) fromgetHostCapabilities()on constrained hosts instead of the fixed 1 s.springboard.alerts.firstMatch.existsfirst and only enumerate buttons when an alert is present.Files
packages/platform-ios/xctest-agent/HarnessXCTestAgentUITests/HarnessXCTestAgentUITests.swiftpackages/platform-ios/xctest-agent/HarnessXCTestAgentUITests/PermissionPromptWatchdog.swiftpackages/platform-ios/src/xctest-agent.ts(getLaunchEnvironment,ensureStarted)packages/platform-ios/src/xctest-agent-capabilities.tsPart of a broader effort to make Harness reliable on constrained CI runners.