gojuno / swarmer

Reactive tool to create and start multiple Android Emulators in parallel.
Apache License 2.0
203 stars 17 forks source link

Timeout error while staring a lot of new emulators simultaneously #28

Closed Kpeved closed 7 years ago

Kpeved commented 7 years ago

I'm starting 5 new emulators with this script

IFS=', ' read -r -a arr <<< "%screenshots_emulators%"

scriptString=" "
for ((i=0; i<${#arr[@]}; i++)); do
    scriptString="$scriptString --emulator-name test_emulator_$i "
    scriptString="$scriptString --package \"system-images;android-26;google_apis;x86\" "
    scriptString="$scriptString --android-abi google_apis/x86 "
    scriptString="$scriptString --path-to-config-ini %EMULATOR_CONFIGS_DIR%${arr[$i]} "
    scriptString="$scriptString --emulator-start-options -prop persist.sys.language=en -prop persist.sys.country=US "
    scriptString="$scriptString --redirect-logcat-to /tmp/test_emulator_$i_logcat.txt "
    echo "config: ${arr[$i]}"
done

echo $scriptString

java -jar /tmp/swarmer.jar start $scriptString

But I get only 3 or 4 emulators running, other 2 don't want to start. So I get TimeoutException

[17:10:01][Step 8/9] Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.TimeoutException
[17:10:01][Step 8/9]    at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
[17:10:01][Step 8/9]    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:464)
[17:10:01][Step 8/9]    at rx.observables.BlockingObservable.firstOrDefault(BlockingObservable.java:196)
[17:10:01][Step 8/9]    at com.gojuno.swarmer.EmulatorsKt.startEmulators(Emulators.kt:49)
[17:10:01][Step 8/9]    at com.gojuno.swarmer.MainKt.main(Main.kt:7)
[17:10:01][Step 8/9] Caused by: java.util.concurrent.TimeoutException
[17:10:01][Step 8/9]    at rx.internal.operators.OperatorTimeoutBase$TimeoutSubscriber.onTimeout(OperatorTimeoutBase.java:177)
[17:10:01][Step 8/9]    at rx.internal.operators.OperatorTimeout$1$1.call(OperatorTimeout.java:41)
[17:10:01][Step 8/9]    at rx.internal.schedulers.EventLoopsScheduler$EventLoopWorker$2.call(EventLoopsScheduler.java:189)
[17:10:01][Step 8/9]    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
[17:10:01][Step 8/9]    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[17:10:01][Step 8/9]    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[17:10:01][Step 8/9]    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[17:10:01][Step 8/9]    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[17:10:01][Step 8/9]    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[17:10:01][Step 8/9]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[17:10:01][Step 8/9]    at java.lang.Thread.run(Thread.java:745)

Is there some limitation on number of running emulators?

artem-zinnatullin commented 7 years ago

There are no limitations on number of emulators in Swarmer.

But your hardware may not be able to start that amount of emulators in parallel.

Please check htop/top output to see how much CPU and RAM you have left when you try to launch that amount of emulators, GPU also can be a bottleneck (we learned it hard way).

I would also recommend to carefully review emulator configs (reduce screen resolution, etc).