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.34.0] Android driver unreachable whilst running flow #1570

Open
DavidREntwistle opened this issue Nov 2, 2023 · 27 comments
Open

[v1.34.0] Android driver unreachable whilst running flow #1570

DavidREntwistle opened this issue Nov 2, 2023 · 27 comments
Labels
bug Something isn't working

Comments

@DavidREntwistle
Copy link

DavidREntwistle commented Nov 2, 2023

Describe the bug
Whilst running a flow that previously passed, the following error occurred:

[ERROR] maestro.drivers.AndroidDriver - Failed to get view hierarchy: Attempt to invoke virtual method 'java.lang.CharSequence android.view.accessibility.AccessibilityNodeInfo.getContentDescription()' on a null object reference
io.grpc.StatusRuntimeException: INTERNAL: Attempt to invoke virtual method 'java.lang.CharSequence android.view.accessibility.AccessibilityNodeInfo.getContentDescription()' on a null object reference
	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.viewHierarchy(MaestroDriverGrpc.java:641)
	at maestro.drivers.AndroidDriver.callViewHierarchy(AndroidDriver.kt:260)
	at maestro.drivers.AndroidDriver.callViewHierarchy$default(AndroidDriver.kt:258)
	at maestro.drivers.AndroidDriver.contentDescriptor(AndroidDriver.kt:249)
	at maestro.ViewHierarchy$Companion.from-c1iYVAs(ViewHierarchy.kt:29)
	at maestro.utils.ScreenshotUtils$Companion.viewHierarchy-c1iYVAs(ScreenshotUtils.kt:99)
	at maestro.utils.ScreenshotUtils$Companion.waitForAppToSettle-OpTFbEc(ScreenshotUtils.kt:58)
	at maestro.drivers.AndroidDriver.waitForAppToSettle-5RpGHs4(AndroidDriver.kt:552)
	at maestro.Maestro.waitForAppToSettle-5RpGHs4(Maestro.kt:457)
	at maestro.Maestro.waitForAppToSettle-5RpGHs4$default(Maestro.kt:452)
	at maestro.Maestro.hierarchyBasedTap-hbl3e4M(Maestro.kt:343)
	at maestro.Maestro.performTap-hbl3e4M(Maestro.kt:271)
	at maestro.Maestro.tap-BUbHBYE(Maestro.kt:185)
	at maestro.orchestra.Orchestra.tapOnElement(Orchestra.kt:753)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:239)
	at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:201)
	at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:111)
	at maestro.orchestra.Orchestra.runFlow$default(Orchestra.kt:75)
	at maestro.cli.runner.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:210)
	at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:69)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:152)
	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)

UPDATE 27th November 2023:
See post here.

To Reproduce
Unable to reproduce at this moment.

Expected behavior
To not fail getting the view hierarchy.

Screenshots
Screenshot 2023-11-02 at 18 52 13

Environment information
Maestro version [v1.34.0]
Platform: [Android 13.0]
Framework: [Native Android]
Device model and OS version: [Pixel]
Emulator device
Host [Apple MacBook Pro M2 Max]

Additional context
This was not an issue on v1.33.1 for Android.
iOS v1.33.1 & v1.34.0 is not an issue.

@DavidREntwistle DavidREntwistle added the bug Something isn't working label Nov 2, 2023
@axelniklasson
Copy link
Collaborator

@DavidREntwistle does this happen consistently or every now and then for you? What if you try different emulators / device models?

@DavidREntwistle
Copy link
Author

@axelniklasson it seems inconsistent across devices whilst running locally. But it looks to be consistently occurring when running on CI.

[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)

This looks related to this issue I raised here: #1525

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.

@axelniklasson
Copy link
Collaborator

Got it -- thanks for that context @DavidREntwistle. I would recommend running a separate process on your CI box that checks whether the device you're working with is online or not during the execution to rule out any environment specific issues. If it turns out that the device is online and functioning it does point towards a maestro issue, so let us know if that is the case. Thanks!

@DavidREntwistle
Copy link
Author

Thank you @axelniklasson I'll take a look at that from our side and feedback.

@saihemanth121
Copy link

saihemanth121 commented Nov 21, 2023

@axelniklasson I'm also facing the same issue after upgrading to Maestro 1.34.1. I've checked that emulator is running and responsive, yet maestro throws a "device offline" error and then all tests start failing with "Android driver unreachable".

I also checked maestro.log and found this:

[ERROR] maestro.drivers.AndroidDriver - Failed to get view hierarchy: Network closed for unknown reason
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.viewHierarchy(MaestroDriverGrpc.java:641)
	at maestro.drivers.AndroidDriver.callViewHierarchy(AndroidDriver.kt:260)
	at maestro.drivers.AndroidDriver.callViewHierarchy$default(AndroidDriver.kt:258)
	at maestro.drivers.AndroidDriver.contentDescriptor(AndroidDriver.kt:249)
	at maestro.ViewHierarchy$Companion.from-c1iYVAs(ViewHierarchy.kt:29)
	at maestro.Maestro.viewHierarchy-prqvCes(Maestro.kt:412)
	at maestro.Maestro$findElementWithTimeout$element$1.invoke(Maestro.kt:437)
	at maestro.Maestro$findElementWithTimeout$element$1.invoke(Maestro.kt:436)
	at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16)
	at maestro.Maestro.findElementWithTimeout(Maestro.kt:436)
	at maestro.orchestra.Orchestra.findElement(Orchestra.kt:849)
	at maestro.orchestra.Orchestra.evaluateCondition(Orchestra.kt:512)
	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.executeSubflowCommands(Orchestra.kt:581)
	at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:622)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:490)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:268)
	at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:201)
	at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:111)
	at maestro.orchestra.Orchestra.runFlow$default(Orchestra.kt:75)
	at maestro.cli.runner.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:210)
	at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:69)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:152)
	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

DavidREntwistle commented Nov 27, 2023

I've experienced the Android driver unreachable issue again whilst running the full flow suite of 69 flows.
Both the Android device & the app remained responsive during this time and didn't crash/close.

Looking into the maestro.log file, when a similar view hierarchy error occurs the following maestro command fails:

[ERROR] maestro.drivers.AndroidDriver - Timeout while fetching view hierarchy
[INFO ] m.cli.runner.TestSuiteInteractor - Tap on "${ACCOUNT}", id: ${output.home.switch.account} FAILED

Though the above "ERROR" was a maestro.drivers.AndroidDriver - Timeout while fetching view hierarchy not the first reported maestro.drivers.AndroidDriver - Failed to get view hierarchy.

Had a check within the commands json file for the flow when the error occurred, here is the below stack trace for the Android driver unreachable error:

{"command":{"tapOnElement":{"selector":{"textRegex":"${ACCOUNT}","idRegex":"${output.home.switch.account}","optional":false},"retryIfNoChange":false,"waitUntilVisible":false,"longPress":false}},"metadata":{"status":"FAILED","timestamp":1701082911160,"duration":41455,"error":

{"stackTrace":[{"classLoaderName":"app","methodName":"callViewHierarchy","fileName":"AndroidDriver.kt","lineNumber":265,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"callViewHierarchy$default","fileName":"AndroidDriver.kt","lineNumber":258,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"contentDescriptor","fileName":"AndroidDriver.kt","lineNumber":249,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"from-c1iYVAs","fileName":"ViewHierarchy.kt","lineNumber":29,"nativeMethod":false,"className":"maestro.ViewHierarchy$Companion"},
{"classLoaderName":"app","methodName":"viewHierarchy-c1iYVAs","fileName":"ScreenshotUtils.kt","lineNumber":99,"nativeMethod":false,"className":"maestro.utils.ScreenshotUtils$Companion"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-OpTFbEc","fileName":"ScreenshotUtils.kt","lineNumber":58,"nativeMethod":false,"className":"maestro.utils.ScreenshotUtils$Companion"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-5RpGHs4","fileName":"AndroidDriver.kt","lineNumber":552,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-5RpGHs4","fileName":"Maestro.kt","lineNumber":457,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-5RpGHs4$default","fileName":"Maestro.kt","lineNumber":452,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"hierarchyBasedTap-hbl3e4M","fileName":"Maestro.kt","lineNumber":343,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"performTap-hbl3e4M","fileName":"Maestro.kt","lineNumber":271,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"tap-BUbHBYE","fileName":"Maestro.kt","lineNumber":185,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"tapOnElement","fileName":"Orchestra.kt","lineNumber":753,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeCommand","fileName":"Orchestra.kt","lineNumber":239,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeSubflowCommands","fileName":"Orchestra.kt","lineNumber":581,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runSubFlow","fileName":"Orchestra.kt","lineNumber":622,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlowCommand","fileName":"Orchestra.kt","lineNumber":490,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeCommand","fileName":"Orchestra.kt","lineNumber":268,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeCommands","fileName":"Orchestra.kt","lineNumber":201,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlow","fileName":"Orchestra.kt","lineNumber":103,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlow$default","fileName":"Orchestra.kt","lineNumber":75,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlow","fileName":"TestSuiteInteractor.kt","lineNumber":210,"nativeMethod":false,"className":"maestro.cli.runner.TestSuiteInteractor"},
{"classLoaderName":"app","methodName":"runTestSuite","fileName":"TestSuiteInteractor.kt","lineNumber":54,"nativeMethod":false,"className":"maestro.cli.runner.TestSuiteInteractor"},
{"classLoaderName":"app","methodName":"invoke","fileName":"TestCommand.kt","lineNumber":152,"nativeMethod":false,"className":"maestro.cli.command.TestCommand$call$1"},
{"classLoaderName":"app","methodName":"invoke","fileName":"TestCommand.kt","lineNumber":136,"nativeMethod":false,"className":"maestro.cli.command.TestCommand$call$1"},
{"classLoaderName":"app","methodName":"newSession","fileName":"MaestroSessionManager.kt","lineNumber":101,"nativeMethod":false,"className":"maestro.cli.session.MaestroSessionManager"},
{"classLoaderName":"app","methodName":"newSession$default","fileName":"MaestroSessionManager.kt","lineNumber":58,"nativeMethod":false,"className":"maestro.cli.session.MaestroSessionManager"},
{"classLoaderName":"app","methodName":"call","fileName":"TestCommand.kt","lineNumber":136,"nativeMethod":false,"className":"maestro.cli.command.TestCommand"},
{"classLoaderName":"app","methodName":"call","fileName":"TestCommand.kt","lineNumber":46,"nativeMethod":false,"className":"maestro.cli.command.TestCommand"},
{"classLoaderName":"app","methodName":"executeUserObject","fileName":"CommandLine.java","lineNumber":1933,"nativeMethod":false,"className":"picocli.CommandLine"},
{"classLoaderName":"app","methodName":"access$1200","fileName":"CommandLine.java","lineNumber":145,"nativeMethod":false,"className":"picocli.CommandLine"},
{"classLoaderName":"app","methodName":"executeUserObjectOfLastSubcommandWithSameParent","fileName":"CommandLine.java","lineNumber":2332,"nativeMethod":false,"className":"picocli.CommandLine$RunLast"},
{"classLoaderName":"app","methodName":"handle","fileName":"CommandLine.java","lineNumber":2326,"nativeMethod":false,"className":"picocli.CommandLine$RunLast"},
{"classLoaderName":"app","methodName":"handle","fileName":"CommandLine.java","lineNumber":2291,"nativeMethod":false,"className":"picocli.CommandLine$RunLast"},
{"classLoaderName":"app","methodName":"execute","fileName":"CommandLine.java","lineNumber":2159,"nativeMethod":false,"className":"picocli.CommandLine$AbstractParseResultHandler"},
{"classLoaderName":"app","methodName":"executionStrategy","fileName":"DisableAnsiMixin.kt","lineNumber":22,"nativeMethod":false,"className":"maestro.cli.DisableAnsiMixin$Companion"},
{"classLoaderName":"app","methodName":"execute","fileName":"CommandLine.java","lineNumber":2058,"nativeMethod":false,"className":"picocli.CommandLine"},
{"classLoaderName":"app","methodName":"main","fileName":"App.kt","lineNumber":117,"nativeMethod":false,"className":"maestro.cli.AppKt"}],
"message":"Android driver unreachable","localizedMessage":"Android driver unreachable"}}},

Followed by another Android driver unreachable error:

{"assertConditionCommand":{"condition":{"visible":{"idRegex":"${output.tabBar.home}","optional":false}}}}],"sourceDescription":"../accountSwitch.yaml","config":{"appId":"com.test.android.demo"}}},"metadata":{"status":"FAILED","timestamp":1701082898057,"duration":86235,"error":
    
{"stackTrace":[{"classLoaderName":"app","methodName":"callViewHierarchy","fileName":"AndroidDriver.kt","lineNumber":265,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"callViewHierarchy$default","fileName":"AndroidDriver.kt","lineNumber":258,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"contentDescriptor","fileName":"AndroidDriver.kt","lineNumber":249,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"from-c1iYVAs","fileName":"ViewHierarchy.kt","lineNumber":29,"nativeMethod":false,"className":"maestro.ViewHierarchy$Companion"},
{"classLoaderName":"app","methodName":"viewHierarchy-c1iYVAs","fileName":"ScreenshotUtils.kt","lineNumber":99,"nativeMethod":false,"className":"maestro.utils.ScreenshotUtils$Companion"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-OpTFbEc","fileName":"ScreenshotUtils.kt","lineNumber":58,"nativeMethod":false,"className":"maestro.utils.ScreenshotUtils$Companion"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-5RpGHs4","fileName":"AndroidDriver.kt","lineNumber":552,"nativeMethod":false,"className":"maestro.drivers.AndroidDriver"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-5RpGHs4","fileName":"Maestro.kt","lineNumber":457,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"waitForAppToSettle-5RpGHs4$default","fileName":"Maestro.kt","lineNumber":452,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"hierarchyBasedTap-hbl3e4M","fileName":"Maestro.kt","lineNumber":343,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"performTap-hbl3e4M","fileName":"Maestro.kt","lineNumber":271,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"tap-BUbHBYE","fileName":"Maestro.kt","lineNumber":185,"nativeMethod":false,"className":"maestro.Maestro"},
{"classLoaderName":"app","methodName":"tapOnElement","fileName":"Orchestra.kt","lineNumber":753,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeCommand","fileName":"Orchestra.kt","lineNumber":239,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeSubflowCommands","fileName":"Orchestra.kt","lineNumber":581,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runSubFlow","fileName":"Orchestra.kt","lineNumber":622,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlowCommand","fileName":"Orchestra.kt","lineNumber":490,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeCommand","fileName":"Orchestra.kt","lineNumber":268,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"executeCommands","fileName":"Orchestra.kt","lineNumber":201,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlow","fileName":"Orchestra.kt","lineNumber":103,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlow$default","fileName":"Orchestra.kt","lineNumber":75,"nativeMethod":false,"className":"maestro.orchestra.Orchestra"},
{"classLoaderName":"app","methodName":"runFlow","fileName":"TestSuiteInteractor.kt","lineNumber":210,"nativeMethod":false,"className":"maestro.cli.runner.TestSuiteInteractor"},
{"classLoaderName":"app","methodName":"runTestSuite","fileName":"TestSuiteInteractor.kt","lineNumber":54,"nativeMethod":false,"className":"maestro.cli.runner.TestSuiteInteractor"},
{"classLoaderName":"app","methodName":"invoke","fileName":"TestCommand.kt","lineNumber":152,"nativeMethod":false,"className":"maestro.cli.command.TestCommand$call$1"},
{"classLoaderName":"app","methodName":"invoke","fileName":"TestCommand.kt","lineNumber":136,"nativeMethod":false,"className":"maestro.cli.command.TestCommand$call$1"},
{"classLoaderName":"app","methodName":"newSession","fileName":"MaestroSessionManager.kt","lineNumber":101,"nativeMethod":false,"className":"maestro.cli.session.MaestroSessionManager"},
{"classLoaderName":"app","methodName":"newSession$default","fileName":"MaestroSessionManager.kt","lineNumber":58,"nativeMethod":false,"className":"maestro.cli.session.MaestroSessionManager"},
{"classLoaderName":"app","methodName":"call","fileName":"TestCommand.kt","lineNumber":136,"nativeMethod":false,"className":"maestro.cli.command.TestCommand"},
{"classLoaderName":"app","methodName":"call","fileName":"TestCommand.kt","lineNumber":46,"nativeMethod":false,"className":"maestro.cli.command.TestCommand"},
{"classLoaderName":"app","methodName":"executeUserObject","fileName":"CommandLine.java","lineNumber":1933,"nativeMethod":false,"className":"picocli.CommandLine"},
{"classLoaderName":"app","methodName":"access$1200","fileName":"CommandLine.java","lineNumber":145,"nativeMethod":false,"className":"picocli.CommandLine"},
{"classLoaderName":"app","methodName":"executeUserObjectOfLastSubcommandWithSameParent","fileName":"CommandLine.java","lineNumber":2332,"nativeMethod":false,"className":"picocli.CommandLine$RunLast"},
{"classLoaderName":"app","methodName":"handle","fileName":"CommandLine.java","lineNumber":2326,"nativeMethod":false,"className":"picocli.CommandLine$RunLast"},
{"classLoaderName":"app","methodName":"handle","fileName":"CommandLine.java","lineNumber":2291,"nativeMethod":false,"className":"picocli.CommandLine$RunLast"},
{"classLoaderName":"app","methodName":"execute","fileName":"CommandLine.java","lineNumber":2159,"nativeMethod":false,"className":"picocli.CommandLine$AbstractParseResultHandler"},
{"classLoaderName":"app","methodName":"executionStrategy","fileName":"DisableAnsiMixin.kt","lineNumber":22,"nativeMethod":false,"className":"maestro.cli.DisableAnsiMixin$Companion"},
{"classLoaderName":"app","methodName":"execute","fileName":"CommandLine.java","lineNumber":2058,"nativeMethod":false,"className":"picocli.CommandLine"},
{"classLoaderName":"app","methodName":"main","fileName":"App.kt","lineNumber":117,"nativeMethod":false,"className":"maestro.cli.AppKt"}],
    "message":"Android driver unreachable","localizedMessage":"Android driver unreachable"}}},

private fun callViewHierarchy(attempt: Int = 1): MaestroAndroid.ViewHierarchyResponse {

@arashgm
Copy link

arashgm commented Nov 27, 2023

i have the same issue when running it locally for one flow , but its happening time to time not always

@DavidREntwistle
Copy link
Author

Experiencing this issue on Maestro v1.35.0 also.

[ERROR] maestro.drivers.AndroidDriver - Failed to get view hierarchy: Network closed for unknown reason
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.viewHierarchy(MaestroDriverGrpc.java:641)
	at maestro.drivers.AndroidDriver.callViewHierarchy(AndroidDriver.kt:301)
	at maestro.drivers.AndroidDriver.callViewHierarchy$default(AndroidDriver.kt:299)
	at maestro.drivers.AndroidDriver.contentDescriptor(AndroidDriver.kt:265)
	at maestro.ViewHierarchy$Companion.from-8JJjmZI(ViewHierarchy.kt:29)
	at maestro.utils.ScreenshotUtils$Companion.viewHierarchy-c1iYVAs(ScreenshotUtils.kt:99)
	at maestro.utils.ScreenshotUtils$Companion.waitForAppToSettle-OpTFbEc(ScreenshotUtils.kt:60)
	at maestro.drivers.AndroidDriver.waitForAppToSettle-5RpGHs4(AndroidDriver.kt:605)
	at maestro.Maestro.waitForAppToSettle-5RpGHs4(Maestro.kt:468)
	at maestro.Maestro.waitForAppToSettle-5RpGHs4$default(Maestro.kt:463)
	at maestro.Maestro.inputText(Maestro.kt:475)
	at maestro.orchestra.Orchestra.inputTextCommand(Orchestra.kt:728)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:258)
	at maestro.orchestra.Orchestra.executeSubflowCommands(Orchestra.kt:581)
	at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:622)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:490)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:268)
	at maestro.orchestra.Orchestra.executeSubflowCommands(Orchestra.kt:581)
	at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:622)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:490)
	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.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:210)
	at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:69)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:152)
	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)
[ERROR] maestro.drivers.AndroidDriver - Timeout while fetching view hierarchy

@DavidREntwistle
Copy link
Author

DavidREntwistle commented Jan 12, 2024

I've been able to simulate this issue here and I have left steps to replicate:
#1525 (comment)

I'm wondering if this "Android driver unreachable whilst running flow" & the "Exception in thread "pool-4-thread-1"" issues I've raised could be related to something similar to this google issue raised.

If the device reconnects following the initial error, after 4 minutes the tests re-continue.
cc. @axelniklasson

@simon-gilmurray
Copy link

@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)

@jaychang0917
Copy link

Also encounter this issue on v1.35.0

@jsonITP
Copy link

jsonITP commented Feb 2, 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)

Got the exact same issue running our flows

@adithyaam
Copy link

We are also facing the same issue when running on a macbook as a Azure local agent, Did anyone solve this please advice,
Thankyou

@DavidREntwistle
Copy link
Author

@adithyaam I found one cause to be our ci agent timing out because of the long execution time/the timeout set to an hour when the flows took longer than an hour. Another reason was caused by the actual android emulator crashing, it seems some API versions are more stable than others.

@vibin
Copy link

vibin commented May 16, 2024

The AccessibilityNodeInfo.getContentDescription() NPE seems to be a bug in uiautomator that was fixed last year in 2.3.0-alpha04.

#1733 (not released yet) upgrades uiautomator to 2.3.0, so it should address this issue.

Wondering if there's a way to test snapshot builds of Maestro...

@asdolo
Copy link

asdolo commented Jun 28, 2024

@dmitry-zaitsev Should a new version be released now that #1733 has been merged?

@iqbalmineraltown
Copy link

I'm on 1.38.1 and facing this issue as well
using mac mini 2018, Sonoma 14.6

is there any confirmation if #1733 has already fixed this issue?

@robin-pham
Copy link

robin-pham commented Sep 4, 2024

Based off the merge commit, the 'fix' has been in there since 1.37.0.

We've been experiencing this issue as well but on 1.36.0. Was interested in upgrading but if this issue still occurs for you on 1.38.1, doesn't bode well for us :'(

@robin-pham
Copy link

@iqbalmineraltown can you check if when you're running into it, there's a AccessibilityNodeInfo.getContentDescription in the logs?

@iqbalmineraltown
Copy link

@robin-pham there is. Any idea ?

[INFO ] maestro.utils.ScreenshotUtils - Taking screenshot to output sink
[ERROR] maestro.drivers.AndroidDriver - Failed to get view hierarchy: Attempt to invoke virtual method 'java.lang.CharSequence android.view.accessibility.AccessibilityNodeInfo.getContentDescription()' on a null object reference
io.grpc.StatusRuntimeException: INTERNAL: Attempt to invoke virtual method 'java.lang.CharSequence android.view.accessibility.AccessibilityNodeInfo.getContentDescription()' on a null object reference
	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.viewHierarchy(MaestroDriverGrpc.java:641)
	at maestro.drivers.AndroidDriver.callViewHierarchy(AndroidDriver.kt:329)
	at maestro.drivers.AndroidDriver.callViewHierarchy$default(AndroidDriver.kt:327)
	at maestro.drivers.AndroidDriver.contentDescriptor(AndroidDriver.kt:293)
	at maestro.ViewHierarchy$Companion.from-8JJjmZI(ViewHierarchy.kt:29)
	at maestro.utils.ScreenshotUtils$Companion.viewHierarchy-c1iYVAs(ScreenshotUtils.kt:99)
	at maestro.utils.ScreenshotUtils$Companion.waitForAppToSettle-OpTFbEc(ScreenshotUtils.kt:58)
	at maestro.drivers.AndroidDriver.waitForAppToSettle-5RpGHs4(AndroidDriver.kt:634)
	at maestro.Maestro.waitForAppToSettle-5RpGHs4(Maestro.kt:477)
	at maestro.Maestro.waitForAppToSettle-5RpGHs4$default(Maestro.kt:472)
	at maestro.Maestro.hierarchyBasedTap-hbl3e4M(Maestro.kt:356)
	at maestro.Maestro.performTap-hbl3e4M(Maestro.kt:284)
	at maestro.Maestro.tap-BUbHBYE(Maestro.kt:198)
	at maestro.orchestra.Orchestra.tapOnElement(Orchestra.kt:845)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:243)
	at maestro.orchestra.Orchestra.executeSubflowCommands(Orchestra.kt:673)
	at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:714)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:582)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:275)
	at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:191)
	at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:127)
	at maestro.cli.runner.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:250)
	at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:82)
	at maestro.cli.command.TestCommand$handleSessions$1$1$results$1$1$1.invoke(TestCommand.kt:281)
	at maestro.cli.command.TestCommand$handleSessions$1$1$results$1$1$1.invoke(TestCommand.kt:258)
	at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:102)
	at maestro.cli.session.MaestroSessionManager.newSession$default(MaestroSessionManager.kt:54)
	at maestro.cli.command.TestCommand$handleSessions$1$1$results$1$1.invokeSuspend(TestCommand.kt:258)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
[INFO ] maestro.Maestro - Something have changed in the UI judging by view hierarchy. Proceed.

@iqbalmineraltown
Copy link

as mentioned on #1573 (comment)
it runs well on Android emulator API level 32, but not on other API level supported by maestro

@pntgoswami18
Copy link

Has this not been fixed yet?
Any workaround for this ?

@DavidREntwistle
Copy link
Author

Sadly this is still an issue and I haven't found a workaround @pntgoswami18

@mrtry
Copy link

mrtry commented Oct 21, 2024

I'm having the same problem.
I am also experiencing this with API Level 32. ref
I have confirmed that it doesn't work with latest, but will it work if I downgrade?

@DavidREntwistle
Copy link
Author

I have increased my android emulator memory to 4GB and this seems to help this issue, by default it was at 2GB. I'm thinking the emulator/maestro driver crashed due to low memory usage. 4GB (4096) + seems more stable / less android driver unreachable errors occur.

Headless 4GB Emulator E.g.
${ANDROID_HOME}/emulator/emulator -memory 4096 -avd emulatorDeviceNameHere -camera-front emulated -camera-back emulated -gpu swiftshader_indirect -no-window -verbose -no-audio -show-kernel -read-only -no-boot-anim

@robin-pham
Copy link

ty @DavidREntwistle, we bumped it to 8192 and it's been much more stable ever since!

@mrtry
Copy link

mrtry commented Oct 25, 2024

#1570 (comment)

It works, too! Thanks 🙏

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