Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Heuristics for waiting boot process to finish not working with -no-window #26

Open
SiimKinks opened this issue Jul 13, 2017 · 8 comments
Assignees

Comments

@SiimKinks
Copy link

When starting emulator with options -no-audio -no-window -gpu off TimeoutException will happen while waiting for boot process to finish.
Emulator is started in the background, but since init.svc.bootanim property is not set when starting emulator with provided options the script will result in timeout.

Executed command:

java -jar swarmer-0.2.0.jar start \
--emulator-name ANDROID_25_x86 \
--package "system-images;android-25;google_apis;x86" \
--android-abi x86 \
--path-to-config-ini config/android_25_x86_config.ini \
--emulator-start-options -no-audio -no-window -gpu off -prop persist.sys.language=en -prop persist.sys.country=US

Produced output:

[Thu Jul 13 17:07:59 EEST 2017]: Creating avd ANDROID_25_x86.
[Thu Jul 13 17:08:02 EEST 2017]: Avd ANDROID_25_x86 created in 2.346 seconds.
[Thu Jul 13 17:08:02 EEST 2017]: Ports for emulator ANDROID_25_x86: 5554, 5555.
[Thu Jul 13 17:08:02 EEST 2017]: Starting emulator ANDROID_25_x86.
[Thu Jul 13 17:08:15 EEST 2017]: Emulator Emulator(id=emulator-5554, name=ANDROID_25_x86) started in 13.048 seconds.
[Thu Jul 13 17:08:15 EEST 2017]: Waiting boot process to finish for emulator Emulator(id=emulator-5554, name=ANDROID_25_x86).
Timeout 180 seconds, failed to start emulator ANDROID_25_x86.
Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.TimeoutException
        at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
        at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:464)
        at rx.observables.BlockingObservable.firstOrDefault(BlockingObservable.java:196)
        at com.gojuno.swarmer.EmulatorsKt.startEmulators(Emulators.kt:49)
        at com.gojuno.swarmer.MainKt.main(Main.kt:7)
Caused by: java.util.concurrent.TimeoutException
        at rx.internal.operators.OperatorTimeoutBase$TimeoutSubscriber.onTimeout(OperatorTimeoutBase.java:177)
        at rx.internal.operators.OperatorTimeout$1$1.call(OperatorTimeout.java:41)
        at rx.internal.schedulers.EventLoopsScheduler$EventLoopWorker$2.call(EventLoopsScheduler.java:189)
        at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
@artem-zinnatullin
Copy link
Contributor

Hm, interesting.

Are you sure emulator actually started? Because we use pretty much same check as Travis CI's android-wait-for-emulator which actually works if you start emulator with -no-window (proof).

Maybe it's the -gpu off flag, but I believe Travis CI machines don't have GPU on them as well.

Emulator is started in the background

How did you check that? I would suggest adb -s deviceId shell and adb devices

@SiimKinks
Copy link
Author

How did you check that? I would suggest adb -s deviceId shell and adb devices

I ran adb devices - started emulator was in "device" state. Then checked what state the system property was with adb -e shell getprop init.svc.bootanim - it returned no values.
If I start emulator with no options the init.svc.bootanim prop has expected values.
(My test was carried out on a MacOS)

Have you tried to run the exact same input params on your own and it worked?

@yunikkk
Copy link
Contributor

yunikkk commented Jul 14, 2017

Hey,

just checked with the same settings - emulator works fully, running tests etc.
Are you able to adb shell to emulator loaded? Run tests/install apks?

PS what version of android emulator do you have?

@SiimKinks
Copy link
Author

I think you're misunderstanding the problem here. My initial issue was created for the problem that swarmer does not detect wether the emulator was started or not and ultimately ends up in TimeoutException.
The defined emulator is started successfully and everything works related to emulator actions (running tests, installing apks, accessing emulator from adb shell, etc). Problem stems from the desire to listen for the script to finish and execute some next actions when it successfully launched all emulators.
The init.svc.bootanim prop part was directed to pinpoint the exact location where this problem roots from.

Android emulator version is 26.1.2

@yunikkk
Copy link
Contributor

yunikkk commented Jul 14, 2017

The thing is - emulator is launched as intended on my machine, its loaded and reports bootanim successfully after 20 or 30 seconds, so the error should not be the swarmer itself but something in the environment. I tried the same emulator and swarmer versions, with the exact same options you provided (copypasted them all), so its really weird. Tested on Macos 10.12.5.

@SiimKinks
Copy link
Author

Can there be some error in my config.ini file?

avd.ini.encoding=UTF-8
AvdId=ANDROID_25_x86
PlayStore.enabled=false
abi.type=x86
avd.ini.displayname=ANDROID_25_x86
disk.dataPartition.size=800M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=emulated
hw.camera.front=emulated
hw.cpu.arch=x86
hw.cpu.ncore=4
hw.dPad=no
hw.device.hash2=MD5:bfb86a1a4ed5eee97e5502f607348e06
hw.device.manufacturer=Google
hw.device.name=pixel
hw.gps=yes
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.initialOrientation=Portrait
hw.keyboard=yes
hw.lcd.density=480
hw.lcd.height=1920
hw.lcd.width=1080
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images/android-25/google_apis/x86/
runtime.network.latency=none
runtime.network.speed=full
sdcard.size=100M
showDeviceFrame=yes
skin.dynamic=yes
skin.name=pixel
skin.path=/Users/siim/android/skins/pixel
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=256

@yunikkk
Copy link
Contributor

yunikkk commented Jul 14, 2017

Well, if I change skin options in the config to

skin.dynamic=yes
skin.name=480x854
skin.path=_no_skin

everything is working. Otherwise my emulator isn't even able to start. Tried different skins from $ANDROID_HOME/skins with no success...

@yunikkk
Copy link
Contributor

yunikkk commented Jul 14, 2017

And using the following format

skin.name=pixel
skin.path=skins/pixel

pixel skin succeeded to start, too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants