Skip to content

platform-ios: wait for the simulator to settle after boot before launching the app #189

Description

@V3RON

Context

Harness runs unreliably on small CI hosts (e.g. GitHub macos-latest: 3 vCPU / 7 GB); a common symptom is the app failing to connect to the bridge shortly after simulator boot.

prepareSimulator in packages/platform-ios/src/instance.ts boots the simulator and waits with xcrun simctl bootstatus <udid> -b (packages/platform-ios/src/xcrun/simctl.ts waitForBoot). bootstatus -b returns as soon as the device reports Booted, but SpringBoard and the first-boot daemons keep consuming CPU for a while afterwards. On a 3-core host the app is then installed and launched into a simulator that is still busy, which stretches JS evaluation and can push startup past bundleStartTimeout / readyTimeout.

Proposal

Add a bounded "settle" step after waitForBoot, applied on constrained hosts (reuse the host-capability thresholds from startup-strategy.ts):

  • Poll a direct responsiveness probe, e.g. xcrun simctl spawn <udid> launchctl list, and proceed once two consecutive calls complete under ~300 ms; and/or
  • wait until os.loadavg()[0] drops below cores × 1.5;
  • cap the wait (e.g. 45 s) so a persistently busy host does not stall startup, and record the settle duration in diagnostics.

This should apply both when Harness booted the simulator and when it found one already Booting.

Files

  • packages/platform-ios/src/instance.ts (prepareSimulator)
  • packages/platform-ios/src/xcrun/simctl.ts (waitForBoot)
  • packages/platform-ios/src/startup-strategy.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