Skip to content

Investigate implicit shutdown after an external emulator restart #4585

Closed

Description

@thymikee

Purpose

Follow up on PR #4539, r4572557061. Plain close should not stop a new emulator boot that another actor started after the session’s original boot. This is separate from the Android cold-open acceptance runs still required by #4162.

Current evidence

At 0e19c8dfaf2a549bd6cfd49d3b1c50d56ee83dcd, the source permits this sequence:

  1. A session opens a stopped local Android emulator and records bootedByOpen: true.
  2. Another actor stops and starts the emulator, retaining its serial and the daemon’s claim file.
  3. The session reopens its app. Claim renewal verifies token/process identity and stamps updatedAtMs; it does not observe the device’s current boot. Android session refresh returns the stored device. updateOpenDevice retains boot ownership for the same device identity.
  4. Plain close can renew that claim and request shutdown of the current emulator boot.

See reopen, renewal, stored Android device, retained boot ownership, and implicit shutdown.

This is a source trace, not a runtime reproduction. No live external-reboot case has run. The earlier Darwin iOS stale-snapshot rejection does not settle this scenario. The existing boot-observation service already distinguishes device boots for claim acquisition; claim currency and ownership of a particular boot answer different questions.

Required behavior and completion

  • First reproduce the sequence through the routed open/close lifecycle with real claim handling. Record whether the second open actually boots anything and whether close asks for shutdown.
  • If reproduced, tie implicit-stop authority to the boot this session caused at the owning lifecycle/claim boundary. Reuse existing boot observation where appropriate. Specify behavior when boot observation is unavailable before implementation.
  • Preserve actual cold-reopen ownership, same-boot reopens, explicit close --shutdown, policy-denied warnings, provider/physical exclusions, and claim takeover behavior. A blanket selection.source === 'local' condition would drop legitimate cold reopens.
  • Add a regression that fails on the observed wrong shutdown and passes after the fix. Verify both a same-boot reopen and an external restart. Cover close without an intervening reopen if the reproduction exposes the same gap.
  • Run the affected exact-head checks and supported live-device verification before claiming the device behavior fixed.

No speculative guard, new flag, release workaround, or change to #4162’s pending acceptance evidence is included in this follow-up.

Activity

  1. apex-sentinel-staging commented on Nov 16, 2026

    @apex-sentinel-staging

    Apex Sentinel · Issue review

    Suggested label: bug

    The issue identifies a concrete existing behavior that is wrong: after an external emulator restart, a session's plain close can still request shutdown of the current boot, and it points to source locations plus required reproduction and tests.

    Required sections

    • Steps to reproduce (missing)
    • Expected and actual behavior (missing)
    • Version or environment (missing)
  2. added
    bugSomething isn't working
    and removed on Nov 17, 2026
  3. thymikee commented on Nov 18, 2026

    @thymikee
    MemberAuthor

    Current state: reproduced against #4539 head bcb9196 with real claim files through routed open and close. The controlled platform fixture cold-boots an emulator, changes the observed boot while retaining its serial and claim, then reopens without booting it. Plain close incorrectly asks the platform to stop the externally rebooted emulator. The reproducer records one failure and two passing controls. No real device was used.

    The session refreshes the claim on reopen, so the renewal timestamp no longer distinguishes the two boots. The next implementation checks the original claim timestamp against the current boot observation for the affected Android emulator path. A confirmed later boot should retain the emulator and report a distinct warning. Same-boot close, explicit shutdown, and denied or lost-claim behavior remain separate. Live verification still requires a supported cold-AVD route.

  4. thymikee commented on Nov 20, 2026

    @thymikee
    MemberAuthor

    Resolved in #4539 (0.22, c30537b): close stops only the emulator process this session's open launched, read once right before the stop, so an externally restarted emulator on the same serial is kept with a warning. Verified by live Android runs on a dedicated AVD.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions