Skip to content

Android open fails with "helper could not launch the application" when am start -W reports "Status: timeout" on slow cold starts #4095

Closed

Description

@tamura-go-tamura

Hi! Thanks for agent-device, it's been great for our Android flows.

We're hitting an occasional open failure where the app actually launched fine.

Environment

  • agent-device 0.21.29 (via @e2e-dev/mobile 0.12.4). The Status: ok check in app-lifecycle is unchanged in 0.21.35 and on current main (packages/platform-android/src/app-lifecycle.ts).
  • Android emulator (x86_64), React Native debug build
  • Cold start takes about 9–13 s

What happens
open sometimes fails with:

COMMAND_FAILED: Android helper could not launch the application

…but the app is up and running right after.

Why (as far as I can tell)
The Android helper's open runs am start -W. When the launch takes more than ~10 s, am stops waiting and prints Status: timeout, while the launch itself keeps going. app-lifecycle treats any output that doesn't match /^Status: ok\r?$/m as a failure, so the timeout case is reported as a launch failure.

Evidence
In all 3 failures the helper output looked like this (package name replaced):

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.DEFAULT,android.intent.category.LAUNCHER] cmp=com.example.app/.MainActivity }
Status: timeout
LaunchState: UNKNOWN (-1)
Activity: com.example.app/.MainActivity
WaitTime: 10330
Complete

ActivityTaskManager logged the START with result code=0, and Displayed com.example.app/.MainActivity showed up 0.4–1.4 s after the helper returned the timeout. No crash or ANR.

For comparison, a successful (slow) cold start:

Status: ok
LaunchState: COLD
Activity: com.example.app/.MainActivity
TotalTime: 11591
WaitTime: 11610
Complete

Idea
Would it make sense to treat Status: timeout with an Activity: line as "launch was dispatched" and not fail open? Or, alternatively, keep waiting until the app is in the foreground before deciding? We plan to work around it locally with a patch that relaxes that check, but we'd much prefer an upstream fix. Does that sound reasonable, or is there a reason timeout is treated as a failure?

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. Confirmed on main: tryAndroidHelperLaunch in packages/platform-android/src/app-lifecycle.ts fails open on anything but Status: ok, and a unit test pins Status: timeout as a failure. am start -W stops waiting after about 10 s while the launch continues, so a slow cold start is reported as a failed launch. The intended fix: treat Status: timeout with an Activity: line for the requested package as dispatched, then require the package to reach the foreground within the open's deadline before returning ok. Thanks for the timeout and success outputs side by side.

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

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions