Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
958 stars 245 forks source link

Fix Patrol tests #296

Closed bartekpacia closed 1 year ago

bartekpacia commented 1 year ago

Description

This PR fixes #267

Checklist

Before creating any Pull Request, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).

Breaking Change

bartekpacia commented 1 year ago

photo_test.dart and video_test.dart pass. ui_test.dart crashes with a mysterious "Instrumentation crashed" when run with patrol test, but works when run with patrol develop.

I run adb logcat while ui_test.dart crashed and these logs look interesting:

Logs ``` 03-25 21:23:20.736 2892 2903 W System : A resource failed to call Surface.release. 03-25 21:23:20.742 2892 2892 D MonitoringInstr: Handling an uncaught exception thrown on the thread main. 03-25 21:23:20.742 2892 2892 D MonitoringInstr: java.lang.NullPointerException 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at com.apparence.camerawesome.cameraX.CameraAwesomeX$recordVideo$1.invokeSuspend(CameraAwesomeX.kt:418) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at android.os.Handler.handleCallback(Handler.java:942) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at android.os.Handler.dispatchMessage(Handler.java:99) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at android.os.Looper.loopOnce(Looper.java:201) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at android.os.Looper.loop(Looper.java:288) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at android.app.ActivityThread.main(ActivityThread.java:7872) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at java.lang.reflect.Method.invoke(Native Method) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 03-25 21:23:20.742 2892 2892 D MonitoringInstr: Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7392925, Dispatchers.Main] 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: An unhandled exception was thrown by the app. 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: java.lang.NullPointerException 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at com.apparence.camerawesome.cameraX.CameraAwesomeX$recordVideo$1.invokeSuspend(CameraAwesomeX.kt:418) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at android.os.Handler.handleCallback(Handler.java:942) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at android.os.Handler.dispatchMessage(Handler.java:99) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at android.os.Looper.loopOnce(Looper.java:201) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at android.os.Looper.loop(Looper.java:288) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at android.app.ActivityThread.main(ActivityThread.java:7872) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at java.lang.reflect.Method.invoke(Native Method) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 03-25 21:23:20.742 2892 2892 W AndroidJUnitRunner: Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7392925, Dispatchers.Main] 03-25 21:23:20.745 2892 2892 D AndroidJUnitRunner: Reporting the crash to an event service. 03-25 21:23:20.745 2892 2892 W TestEventClient: Process crashed before connection to orchestrator 03-25 21:23:20.745 2892 2892 I AndroidJUnitRunner: Bringing down the entire Instrumentation process. 03-25 21:23:20.745 2892 2892 E MonitoringInstr: Exception encountered by: Thread[main,5,main]. Dumping thread state to outputs and pining for the fjords. 03-25 21:23:20.745 2892 2892 E MonitoringInstr: java.lang.NullPointerException 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at com.apparence.camerawesome.cameraX.CameraAwesomeX$recordVideo$1.invokeSuspend(CameraAwesomeX.kt:418) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at android.os.Handler.handleCallback(Handler.java:942) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at android.os.Handler.dispatchMessage(Handler.java:99) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at android.os.Looper.loopOnce(Looper.java:201) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at android.os.Looper.loop(Looper.java:288) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at android.app.ActivityThread.main(ActivityThread.java:7872) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at java.lang.reflect.Method.invoke(Native Method) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 03-25 21:23:20.745 2892 2892 E MonitoringInstr: Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7392925, Dispatchers.Main] 03-25 21:23:20.747 2892 2892 E THREAD_STATE: Thread[HwBinder:2892_1,5,main] 03-25 21:23:20.747 2892 2892 E THREAD_STATE: 03-25 21:23:20.747 2892 2892 E THREAD_STATE: Thread[DefaultDispatcher-worker-4,5,main] 03-25 21:23:20.747 2892 2892 E THREAD_STATE: jdk.internal.misc.Unsafe.park(Native Method) 03-25 21:23:20.747 2892 2892 E THREAD_STATE: java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:357) 03-25 21:23:20.747 2892 2892 E THREAD_STATE: kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.park(CoroutineScheduler.kt:795) 03-25 21:23:20.747 2892 2892 E THREAD_STATE: kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.tryPark(CoroutineScheduler.kt:740) 03-25 21:23:20.747 2892 2892 E THREAD_STATE: kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:711) 03-25 21:23:20.747 2892 2892 E THREAD_STATE: kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) 03-25 21:23:20.747 2892 2892 E THREAD_STATE: 03-25 21:23:20.747 2892 2892 E THREAD_STATE: Thread[Signal Catcher,10,system] ```

What's worse is that you don't get test results of the failure, but only a cryptic "Instrumentation process crashed" instead. That's because

istornz commented 1 year ago

Thanks a lot @bartekpacia 👍 Your help is greatly appreciated 🥇

apalala-dev commented 1 year ago

Since you mentioned that there was a problem with ui_test, I tried an other one.

The tests didn't run after running the following command: patrol test --target integration_test/photo_test.dart --verbose

After looking at the logcat, I've noticed this:

Logs ``` 2023-03-27 10:27:25.878 9084-9112 THREAD_STATE com.example.camera_app E Thread[Binder:9084_3,5,main] Thread[Profile Saver,5,system] Thread[Instr: androidx.test.runner.AndroidJUnitRunner,5,main] dalvik.system.VMStack.getThreadStackTrace(Native Method) java.lang.Thread.getStackTrace(Thread.java:1736) java.lang.Thread.getAllStackTraces(Thread.java:1812) androidx.test.runner.MonitoringInstrumentation.getThreadState(MonitoringInstrumentation.java:748) androidx.test.runner.MonitoringInstrumentation.dumpThreadStateToOutputs(MonitoringInstrumentation.java:743) androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:547) androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:376) pl.leancode.patrol.PatrolTestRule.launchActivity(PatrolTestRule.kt:28) dev.flutter.plugins.integration_test.FlutterTestRunner.run(FlutterTestRunner.java:61) org.junit.runners.Suite.runChild(Suite.java:128) org.junit.runners.Suite.runChild(Suite.java:27) org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) org.junit.runners.ParentRunner.run(ParentRunner.java:413) org.junit.runner.JUnitCore.run(JUnitCore.java:137) org.junit.runner.JUnitCore.run(JUnitCore.java:115) androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67) androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58) androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:446) android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2213) Thread[FinalizerWatchdogDaemon,5,system] java.lang.Thread.sleep(Native Method) java.lang.Thread.sleep(Thread.java:442) java.lang.Thread.sleep(Thread.java:358) java.lang.Daemons$FinalizerWatchdogDaemon.sleepForNanos(Daemons.java:391) java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:420) java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:326) java.lang.Daemons$Daemon.run(Daemons.java:140) java.lang.Thread.run(Thread.java:923) Thread[HeapTaskDaemon,5,system] Thread[FinalizerDaemon,5,system] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:190) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:211) java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:274) java.lang.Daemons$Daemon.run(Daemons.java:140) java.lang.Thread.run(Thread.java:923) Thread[Jit thread pool worker thread 0,5,system] Thread[Signal Catcher,10,system] Thread[grpc-okhttp-0,5,main] libcore.io.Linux.poll(Native Method) libcore.io.ForwardingOs.poll(ForwardingOs.java:168) libcore.io.BlockGuardOs.poll(BlockGuardOs.java:263) libcore.io.ForwardingOs.poll(ForwardingOs.java:168) android.system.Os.poll(Os.java:430) libcore.io.IoBridge.poll(IoBridge.java:676) java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:194) java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:451) java.net.ServerSocket.implAccept(ServerSocket.java:547) java.net.ServerSocket.accept(ServerSocket.java:515) io.grpc.okhttp.OkHttpServer.acceptConnections(OkHttpServer.java:100) io.grpc.okhttp.OkHttpServer.$r8$lambda$nWZgluu-gd0CBu46dJMXNIRQajA(Unknown Source:0) io.grpc.okhttp.OkHttpServer$$ExternalSyntheticLambda0.run(Unknown Source:2) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) java.lang.Thread.run(Thread.java:923) Thread[DefaultDispatcher-worker-1,5,main] 2023-03-27 10:27:25.878 9084-9112 THREAD_STATE com.example.camera_app E java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.Object.wait(Object.java:568) io.grpc.internal.ServerImpl.awaitTermination(ServerImpl.java:320) pl.leancode.patrol.PatrolServer.blockUntilShutdown(PatrolServer.kt:39) pl.leancode.patrol.PatrolTestRule$launchActivity$1.invokeSuspend(PatrolTestRule.kt:25) kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Thread[ReferenceQueueDaemon,5,system] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.Object.wait(Object.java:568) java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:218) java.lang.Daemons$Daemon.run(Daemons.java:140) java.lang.Thread.run(Thread.java:923) Thread[main,5,main] android.os.MessageQueue.nativePollOnce(Native Method) android.os.MessageQueue.next(MessageQueue.java:335) android.os.Looper.loop(Looper.java:193) android.app.ActivityThread.main(ActivityThread.java:7876) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) Thread[Binder:9084_2,5,main] Thread[Binder:9084_1,5,main] Thread[InstrumentationConnectionThread,5,main] android.os.MessageQueue.nativePollOnce(Native Method) android.os.MessageQueue.next(MessageQueue.java:335) android.os.Looper.loop(Looper.java:193) android.os.HandlerThread.run(HandlerThread.java:67) Thread[DefaultDispatcher-worker-2,5,main] sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:353) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.park(CoroutineScheduler.kt:795) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.tryPark(CoroutineScheduler.kt:740) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:711) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Thread[MonitoringInstrumentation,5,main] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.Object.wait(Object.java:568) android.app.Instrumentation.startActivitySync(Instrumentation.java:528) android.app.Instrumentation.startActivitySync(Instrumentation.java:465) androidx.test.runner.MonitoringInstrumentation.access$001(MonitoringInstrumentation.java:102) androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:540) androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:537) java.util.concurrent.FutureTask.run(FutureTask.java:266) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) java.lang.Thread.run(Thread.java:923) ```

Note that the error only appeared in the logcat (no error from the CLI which makes it seem to hang forever)

The develop command gave a similar result but the CLI (with --verbose) mentionned this:

        V/FlutterTestRunner(12075): launchActivity failed, possibly because the activity was already running. java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.example.camera_app/.MainActivity } within 45000 milliseconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1679906315630 and now the last time the queue went idle was: 1679906315630. If these numbers are the same your activity might be hogging the event queue.
        V/FlutterTestRunner(12075): Try disabling auto-launch of the activity, e.g. ActivityTestRule<>(MainActivity.class, true, false);

I found similar logs in the logcat:

Logs ``` 2023-03-27 10:39:20.822 12075-12102 THREAD_STATE com.example.camera_app E Thread[Binder:12075_3,5,main] Thread[Profile Saver,5,system] Thread[Instr: androidx.test.runner.AndroidJUnitRunner,5,main] dalvik.system.VMStack.getThreadStackTrace(Native Method) java.lang.Thread.getStackTrace(Thread.java:1736) java.lang.Thread.getAllStackTraces(Thread.java:1812) androidx.test.runner.MonitoringInstrumentation.getThreadState(MonitoringInstrumentation.java:748) androidx.test.runner.MonitoringInstrumentation.dumpThreadStateToOutputs(MonitoringInstrumentation.java:743) androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:547) androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:376) pl.leancode.patrol.PatrolTestRule.launchActivity(PatrolTestRule.kt:28) dev.flutter.plugins.integration_test.FlutterTestRunner.run(FlutterTestRunner.java:61) org.junit.runners.Suite.runChild(Suite.java:128) org.junit.runners.Suite.runChild(Suite.java:27) org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) org.junit.runners.ParentRunner.run(ParentRunner.java:413) org.junit.runner.JUnitCore.run(JUnitCore.java:137) org.junit.runner.JUnitCore.run(JUnitCore.java:115) androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67) androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58) androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:446) android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2213) Thread[FinalizerDaemon,5,system] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:190) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:211) java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:274) java.lang.Daemons$Daemon.run(Daemons.java:140) java.lang.Thread.run(Thread.java:923) Thread[HeapTaskDaemon,5,system] Thread[ReferenceQueueDaemon,5,system] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.Object.wait(Object.java:568) java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:218) java.lang.Daemons$Daemon.run(Daemons.java:140) java.lang.Thread.run(Thread.java:923) Thread[FinalizerWatchdogDaemon,5,system] java.lang.Thread.sleep(Native Method) java.lang.Thread.sleep(Thread.java:442) java.lang.Thread.sleep(Thread.java:358) java.lang.Daemons$FinalizerWatchdogDaemon.sleepForNanos(Daemons.java:391) java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:420) java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:326) java.lang.Daemons$Daemon.run(Daemons.java:140) java.lang.Thread.run(Thread.java:923) Thread[Signal Catcher,10,system] Thread[grpc-okhttp-0,5,main] libcore.io.Linux.poll(Native Method) libcore.io.ForwardingOs.poll(ForwardingOs.java:168) libcore.io.BlockGuardOs.poll(BlockGuardOs.java:263) libcore.io.ForwardingOs.poll(ForwardingOs.java:168) android.system.Os.poll(Os.java:430) libcore.io.IoBridge.poll(IoBridge.java:676) java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:194) java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:451) java.net.ServerSocket.implAccept(ServerSocket.java:547) java.net.ServerSocket.accept(ServerSocket.java:515) io.grpc.okhttp.OkHttpServer.acceptConnections(OkHttpServer.java:100) io.grpc.okhttp.OkHttpServer.$r8$lambda$nWZgluu-gd0CBu46dJMXNIRQajA(Unknown Source:0) 2023-03-27 10:39:20.822 12075-12102 THREAD_STATE com.example.camera_app E io.grpc.okhttp.OkHttpServer$$ExternalSyntheticLambda0.run(Unknown Source:2) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) java.lang.Thread.run(Thread.java:923) Thread[DefaultDispatcher-worker-1,5,main] sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:353) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.park(CoroutineScheduler.kt:795) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.tryPark(CoroutineScheduler.kt:740) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:711) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Thread[Jit thread pool worker thread 0,5,system] Thread[main,5,main] android.os.MessageQueue.nativePollOnce(Native Method) android.os.MessageQueue.next(MessageQueue.java:335) android.os.Looper.loop(Looper.java:193) android.app.ActivityThread.main(ActivityThread.java:7876) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) Thread[Binder:12075_2,5,main] Thread[Binder:12075_1,5,main] Thread[InstrumentationConnectionThread,5,main] android.os.MessageQueue.nativePollOnce(Native Method) android.os.MessageQueue.next(MessageQueue.java:335) android.os.Looper.loop(Looper.java:193) android.os.HandlerThread.run(HandlerThread.java:67) Thread[DefaultDispatcher-worker-2,5,main] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.Object.wait(Object.java:568) io.grpc.internal.ServerImpl.awaitTermination(ServerImpl.java:320) pl.leancode.patrol.PatrolServer.blockUntilShutdown(PatrolServer.kt:39) pl.leancode.patrol.PatrolTestRule$launchActivity$1.invokeSuspend(PatrolTestRule.kt:25) kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Thread[MonitoringInstrumentation,5,main] java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:442) java.lang.Object.wait(Object.java:568) android.app.Instrumentation.startActivitySync(Instrumentation.java:528) android.app.Instrumentation.startActivitySync(Instrumentation.java:465) androidx.test.runner.MonitoringInstrumentation.access$001(MonitoringInstrumentation.java:102) androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:540) androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:537) java.util.concurrent.FutureTask.run(FutureTask.java:266) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) java.lang.Thread.run(Thread.java:923) ```
apalala-dev commented 1 year ago

@bartekpacia Any idea on how we could fix this?

bartekpacia commented 1 year ago

After looking at the logcat, I've noticed this:

I'm pretty sure that the killing of all these threads (visible in your logcat) is the aftermath of a crash that occurred a bit earlier. If you scrolled the logcat up, you'd see this.

Unfortunately, I've no idea what could be causing this – I've seen many different crashes with Patrol but nothing like this.

apalala-dev commented 1 year ago

I applied your changes on another branch and commented my own tests. Then I made one very simple to see if this simple config works first and seems to be ok.

In the end, my tests are probably the problem 😅 I'll fix them then I'll have to figure out if the tests run well on my physical device as well, but I am not stuck anymore :)

Thanks for the help! 💪

bartekpacia commented 1 year ago

Hm, strange. But I'm glad to hear that it at least started to work on another branch.

Thanks for the help!

Yeah, happy to help and thanks for the awesome plugin :) Unfortunately, my time is limited so I can't help you as much as I want, but feel free to ask me in case of any more problems/questions - maybe I'll be of more help.

apalala-dev commented 1 year ago

I made an other PR (#307) which fixes some of the tests that didn't pass and include your changes. I'm closing this PR since the changes are also there.

There are still some behaviours a bit weird on my device: once the apps for testing are installed, I need to launch manually my app to be able to run the tests on it. It may be related to this specific device. On emulator it works fine, and same for Firebase Test Lab!

Thanks again for the help 🙏