fix(android): give an adopted emulator the 60s bundle window of a new one - #1827
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A debug
stim androidon an emulator adopted from the pool got only the 20-second bundle window, while a newly created emulator gets 60 seconds. Adoption cold-boots the parked AVD and wipes the app's data before install, so the first launch is as slow as on a new emulator. Under heavy host load the app's first bundle request arrives after the 20 seconds are up. The launch is then reported aslaunched: 'unverified'with launch remedies, even though it is working.I reproduced this with this worktree's
apps/mobileon the real~/.stim(load average 100 to 150), adopting the parkedstim-1700-mobile. On an adopting run retried after a boot timeout, Stim reportedUNVERIFIED ... within 21s, and the app'sbundle_response_startedreached port 8084 about 57s into what a 60s window would have covered. The first adopting run only just stayed inside 20s: it reported'bundling', with the request at 18s after launch.The "Metro served the bundle 1.5 min earlier" in the issue was most likely Stim's own warmup (
bundle_prefetch_*), which correctly does not count as evidence. The original workspace has been removed, so I can't confirm this from its logs.Solution
An owned local emulator now gets the 60-second window when this run creates it or finishes adopting it:
device.created || device.adoptionPending. The check isadoptionPendingand notadopted, because a retry after a failed adopting run gets the device back from config with onlyadoptionPending. That retry still wipes and reinstalls the app, and it is the case I reproduced. The verify phase names the case:(new emulator)or(adopted emulator).Only the window changes. The evidence required for
true,'bundling'and'unverified'is the same, and so are the remedies. An emulator whose adoption finished on an earlier run keeps 20 seconds, as do rebooted owned AVDs, remote targets and physical devices. The lifecycle guide andwebsite/docs/dev-server-and-logs.mdare updated to match.Test plan
android-command.test.ts,launch verificationtable: I added two rows for an adopting emulator. With the bundle delivered at 23s the result istrueafter 26s. With no bundle the result isunverifiedafter 60s. Both rows fail againstmain'slaunch.ts(unverifiedafter 20000ms) and pass with this change.dist/cli.mjs androidon the emulator above, and the result wasbundle loaded, process alive (14.4s total). That run reused the already-adopted emulator, so it took the 20s path. Re-parking to rerun adoption needed a worktree remove and re-add, and that was not permitted in this session. The adoption runs described above are the evidence for the window itself.format:check,lint,build,typecheck,knip,test:runtimeandtest:e2e(99/99) pass. Inpnpm test, unrelated files hit 5s timeouts at load 300 to 500. Each of those files passed when rerun on its own.Fixes #1792