Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.33.1] Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found/device offline #1525

Open
DavidREntwistle opened this issue Oct 13, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@DavidREntwistle
Copy link

DavidREntwistle commented Oct 13, 2023

Describe the bug
Whilst running our android test folder containing 70~ flows taking around 40mins on CI, the below Exception in thread "pool-4-thread-1" occurs. This then causes an execution timeout, stopping the build on agent.

  Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found
    at dadb.adbserver.AdbServer.send$dadb(AdbServer.kt:99)
    at dadb.adbserver.AdbServerDadb.open(AdbServer.kt:137)
    at dadb.forwarding.TcpForwarder.handleForwarding$lambda-1(TcpForwarder.kt:64)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

To Reproduce

  1. Running the emulator headless on CI
  2. Run a test folder containing a large number of flows
  3. The Flow fails around the 40 min mark because of the Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found

Expected behaviour
The adb server to continue running after lengthy execution times.

Environment information:

  • Maestro version [v1.33.1]
  • Platform: [Android 13]
  • Framework: [Native Android]
  • Emulator - headless
  • Host [AWS linux-x86_64]
@DavidREntwistle
Copy link
Author

Update:

The error now appears to display as:

[Passed] test_flow29 (14s)
[Failed] test_flow30 (1m 29s) (Android driver unreachable)
[Failed] test_flow31 (41s) (Android driver unreachable)
Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device offline
   at dadb.adbserver.AdbServer.send$dadb(AdbServer.kt:99)
   at dadb.adbserver.AdbServerDadb.open(AdbServer.kt:137)
   at dadb.forwarding.TcpForwarder.handleForwarding$lambda-1(TcpForwarder.kt:64)
   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
   at java.base/java.lang.Thread.run(Thread.java:833)
[Failed] test_flow32 (1m 20s) (Android driver unreachable)
[Failed] test_flow33 (1m 20s) (Android driver unreachable)

It appears that now in v1.34.0 after this issue occurs, the flows continue to run with the "Android driver unreachable" message as the reason (this I feel is better).

I can't think of any reason why the device would go offline mid-execution.

Possibly the related to the issue what I've raised here #1570

@sanyar123
Copy link

Hi @DavidREntwistle, I am also facing the same issue. Did you find any workaround for this issue?

@DavidREntwistle
Copy link
Author

DavidREntwistle commented Jan 4, 2024

Hi @DavidREntwistle, I am also facing the same issue. Did you find any workaround for this issue?

@sanyar123 Sadly not yet.

I did add some logging and handling at the start of the flows to check if an ANR/Crash occurred in my test app on the previous flow. But this doesn't seem to be the cause of the issue.

@DavidREntwistle
Copy link
Author

DavidREntwistle commented Jan 12, 2024

I have been able to simulate this issue consistently, here are some steps to reproduce:

  1. Run a flows folder containing any valid flow (for example purposes).
  2. Allow the 1st flow to pass (for example purposes).
  3. Run adb reconnect device whilst the second flow is running.
  4. Observe the below failure in terminal:
Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found
        at dadb.adbserver.AdbServer.send$dadb(AdbServer.kt:99)                                
        at dadb.adbserver.AdbServerDadb.open(AdbServer.kt:137)                                
        at dadb.forwarding.TcpForwarder.handleForwarding$lambda-1(TcpForwarder.kt:64)         
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)    
  1. Observe the 2nd flow fail after 2 minutes with Android driver unreachable.
  2. Run adb reconnect device after the second flow fails with Android driver unreachable.
  3. Observe then the 3rd & 4th flow each fail after 2 minutes with Android driver unreachable.
  4. Observe then the 5th flow run and pass with no error.

See the error in the mastro test log:

