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.35.0] "io.grpc.StatusRuntimeException: UNKNOWN" Failed to take screenshot on android flow failure #1647

Open
DavidREntwistle opened this issue Jan 9, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@DavidREntwistle
Copy link

DavidREntwistle commented Jan 9, 2024

Describe the bug
When a failure occurs on android, an UNKNOWN exception is thrown when a screenshot is attempted to be taken.

[INFO ] maestro.utils.ScreenshotUtils - Taking screenshot to byte array
[INFO ] maestro.utils.ScreenshotUtils - Taking screenshot to output sink
[WARN ] maestro.utils.ScreenshotUtils - Failed to take screenshot
io.grpc.StatusRuntimeException: UNKNOWN
	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.screenshot(MaestroDriverGrpc.java:648)
	at maestro.drivers.AndroidDriver$takeScreenshot$1.invoke(AndroidDriver.kt:436)
	at maestro.drivers.AndroidDriver$takeScreenshot$1.invoke(AndroidDriver.kt:435)
	at maestro.drivers.AndroidDriver.runDeviceCall(AndroidDriver.kt:989)
	at maestro.drivers.AndroidDriver.takeScreenshot(AndroidDriver.kt:435)
	at maestro.utils.ScreenshotUtils$Companion.takeScreenshot(ScreenshotUtils.kt:19)
	at maestro.utils.ScreenshotUtils$Companion.takeScreenshot(ScreenshotUtils.kt:26)
	at maestro.utils.ScreenshotUtils$Companion.tryTakingScreenshot(ScreenshotUtils.kt:32)
	at maestro.Maestro.hierarchyBasedTap-hbl3e4M(Maestro.kt:329)
	at maestro.Maestro.performTap-hbl3e4M(Maestro.kt:275)
	at maestro.Maestro.tap-BUbHBYE(Maestro.kt:189)
	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:54)
	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)

To Reproduce
Fail a flow on android, observe Maestro log.

Expected behavior
When a flow fails, a screenshot is taken and saved within the debug output test folder.

Environment information (please complete the following information):

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

Additional context
Add any other context about the problem here.

@DavidREntwistle DavidREntwistle added the bug Something isn't working label Jan 9, 2024
@DavidREntwistle DavidREntwistle changed the title [v1.35.0] Failed to take screenshot when flow fails [v1.35.0] Failed to take screenshot when flow fails on android Jan 9, 2024
@DavidREntwistle DavidREntwistle changed the title [v1.35.0] Failed to take screenshot when flow fails on android [v1.35.0] "io.grpc.StatusRuntimeException: UNKNOWN" Failed to take screenshot on android flow failure Jan 22, 2024
@DavidREntwistle
Copy link
Author

I believe this is related/causes these issues I've also raised:

I think this issue could be caused by the grpc server (that Maestro starts up inside the emulator vm) not running (when it should). Then the dadb (adb wrapper) fails because there is no network to run the commands on. Found this issue raised for grpc, but more shots in the dark grpc/grpc-java#10120

@DavidREntwistle
Copy link
Author

DavidREntwistle commented Jan 22, 2024

I think what happens before this issue is thrown:

  1. An android alert displays "System UI isn't responding" & also a secondary alert "Process system isn't responding".
  2. Running the flow then throws the "io.grpc.StatusRuntimeException: UNKNOWN" error raised above.
  3. Closing these two android alerts displayed & re-running the flow then runs the flow without error.

@DavidREntwistle
Copy link
Author

Noticing this device error on logcat at the same time:

FastPrintWriter
system_server
W  Write failure
java.io.IOException: write failed: EPIPE (Broken pipe)
    at libcore.io.IoBridge.write(IoBridge.java:651)
    at java.io.FileOutputStream.write(FileOutputStream.java:401)
    at com.android.internal.util.FastPrintWriter.flushBytesLocked(FastPrintWriter.java:354)
    at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:377)
    at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:322)
    at com.android.internal.util.FastPrintWriter.print(FastPrintWriter.java:499)
    at java.io.PrintWriter.println(PrintWriter.java:822)
    at android.util.PrintWriterPrinter.println(PrintWriterPrinter.java:38)
    at android.content.IntentFilter.dump(IntentFilter.java:2217)
    at com.android.server.IntentResolver.dumpMap(IntentResolver.java:324)
    at com.android.server.IntentResolver.dump(IntentResolver.java:374)
    at com.android.server.pm.resolution.ComponentResolverBase.dumpActivityResolvers(ComponentResolverBase.java:319)
    at com.android.server.pm.DumpHelper.doDump(DumpHelper.java:406)
    at com.android.server.pm.PackageManagerService$IPackageManagerImpl.dump(PackageManagerService.java:6001)
    at android.os.Binder.doDump(Binder.java:985)
    at android.os.Binder.dump(Binder.java:975)
    at android.os.Binder.onTransact(Binder.java:856)
    at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4313)
    at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:5948)
    at android.os.Binder.execTransactInternal(Binder.java:1285)
    at android.os.Binder.execTransact(Binder.java:1244)
Caused by: android.system.ErrnoException: write failed: EPIPE (Broken pipe)
    at libcore.io.Linux.writeBytes(Native Method)
    at libcore.io.Linux.write(Linux.java:296)
    at libcore.io.ForwardingOs.write(ForwardingOs.java:943)
    at libcore.io.BlockGuardOs.write(BlockGuardOs.java:448)
    at libcore.io.IoBridge.write(IoBridge.java:646)
    at java.io.FileOutputStream.write(FileOutputStream.java:401) 
    at com.android.internal.util.FastPrintWriter.flushBytesLocked(FastPrintWriter.java:354) 
    at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:377) 
    at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:322) 
    at com.android.internal.util.FastPrintWriter.print(FastPrintWriter.java:499) 
    at java.io.PrintWriter.println(PrintWriter.java:822) 
    at android.util.PrintWriterPrinter.println(PrintWriterPrinter.java:38) 
    at android.content.IntentFilter.dump(IntentFilter.java:2217) 
    at com.android.server.IntentResolver.dumpMap(IntentResolver.java:324) 
    at com.android.server.IntentResolver.dump(IntentResolver.java:374) 
    at com.android.server.pm.resolution.ComponentResolverBase.dumpActivityResolvers(ComponentResolverBase.java:319) 
    at com.android.server.pm.DumpHelper.doDump(DumpHelper.java:406) 
    at com.android.server.pm.PackageManagerService$IPackageManagerImpl.dump(PackageManagerService.java:6001) 
    at android.os.Binder.doDump(Binder.java:985) 
    at android.os.Binder.dump(Binder.java:975) 
    at android.os.Binder.onTransact(Binder.java:856) 
    at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4313) 
    at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:5948) 
    at android.os.Binder.execTransactInternal(Binder.java:1285) 
    at android.os.Binder.execTransact(Binder.java:1244) 

@DavidREntwistle
Copy link
Author

Also this:

SerializingExecutor
dev.mobile.maestro
E
Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@94b09ed
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
    at dev.mobile.maestro.Service.screenshot(MaestroDriverService.kt:299)
    at maestro_android.MaestroDriverGrpc$MethodHandlers.invoke(MaestroDriverGrpc.java:809)
    at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
    at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:355)
    at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:867)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)

@DavidREntwistle
Copy link
Author

DavidREntwistle commented Jan 22, 2024

Potentially some more breadcrumbs:

Also this:

SerializingExecutor
dev.mobile.maestro
E
Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@94b09ed
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
    at dev.mobile.maestro.Service.screenshot(MaestroDriverService.kt:299)
    at maestro_android.MaestroDriverGrpc$MethodHandlers.invoke(MaestroDriverGrpc.java:809)
    at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
    at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:355)
    at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:867)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)

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

1 participant