Skip to content

Released iOS simulator stays booted after simlock daemon stop #1056

Closed

Description

@V3RON

What happened

After a lease was released and simlock daemon stop returned, the released iOS simulator kept running. No daemon owned it any more:

simlock lease --platform ios --device "iPhone 16" --detach   # lse_632aaee9…, device 5F3D67F7…
simlock release lse_632aaee9-4590-47b8-8f52-915a062b901d     # ok
simlock list                                                 # device state: reclaiming
simlock daemon stop                                          # ok
xcrun simctl --set $SIMLOCK_HOME/devices/ios list devices
#   simlock-a8e7126d-… (5F3D67F7-032F-4B35-9A26-A07C98A0A11B) (Booted)
pgrep -fl launchd_sim   # launchd_sim for that device still running

The warm pool probably kept it (warmPool.enabled keeps released devices booted). But once the daemon stops, nothing manages the device, and it keeps using RAM until the next daemon start or a reboot.

What you expected

One of these:

  • daemon stop shuts down idle (unleased) devices it booted before it exits, or
  • the docs say clearly that idle warm devices stay booted after daemon stop, and how to shut them down. The daemon stop docs (website/src/content/docs/docs/reference/cli.mdx:357, worker/running-the-daemon.mdx:119) say nothing about it.

How to reproduce

  1. Fresh SIMLOCK_HOME, default config.
  2. simlock lease --platform ios --device "iPhone 16" --detach, then simlock release <lease-id>.
  3. Right away, simlock daemon stop.
  4. xcrun simctl --set $SIMLOCK_HOME/devices/ios list devices shows the device (Booted).

Found in an agent onboarding experiment (Haiku installing and setting up simlock from the docs). In that flow it leaves a booted simulator behind after the "prove it works, then clean up" step.

Environment

simlock 0.3.0 (main @ 3431dd0, packed locally), macOS 26.6 (Darwin 25.6.0), Xcode 27.0, iOS 27.0 runtime. simlock doctor: {"findings":[]}.

Logs and evidence

The device was in reclaiming when daemon stop was sent. It is not known whether the reclaim finished before the daemon exited.

Written by an agent.

Activity

  1. added
    bug:new
    on Oct 30, 2026
  2. V3RON commented on Oct 31, 2026

    @V3RON
    ContributorAuthor

    Maintainer decision: daemon stop shuts down the idle (unleased) devices this daemon booted before it exits. Warm devices are not kept across a daemon stop.

    Written by an agent.

  3. self-assigned this
    on Oct 31, 2026
  4. V3RON commented on Oct 31, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Gap: the expectation is the maintainer's decision on this thread, a proposal.

    e2e/daemon-lifecycle.test.ts › "daemon stop shuts down every idle device it booted, one still reclaiming included, and leaves the leased one running" on bug/1056-repro. Two idle devices (one released right before the stop, still reclaiming), one leased; asserts the fake driver's shutdown calls.

    pnpm test:e2e e2e/daemon-lifecycle.test.ts -t 'idle device'
    AssertionError: expected [] to deeply equal [ 'fake-android-1', 'fake-ios-1' ]
     ❯ e2e/daemon-lifecycle.test.ts:279:30
    

    Correction to the issue: the docs do cover this. website/src/content/docs/docs/worker/running-the-daemon.mdx:117 says "does not shut down devices … the next daemon picks them up".

    Root cause

    src/daemon/main.ts:706-710: the worker's settle waits for background reclaims (leasing.settle), so a device still reclaiming ends ready. Then core.drain() (src/core/warm-pool/converger.ts:295) closes the pool and waits for its passes. Neither step shuts down an idle ready device, and dispose does not either. No ADR requires keeping them booted (checked 0004, 0017, 0019, 0038, 0041).

    Simplest fix

    After drain settles, shut down every ready virtual device that has no lease and no claim, through the pool's existing #shutdown (lifecycle.shutdown, cleanup claim, a log line with reason daemon-stop). A throwaway version of that loop at the end of WarmPool.drain made the test pass. In the same change, update running-the-daemon.mdx:117 and the daemon stop row in reference/cli.mdx.

    Alternatives rejected

    • Shut down in beginStop: it runs before reclaims settle, so the device that is still reclaiming would be missed.
    • Docs only: the maintainer decided otherwise.
    • Shut down every device: leases outlive daemon stop (ADR 0004 §3, src/daemon/AGENTS.md rules).

    Risk

    • Shutdowns must finish before dispose, which stops Android's adb server.
    • The next start boots the learned kinds again (ADR 0038), so every restart now costs a boot.
    • The fake reclaim is fast: a fix reading a snapshot taken at stop could still pass. Check the order in code.

    Written by an agent.

  5. removed their assignment
    on Oct 31, 2026
  6. added
    bug:ready
    and removed
    bug:new
    on Oct 31, 2026
  7. self-assigned this
    on Oct 31, 2026
  8. V3RON commented on Oct 31, 2026

    @V3RON
    ContributorAuthor

    Maintainer confirmed the behaviour shipped in #1150: daemon stop (and simlock update) shuts down idle devices, so the next start boots the warm pool's devices again. Kept as is.

    Written by an agent.

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

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions