fix(mobile): never pin an install's file path as the app app.open() launches
Merged
OK
2mo ago+99+99+01234567890123456789-17-17-01234567890123456789
A target with only app.appPath on Android: device.installApp() succeeds, then app.open() fails with Android runtime hints require an installed package name, not "/.../benchmark.apk". CI never saw it because the benchmark always sets bundleId.
Root cause (upstream, agent-device 0.21.18)
install --jsonreturnsapp: <apk path>and nopackagewhen it cannot identify the APK (src/daemon/handlers/session-app-deployment.ts,buildNonIosDeployResult:app || packageName || launchTarget || appPath).- Its binary
AndroidManifest.xmlparser never matches aapt2 output: it requires a 36-byte start-element header and countsattributeStartfrom the chunk, butResXMLTree_node's header is 16 bytes andattributeStartis relative toResXMLTree_attrExt(packages/platform-android/src/manifest.ts,parseStartElementPackageName). Its tests only use text manifests. - The fallback is the SDK's
aapt, searched underANDROID_SDK_ROOT,ANDROID_HOME,~/Android/Sdk, so not the macOS default~/Library/Android/sdk. - The last fallback diffs
pm list packagesbefore and after install, which finds nothing when the package is already on the device. - Proof on this Mac:
resolveAndroidArchivePackageName(apk)fromagent-device/artifactsreturnsundefined, and withANDROID_HOMEset it returnsdev.e2e.benchmark. - An upstream fix for the parser (a 10-line offset fix plus a test with a real aapt2-compiled manifest) is ready locally and not opened yet. With it,
agent-device install --jsonreports"package": "dev.e2e.benchmark"with no SDK env. The bump comes in a follow-up PR once it is released.
This PR
installAppopens by the id agent-device reported, else theapppassed in, and never byresult.app(packages/mobile/src/surface.ts). With neither, it fails at the install withENGINE_FAILUREnamingapp.bundleIdor theappoption, instead of pinning a file path that fails later inapp.open().app.open()on a device now keeps the engine's ownUNSUPPORTED_CAPABILITYreason. Before, core rewrote every one into "pin one with the target's app.bundleId or app.appPath", even withappPathset (packages/e2e/src/run/fixtures.ts). Core's message now covers only an engine with no relaunch hook.- The mobile restart message now reads correctly under both
app.open()andapp.restart(): "launching the app needs...". - Docs:
installAppreturn rules (reference, README) and a Troubleshooting entry for the Android case (ANDROID_HOME, daemon restart, orbundleId). - Decision: a non-engine build installed with no identity and no
appalso fails, becauseInstalledApp.apphas no honest value to return. Before, it returned the path.
Verified
Ran it locally: yes
- Pixel_7_API_36 emulator, scratch project with
app: { appPath: '.build/android/benchmark.apk' }and a test that runsawait device.installApp(); await app.open();and then expects the home list.dev.e2e.benchmarkwas already installed andANDROID_HOMEwas unset, the stress-test setup.
| main | this branch | |
|---|---|---|
Android, no ANDROID_HOME | installApp resolves {"app":"/.../benchmark.apk"}, then app.open(): ENGINE_FAILURE: open /.../benchmark.apk failed: Android runtime hints require an installed package name | installApp: ENGINE_FAILURE: installed /.../benchmark.apk, but agent-device reported no bundle id or package for it, so nothing can open it: name the app with the target's app.bundleId or installApp's app option |
Android, ANDROID_HOME set (daemon restarted) | not run | installApp resolved to {"app":"dev.e2e.benchmark","bundleId":"dev.e2e.benchmark"}, app.open() launches, test passes |
iOS, appPath only, no installApp() | UNSUPPORTED_CAPABILITY: app.open() has no app to launch on target "ios": pin one with the target's app.bundleId or app.appPath, or bring one up with device.openApp | UNSUPPORTED_CAPABILITY: launching the app needs the target's app.bundleId, or the build the target's app.appPath names installed first with device.installApp() |
iOS, appPath only, installApp() then app.open() | not run | passes, resolves dev.e2e.benchmark |
- Mobile benchmark locator suite on the Android emulator, branch build,
E2E_MOBILE_BENCHMARK_ANDROID_APPset:54 passed | 1 skipped. - No video:
--videofails on this host withstart video recording failed: 4 devices match this request equally, because iOS simulators were booted next to the emulator and the video start passes no device selection. That bug is on main too and out of scope here.