Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27750] Android: CLI fails to recognize avd emulator is booted when it starts it

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-02-12T11:35:19.000+0000
Affected Version/sRelease 9.0.0
Fix Version/sRelease 9.0.0, node-titanium-sdk 4.3.1
ComponentsAndroid, CLI
Labelscb-tooling
ReporterChristopher Williams
AssigneeChristopher Williams
Created2020-02-06T15:01:00.000+0000
Updated2020-02-12T11:35:19.000+0000

Description

We're seeing native modules builds (like this one for ti.map: https://jenkins.appcelerator.org/blue/organizations/jenkins/modules%2Fti.map/detail/PR-285/9/pipeline/) failing to run our test suite because once it generates a project and launches, it never seems to think the emulator is fully booted. I can reproduce locally. If I pre-boot an emulator and launch, it recognizes the emulator has booted and works. If I don't have one up and running, it fails to recognize when the emulator has booted.

Comments

  1. Christopher Williams 2020-02-06

    My best guess here is that the adb:track-devices command isn't re-firing when the device has booted up. I assume it used to to denote a "state" change, but suddenly it no longer does so, so the node-titanium-sdk code just never re-checks on it's own to see if the emulator has booted? https://github.com/appcelerator/node-titanium-sdk/blob/master/lib/emulator.js#L233-L280
  2. Christopher Williams 2020-02-06

    Adding some logging, in this case "adb host:track-devices" typically gets called twice. Once with "undefined" (aka no devices running), and then again when he emulator process starts (with a value like "emulator5554 offline"). But in the second case, the emulator boots pretty much *immediately* due to snapshots - so while adb is reporting the emulator is alive but "offline" it's actually booted almost instantaneously - but "adb host:track-devices" won't fire again. So we'll see the initial offline state and wait around for another event that never happens. It looks like we can't rely on "adb host:track-devices" to be the only trigger for re-checking emulator state.
  3. Christopher Williams 2020-02-06

    https://github.com/appcelerator/node-titanium-sdk/pull/140
  4. Joshua Quick 2020-02-06

    For everyone's info, this is only an issue when launching the Android emulator via QuickBoot/Snapshot. *Steps to reproduce:*

    Ensure you have Android Emulator (aka: AVD) version 27.0.2 installed.

    Launch the emulator by handle.

    Quit the emulator via the \[x\] button, which will auto-create a snapshot. (Do not shut it down via virtual power button.)

    Launch emulator via Titanium CLI.

  5. Chris Barber 2020-02-06

    Possibly related to TIMOB-25406, TIMOB-25194, and TIMOB-19995.
  6. Chris Barber 2020-02-06

    I cannot reproduce. I've tried both from the SDK (master/9.0.0) and by directly invoking node-titanium-sdk's ADB via Node's REPL and they both work. I've looked at the current code as well as the proposed PR and I can't find anything wrong with the current code other than isRunning() could possibly be renamed to isReady(). If a device is "offline", then it might as well be shutdown. I don't believe we can connect via ADB to a device that is "offline", thus given the context, we need isRunning() to return true if and only if the device is online and ready. Furthermore, you can't even get Android Emulator 27.0.2. The latest as of today is 29.3.4. There's no way to downgrade. I find it hard to believe that code that hasn't been touched in over a year does NOT work with 27.0.2, but works with 29.3.4. I'm curious about how/why trackDevices() would only emit an "offline" event without a subsequent "device" event? In my testing, I could always get the "device" event. Are you seeing a race condition? Can you reproduce by manually invoking node-titanium-sdk? So, until I see some more reason/proof, I do NOT think we should merge the PR.
  7. Hans Knöchel 2020-02-07

    Happens for us every time. cb: You can try our app if you want. It definitely does not happen for all apps, but at least for some of them (maybe our modules / Alloy play into it).
  8. Christopher Williams 2020-02-07

    The updated node-titanium-sdk 4.3.1 with the fix is in master. Anecdotally, the ti.map PR that was previously failing with this issue now builds/passes: https://github.com/appcelerator-modules/ti.map/pull/285
  9. Joshua Quick 2020-02-07

    [~hknoechel], there are 2 work-arounds you can do "now" if you can't wait. 1) Shutdown the emulator via the virtual power button like how you do it on a real device. That is, do not quit the emulator via the \[x\] button. When you "quit" the emulator, it will take a snapshot by default which it will quickboot from upon the next launch. 2) Disable the "Quick Boot" option in the emulator's conifg window. This will force it to do a cold boot every time.
  10. Samir Mohammed 2020-02-12

    Closing ticket, fix verified in SDK version 9.0.0.v20200211122336. Test and other information can be found at: https://github.com/appcelerator/node-titanium-sdk/pull/140

JSON Source