[ERROR] maestro.cli.runner.TestRunner - Failed to run flow
io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
	at maestro_android.MaestroDriverGrpc$MaestroDriverBlockingStub.deviceInfo(MaestroDriverGrpc.java:634)
	at maestro.drivers.AndroidDriver$deviceInfo$1.invoke(AndroidDriver.kt:170)
	at maestro.drivers.AndroidDriver$deviceInfo$1.invoke(AndroidDriver.kt:169)
	at maestro.drivers.AndroidDriver.runDeviceCall(AndroidDriver.kt:989)
	at maestro.drivers.AndroidDriver.deviceInfo(AndroidDriver.kt:169)
	at maestro.ViewHierarchy$Companion.from-8JJjmZI(ViewHierarchy.kt:28)
	at maestro.Maestro.viewHierarchy-c1iYVAs(Maestro.kt:416)
	at maestro.Maestro.viewHierarchy-c1iYVAs$default(Maestro.kt:415)
	at maestro.Maestro$findElementWithTimeout$element$1.invoke(Maestro.kt:445)
	at maestro.Maestro$findElementWithTimeout$element$1.invoke(Maestro.kt:444)
	at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16)
	at maestro.Maestro.findElementWithTimeout-AE3g2Tc(Maestro.kt:444)
	at maestro.Maestro.findElementWithTimeout-AE3g2Tc$default(Maestro.kt:438)
	at maestro.orchestra.Orchestra.findElement(Orchestra.kt:863)
	at maestro.orchestra.Orchestra.access$findElement(Orchestra.kt:44)
	at maestro.orchestra.Orchestra$evaluateCondition$3$result$1.invoke(Orchestra.kt:521)
	at maestro.orchestra.Orchestra$evaluateCondition$3$result$1.invoke(Orchestra.kt:519)
	at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16)
	at maestro.orchestra.Orchestra.evaluateCondition(Orchestra.kt:519)
	at maestro.orchestra.Orchestra.evaluateCondition$default(Orchestra.kt:496)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:489)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:268)
	at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:201)
	at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:103)
	at maestro.orchestra.Orchestra.runFlow$default(Orchestra.kt:75)
	at maestro.cli.runner.MaestroCommandRunner.runCommands(MaestroCommandRunner.kt:185)
	at maestro.cli.runner.TestRunner$runSingle$result$1.invoke(TestRunner.kt:54)
	at maestro.cli.runner.TestRunner$runSingle$result$1.invoke(TestRunner.kt:51)
	at maestro.cli.runner.TestRunner.runCatching(TestRunner.kt:145)
	at maestro.cli.runner.TestRunner.runSingle(TestRunner.kt:51)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:177)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:136)
	at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:101)
	at maestro.cli.session.MaestroSessionManager.newSession$default(MaestroSessionManager.kt:58)
	at maestro.cli.command.TestCommand.call(TestCommand.kt:136)
	at maestro.cli.command.TestCommand.call(TestCommand.kt:46)
	at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
	at picocli.CommandLine.access$1200(CommandLine.java:145)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
	at maestro.cli.DisableAnsiMixin$Companion.executionStrategy(DisableAnsiMixin.kt:22)
	at picocli.CommandLine.execute(CommandLine.java:2058)
	at maestro.cli.AppKt.main(App.kt:117)

@DavidREntwistle
Copy link
Author

@sanyar123 are you able to reproduce this issue with these steps above?

@sanyar123
Copy link

@DavidREntwistle I haven't replicated the same steps but I am getting the same error that you have shared

@simon-gilmurray
Copy link

simon-gilmurray commented Jan 16, 2024

@axelniklasson Also hitting this issue on v1.35.0

Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device offline
	at dadb.adbserver.AdbServer.send$dadb(AdbServer.kt:99)
	at dadb.adbserver.AdbServerDadb.open(AdbServer.kt:137)
	at dadb.forwarding.TcpForwarder.handleForwarding$lambda-1(TcpForwarder.kt:64)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

@DavidREntwistle DavidREntwistle changed the title [v1.33.1] Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found - running flow folder in CI [v1.33.1] Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found Jan 16, 2024
@yuseiatlas
Copy link

A temporary fix that worked for me on #1573 (comment). TL;DR: I set the emulator API level to 32.

@DavidREntwistle DavidREntwistle changed the title [v1.33.1] Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found [v1.33.1] Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device 'emulator-5554' not found/device offline Jan 22, 2024
@DavidREntwistle
Copy link
Author

I found the Exception in thread "pool-4-thread-1" java.io.IOException: Command failed (host:transport:emulator-5554): device offline was being caused by our CI build timing out because of the length of execution. But I also think emulator crashes could still be a factor.

@DavidREntwistle
Copy link
Author

As of 15th July 2024, this remains an issue.

@DavidREntwistle
Copy link
Author

I believe this PR could resolve this issue.

@KeunwooPark
Copy link

KeunwooPark commented Sep 22, 2024

Still seeing this error with Android API 31 on 22nd Sep 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants