Skip to content

Android: INSTRUMENTATION_FAILED on the first snapshot after a boot or restore is not retried #4109

Closed

Description

@0xdaniell

What happens. On an emulator that has just finished booting, or just had /data restored, the first snapshot fails about 1 time in 10:

Android snapshot helper failed before returning parseable output: android.util.AndroidException: INSTRUMENTATION_FAILED: com.callstack.agentdevice.snapshothelper/...SnapshotInstrumentation

The helper is installed and current (android_snapshot_helper_install_decision says reason: current, and the sha matches). The session first exits with android_snapshot_helper_session_exited_before_ready, then the fallback capture fails within about 200 ms. The next snapshot works, every time we looked.

Version. 0.21.31, Android 36 emulator.

Proposal. Treat INSTRUMENTATION_FAILED as retriable once inside the capture, after the runtime reset that already happens in the failure path. We run that as a local patch; the error is already reported as retriable: true, so the caller's only other option is to repeat the command itself.

Activity

  1. added
    bug
    on Oct 31, 2026
  2. thymikee commented on Oct 31, 2026

    @thymikee
    Member

    Triage: bug; actionable without more input from you. The error is already reported as retriable: true, so one retry inside the capture, after the helper runtime reset, is a smaller fix than every caller repeating the command. Scope: retry once, only for INSTRUMENTATION_FAILED before the helper session is ready; a second failure surfaces as it does today. Related: #4005 and #4030 track other first-capture failures of the same helper.

  3. added
    in-progress
    on Nov 2, 2026
  4. thymikee commented on Nov 2, 2026

    @thymikee
    Member

    An agent is picking this up; the PR will link here.

  5. thymikee commented on Nov 2, 2026

    @thymikee
    Member

    The fix is up in #4156: on a refused helper start before the session is ready, the capture resets the helper runtime and retries once. The retry fires only on the system's exact refusal record (INSTRUMENTATION_FAILED, id=ActivityManagerService, status code -1, and nothing a started helper prints), so other failures still surface as before.

    We couldn't reproduce the refusal on our Android 15 emulator. If you can run #4156's branch on your Android 36 setup instead of your local patch, please post whether android_snapshot_helper_start_retry shows up in the debug log and whether the snapshot then succeeds. If it doesn't fire, the raw helper stdout from one failure would show whether Android 36 words the refusal differently.

  6. added a commit that references this issue on Nov 3, 2026
    dc39b31
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

    bugin-progressready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions