Skip to content

iOS seed is shut down right after bootstatus, so every clone repeats iOS's first-boot work #1540

Done

Description

@sittingmongoose

What happened

Every fresh lease of an iPhone Duo simulator (iOS 27.3) spent about 5 minutes in iOS first-boot work
after the clone booted. Poster extensions, BackgroundShortcutRunner, CommCenter and other first-boot
daemons were running, and the host load average reached 200-400 (Apple silicon, 16 GB).

During that window:

  • opening Safari took 35-55 s;
  • the first XCUITest snapshot exceeded a 90 s client timeout.

What you expected

A clone of a ready seed should boot into a settled system.

How to reproduce

  1. Let simlock make a new iOS seed for a model.
  2. Lease that model and watch the host load for the first minutes after boot.
  3. Lease it again: every new lease repeats the spike.

Environment

simlock 0.7.0 (main at ee19e97 has the same code), macOS 27.3 arm64, Xcode 27.3, iOS 27.3 runtime.

Logs and evidence

src/drivers/ios/index.ts #makeSeed runs #bootAndWait (bootstatus) and then #shutdown straight
away. bootstatus returns before iOS finishes its first-boot work, so the seed never stores that work, and
each clone does it again.

The workaround we measured:

  1. Boot the seed once in the sources set.
  2. Wait about 8 minutes, until host load is back near idle (about 2.5).
  3. Launch and quit Safari once.
  4. Shut the seed down. It grew from 2.0 to 2.6 GB.

Cold leases from that seed:

  • opening Safari took 8.6-16.6 s;
  • the first snapshot took 3.9-8.75 s;
  • later snapshots took under 1 s;
  • the first-boot spike was gone.

Suggestion: let the seed settle before #shutdown. Settled could mean simulator CPU low for a while, or
a configurable delay such as drivers.ios.seedSettleMs. It costs minutes once per seed rather than once
per lease. Related: #1202.

Activity

  1. added
    bug:new
    on Nov 18, 2026
  2. self-assigned this
    on Nov 18, 2026
  3. V3RON commented on Nov 18, 2026

    @V3RON
    Contributor

    Reproduction

    Confirmed, as a gap: the seed's throwaway is shut down the moment it is ready. The expectation is a proposal: keep it booted 8 minutes (the reporter's settle time) first.

    src/drivers/ios/index-seed-provision.test.ts on bug/1540-repro, "a new iOS seed's throwaway stays booted for 8 minutes after it is ready before it is shut down". It uses the driver's default and checks both sides of the boundary (479 999 / 480 000 ms).

    pnpm exec vitest run --project unit src/drivers/ios/index-seed-provision.test.ts
    AssertionError: 1 ms before 8 minutes after ready the throwaway is still booted:
      expected [ [ 'simctl', '--set', …(3) ], …(3) ] to deeply equal []
    

    Root cause

    src/drivers/ios/seeds.ts:390-391: #makeSeed calls #simctl.shutdown right after #bootThrowaway. That is "ready", meaning bootstatus -b plus one listapps (simulator-boot.ts:48). It proves the device takes requests, not that first-boot daemons have finished. This matches ADR 0061 §1 ("one cold boot to ready, clean shutdown"), so the work is never saved into the seed and every clone does it again.

    Simplest fix

    Shape: wait SEED_SETTLE_MS = 480_000 on the clock port between boot and shutdown. Make it a driver option only (IosSimctlDriverOptions.seedSettleMs), with no config key. The test harness passes 0, which skips the wait.

           await this.#bootThrowaway(throwaway, sourceId);
    +      if (this.#settleMs > 0) {
    +        await new Promise<void>((resolve) => this.#clock.setTimer(this.#settleMs, resolve));
    +      }
           await this.#simctl.shutdown(throwaway);
    pnpm exec vitest run --project unit src/drivers/ios   # 757 passed
    pnpm typecheck                                        # clean
    

    Alternatives rejected

    • Wait for the throwaway's processes to go idle: needs thresholds measured on the slow lane.
    • A public ios.simulator.seedSettleMs key: adds config surface before 8 minutes is shown to be wrong.
    • Boot the seed itself to settle it (the workaround): ADR 0076 §1 says a source never boots.

    Risk

    • The first lease of each new kind waits 8 more minutes. Check client and MCP timeouts.
    • More files name the throwaway's UDID. Check that the lineage swap (ADR 0076 §2) covers them, and how long recording takes for the 2.6 GB seed.
    • STALE_MAKING_MS (seeds.ts:39, 300 s) no longer exceeds the longest make. Update it.

    Fast track

    • Defect: no — gap: a missing settle step
    • Fix tried: yes
    • Nothing public added or broken: no — first lease of a new iOS kind gets 8 min slower
    • No ADR or rule changed: yes
    • One fix: no — an idle-based settle changes the wait users see

    Written by an agent.

  4. removed their assignment
    on Nov 18, 2026
  5. V3RON commented on Nov 18, 2026

    @V3RON
    Contributor

    Being specified in #1732. This issue stays open until that feature ships.

    The file-list race found while designing it is #1731.

    Written by an agent.

  6. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    Shipped as #1732.

  7. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    Shipped as #1732.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:new

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions