Skip to content

serve-sim-bin can remain orphaned and consume ~100% CPU after simulator is shut down #102

Description

@VectorLu

Summary

serve-sim-bin can remain alive as an orphaned background process after the target simulator is shut down, continuing to listen on its stream port and consume roughly one full CPU core for an extended period.

Environment

  • serve-sim: 0.1.40
  • macOS: 15.6.1
  • Hardware: Apple Silicon MacBook Air, M3, 16 GB RAM
  • Target simulator: iPhone 16
  • Target simulator state when discovered: Shutdown

What Happened

I found a long-running serve-sim-bin process after I had already quit Simulator. The target simulator was no longer booted, but the helper was still running and consuming high CPU.

The process looked like this, with the local npm cache path and simulator UDID redacted:

.../node_modules/serve-sim/bin/serve-sim-bin <simulator-udid> --port 3100

Observed process state:

Parent process: launchd / PID 1
Elapsed time: more than 13 days
CPU: ~95-100%
Memory: ~3 GB
Listening: TCP port 3100
Target simulator: iPhone 16 (Shutdown)

After killing the process manually, system CPU idle immediately improved from roughly 50-60% idle to roughly 90-95% idle, memory usage dropped by about 3 GB, and the machine stopped running hot.

Expected Behavior

If the target simulator is shut down or becomes unavailable, the helper should not continue polling/spinning indefinitely. It should ideally do one of the following:

  • exit when the target simulator shuts down or disappears
  • back off aggressively when frame capture fails
  • stop after an idle/unreachable timeout
  • keep a parent/session relationship so detached helpers can be cleaned up predictably

Actual Behavior

The helper stayed alive for more than 13 days with the target simulator shut down and continued consuming close to a full CPU core.

Notes

I do not have the exact original command that launched it. It may have been started by an agent/editor integration using serve-sim or serve-sim --detach. I also do not have the helper logs from the original run.

This seems related to lifecycle handling for the per-device helper rather than the preview UI itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions