Skip to content

platform-ios: reduce XCTest agent per-tick cost on constrained hosts #188

Description

@V3RON

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

  1. Only run the watchdog query when the target app is .runningForeground (skip while it is not running / launching).
  2. Defer enabling autoAcceptPermissions until the app has reported ready over the bridge, rather than at agent start.
  3. 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.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions