patrol icon indicating copy to clipboard operation
patrol copied to clipboard

Can't run test in Android

Open chihuy105 opened this issue 10 months ago • 36 comments

Steps to reproduce

Setup the patrol. And run the test

Actual results

When run patrol test in android with a Emulator that don't have Google play service (android-34/default/arm64-v8a) in German language The test going for awhile until it got the issue. It works on IOS side

Image

Logs

Logs
Unhandled exception:
FormatException: Missing extension byte (at offset 1188)
#0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1950:7)
#1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
#2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
#3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
#4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1609:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:777:19)
#9      _StreamController._add (dart:async/stream_controller.dart:651:7)
#10     _StreamController.add (dart:async/stream_controller.dart:606:5)
#11     _Socket._onData (dart:io-patch/socket_patch.dart:2455:41)
#12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1609:10)
#13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
#14     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
#15     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:777:19)
#16     _StreamController._add (dart:async/stream_controller.dart:651:7)
#17     _StreamController.add (dart:async/stream_controller.dart:606:5)
#18     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1942:33)
#19     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1385:14)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#22     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#23     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

Patrol version

patrol: 3.14.0 patrol_finders: 2.7.0

Patrol Doctor output

Patrol Doctor output
Patrol doctor:
Patrol CLI version: 3.5.0
Flutter command: flutter 
  Flutter 3.27.1 • channel stable
Android: 
• Program adb found in /opt/homebrew/bin/adb
• Env var $ANDROID_HOME set to /Users/kyohuu/Library/Android/sdk
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller

Flutter Doctor output

Flutter Doctor output
Flutter (Channel stable, 3.27.1, on macOS 14.6.1 23G93 darwin-arm64, locale en-VN)
    • Flutter version 3.27.1 on channel stable at /Users/kyohuu/fvm/versions/3.27.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 17025dd882 (8 weeks ago), 2024-12-17 03:23:09 +0900
    • Engine revision cb4b5fff73
    • Dart version 3.6.0
    • DevTools version 2.40.2

chihuy105 avatar Feb 14 '25 04:02 chihuy105

I found the same issue. Look like patrol not working with other language https://github.com/leancodepl/patrol/issues/1334

chihuy105 avatar Feb 14 '25 04:02 chihuy105

@chihuy105 It seams this is caused by something else, I mean I often get the same error on en_US language. In my case "Missing extension byte (at offset 1066)", "Missing extension byte (at offset 1287)".

DmytroChuchmaiBarges avatar Feb 18 '25 13:02 DmytroChuchmaiBarges

Hi, so repro steps are:

  1. Have emulator like this: don't have Google play service (android-34/default/arm64-v8a)
  2. Set language to German on emulator Correct?
  • Additional question, this is something that is 100% reproducible or this is some random error that is flaky.

Kendru98 avatar Feb 20 '25 07:02 Kendru98

It happens on every run after 6 or 7 test.

  1. A emulator that don't have GG service
  2. Yes

chihuy105 avatar Feb 20 '25 08:02 chihuy105

@chihuy105 Thanks for answer, last question, can you confirm that GG service has meaning here? If you have emulator with GG service and change language to german test pass?

Kendru98 avatar Feb 20 '25 09:02 Kendru98

Same issue, locale is en_GB, have not tried to set to en_US:


FormatException: Missing extension byte (at offset 1484)
#0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1959:7)
#1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:310:28)
#2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:306:5)
#3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:70:18)
#4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:115:24)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1778:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:312:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:798:19)
#9      _StreamController._add (dart:async/stream_controller.dart:663:7)
#10     _StreamController.add (dart:async/stream_controller.dart:618:5)
#11     _Socket._onData (dart:io-patch/socket_patch.dart:2904:41)
#12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1778:10)
#13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381:11)
#14     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:312:7)
#15     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:798:19)
#16     _StreamController._add (dart:async/stream_controller.dart:663:7)
#17     _StreamController.add (dart:async/stream_controller.dart:618:5)
#18     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:2323:31)
#19     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1646:14)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#22     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:128:13)
#23     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:195:5)


shovelmn12 avatar Feb 28 '25 11:02 shovelmn12

Same thing. Worked fine for some time.... Will try downgrading

kubicki-4human avatar Mar 04 '25 14:03 kubicki-4human

@kubicki-4human did it work?

@Kendru98 any news on a fix for this issue?

shovelmn12 avatar Mar 05 '25 06:03 shovelmn12

@shovelmn12 Hi, you also use an emulator without Google play service? There are some other priorities now, but I will forward this to team.

Kendru98 avatar Mar 05 '25 10:03 Kendru98

@Kendru98 I am using an emulator with google play services ...

Anyways I am not using patrol anymore too many bugs and issues good luck to you :)

shovelmn12 avatar Mar 05 '25 10:03 shovelmn12

@chihuy105 @kubicki-4human Hi guys, can you prepare minimal steps for reproduction? I was trying to reproduce this in german, and en_GB, but failed to reproduce. Or at least provide some native methods that fails in specific languages.

Kendru98 avatar Mar 05 '25 15:03 Kendru98

I’m not sure but this could be the problems I have many test case and all of it start with a native webview login usung keycloak so I do a lot of native run at the start of each test using enterTextByIndex,… native method on the webview and alot of Future.delay

chihuy105 avatar Mar 05 '25 15:03 chihuy105

I am constantly having this error when running test in bulk i.e. without specifying a target and when I run the tests specifying the target, id does not fail. It is hard to debug though due to I need to wait about 10-20 tests to run until they fail, and the whole test process crashing. Im my case it fails after tapping at widget with a specific key, or waitUntilVisible

DmytroChuchmaiBarges avatar Mar 05 '25 16:03 DmytroChuchmaiBarges

@kubicki-4human did it work?

@Kendru98 any news on a fix for this issue?

Downgrading didn't work, but just using another instance of emulator did. Weird..

kubicki-4human avatar Mar 05 '25 16:03 kubicki-4human

what instance did you use?

chihuy105 avatar Mar 05 '25 16:03 chihuy105

It might be related to https://github.com/flutter/flutter/issues/81666

DmytroChuchmaiBarges avatar Mar 05 '25 16:03 DmytroChuchmaiBarges

I think not on my case cause it’s Android

chihuy105 avatar Mar 06 '25 04:03 chihuy105

This is related to UTF8Devcoder.convertChunked which is used framework-wide.

DmytroChuchmaiBarges avatar Mar 06 '25 07:03 DmytroChuchmaiBarges

hey there, I found a workaround for now: When you run the test, you see ./gradlew :app:connectedStageDebugAndroidTest -Ptarget=/Users/path_to_your_code/integration_test/test_bundle.dart -Pdart-defines=.... it might be ":app:connectedDebugAndroidTest" So,

  1. you do the patrol build android with all the params and targets
  2. cd /android
  3. run ./gradlew :app:connectedStageDebugAndroidTest -Ptarget=/Users/path_to_your_code/integration_test/test_bundle.dart -Pdart-defines=....

in this way it does not crash the patrol process.

DmytroChuchmaiBarges avatar Mar 06 '25 15:03 DmytroChuchmaiBarges

Thanks let me check

chihuy105 avatar Mar 07 '25 00:03 chihuy105

Same Issue .. Any updates?

cljobs avatar Apr 08 '25 09:04 cljobs

Same Issue .. Any updates?

Hi @cljobs, It is hard to reproduce for us, can you provide some cloned repo, and specific emulator config that problem exist? Also flutter --verbose logs etc?

Kendru98 avatar Apr 08 '25 09:04 Kendru98

Hi @cljobs ! As @Kendru98 wrote, we couldn't reproduce this issue before, we need more information, To be more specific:

  • a repo where we can reproduce this bug would be most useful
  • logs from logcat - my guess for now is that the real error log is there

Also it would be very useful for us to know, why your tests failed at this moment (I know, that there is no error log related to your test, but at least tell us what action should be performed in test at the moment of crash)

jBorkowska avatar Apr 08 '25 09:04 jBorkowska

jBorkowska please have a look at workaround I described above, it seams that the issue is in Patrol CLI since if you run the test via gradle, i runs all fine. So somewhere in the process of running tests,I suppose there's some error happens during sending/receiving information between the patrol CLI and the app. btw, there's an open futter framework bug around this error.

DmytroChuchmaiBarges avatar Apr 08 '25 10:04 DmytroChuchmaiBarges

@DmytroChuchmaiBarges I read the thread, still we need the information I wrote about to debug it on our own

jBorkowska avatar Apr 08 '25 10:04 jBorkowska

I am experiencing this issue on all the Android devices I've tested. This includes a Samsung Galaxy S22, as well as Android 13 and 14 emulators, both with and without Google Play Services.

It's Logcat Error

  1. 'package:flutter_test/src/binding.dart': Failed assertion: line 1000 pos 14: '_pendingExceptionDetails != null': A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.

  2. dart:core-patch/errors_patch.dart 50:61 _AssertionError._doThrowNew

  3. dart:core-patch/errors_patch.dart 40:5 _AssertionError._throwNew

  4. package:flutter_test/src/binding.dart 1000:14 TestWidgetsFlutterBinding._runTest.handleUncaughtError

  5. package:flutter_test/src/binding.dart 1005:9 TestWidgetsFlutterBinding._runTest.

  6. dart:async/zone.dart 1081:14 _Zone._processUncaughtError

  7. dart:async/zone.dart 1285:5 _CustomZone.handleUncaughtError

  8. dart:async/future_impl.dart 811:16 Future._propagateToListeners

  9. dart:async/future_impl.dart 674:5 Future._completeError

patrol: 3.14.1 patrol_cli: 3.5.1 androidx.test:orchestrator:1.5.1

Unfortunately, I can't share the code where the error is occurring because it belongs to my company.

cljobs avatar Apr 08 '25 10:04 cljobs

Thanks @cljobs . I'll try to reproduce this error.

If you're looking how to solve the error from logcat, check out this (from setup instructions):

Image

jBorkowska avatar Apr 08 '25 11:04 jBorkowska

I try do not modify FlutterError.onError but still error causes

It's Logcat Error

2025-04-09 10:15:16.648 606-745 ActivityManager system_server I Force stopping debug appid=10219 user=0: finished inst 2025-04-09 10:15:16.649 606-745 ActivityManager system_server I Killing 13357:.debug/u0a219 (adj 0): stop .debug due to finished inst 2025-04-09 10:15:16.651 13330-13330 app_process app_process I System.exit called, status: 0 2025-04-09 10:15:16.651 13330-13330 AndroidRuntime app_process I VM exiting with result code 0. 2025-04-09 10:15:16.652 8734-8734 BoundBrokerSvc com.google.android.gms D onUnbind: Intent { act=com.google.android.gms.measurement.START pkg=com.google.android.gms } 2025-04-09 10:15:16.653 606-745 ActivityTaskManager system_server W Force removing ActivityRecord{73a171a u0 .debug/.MainActivity} t2738 f}}: app died, no saved state 2025-04-09 10:15:16.654 877-1094 BtGatt.ScanManager com.android.bluetooth D uid 10108 isForeground true scanMode -1 2025-04-09 10:15:16.655 8734-8734 BoundBrokerSvc com.google.android.gms D onUnbind: Intent { act=com.google.android.gms.appset.service.START dat=chimera-action:/... cmp=com.google.android.gms/.chimera.GmsApiService } 2025-04-09 10:15:16.656 606-745 InputManager-JNI system_server W Input channel object '711e688 .debug/.MainActivity (client)' was disposed without first being removed with the input manager!

com....android.googlequicksearchbox W Failed to notify listeners java.util.concurrent.CancellationException at java.util.concurrent.FutureTask.report(FutureTask.java:121) at java.util.concurrent.FutureTask.get(FutureTask.java:191) at com.google.common.util.concurrent.bv.get(PG:1) at com.google.common.util.concurrent.ed.a(PG:1) at com.google.common.util.concurrent.cj.r(PG:2) at com.google.common.util.concurrent.cc.run(PG:4) at com.google.common.util.concurrent.bg.execute(PG:1) at com.google.common.util.concurrent.bj.c(PG:1) at com.google.common.util.concurrent.bj.b(PG:3) at com.google.common.util.concurrent.cy.done(PG:1) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381) at java.util.concurrent.FutureTask.cancel(FutureTask.java:179) at com.google.common.util.concurrent.bv.cancel(PG:1) at com.google.android.apps.search.assistant.platform.ondevice.fulfillment.server.k.r.run(PG:1) at com.google.apps.tiktok.tracing.eh.run(PG:2) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463) at com.google.common.util.concurrent.ea.a(PG:1) at com.google.common.util.concurrent.cw.run(PG:4) at com.google.common.util.concurrent.eb.run(PG:1) at com.google.android.libraries.i.af.run(PG:1) at com.google.android.libraries.i.an.run(PG:23) at com.google.android.libraries.i.l.run(PG:2) at com.google.android.libraries.i.q.run(PG:4) at java.lang.Thread.run(Thread.java:1012)

java.lang.SecurityException: Caller androidx.test.services:10221 cannot post for pkg androidx.test.services in user 0 at com.android.server.notification.NotificationManagerService.resolveNotificationUid(NotificationManagerService.java:6851) at com.android.server.notification.NotificationManagerService.cancelNotificationInternal(NotificationManagerService.java:6402) at com.android.server.notification.NotificationManagerService$11.cancelNotification(NotificationManagerService.java:6300) at com.android.server.am.ServiceRecord$3.run(ServiceRecord.java:1150) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.os.HandlerThread.run(HandlerThread.java:67) at com.android.server.ServiceThread.run(ServiceThread.java:44)

(REDACTED) Failed to process cache entry for package(%s). android.content.pm.PackageManager$NameNotFoundException: androidx.test.services at android.app.ApplicationPackageManager.getInstallSourceInfo(ApplicationPackageManager.java:2541) at com.google.android.apps.gsa.nga.engine.ag.ae.a(PG:13) at com.google.android.libraries.gsa.k.a.j.call(PG:2) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at com.google.common.util.concurrent.dq.run(PG:4) at com.google.android.libraries.i.af.run(PG:1) at com.google.android.libraries.i.an.run(PG:23) at com.google.android.libraries.i.l.run(PG:2) at com.google.android.libraries.i.q.run(PG:4) at java.lang.Thread.run(Thread.java:1012)

cljobs avatar Apr 09 '25 01:04 cljobs

Could you post full log from the run? @cljobs

jBorkowska avatar Apr 09 '25 09:04 jBorkowska

Also I didn't reproduce the crash with getting this "FlutterError.onError override" so it must be something else

jBorkowska avatar Apr 09 '25 09:04 jBorkowska