wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.24k stars 1.92k forks source link

react-native Android timeout on detox.init() or detox.launchApp() WebSocket on release mode #2071

Closed dbilgin closed 4 years ago

dbilgin commented 4 years ago

Describe the bug

My detox works on iOS, but when I try to use it on Android the init.js file hangs on Android release mode.

BeforeAll(async () => {
  await detox.init(config);
});

or

BeforeAll(async () => {
  await detox.init(config, {launchApp: false});
  await detox.device.launchApp({ // Hangs here
    newInstance: true,
    permissions: {notifications: 'YES', location: 'always'},
  });
});

Now I've been looking at my logcat and as far as I've understood it's having trouble connecting to the WebSocket, but I don't know what to do with this. The app opens but just stays like that and after a while it gives the error below:

caused by: Error: function timed out, ensure the promise resolves within 120000 milliseconds
    at Timeout._time.default.setTimeout [as _onTimeout] (/Users/me/Desktop/example/node_modules/cucumber/lib/user_code_runner.js:76:18)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

To Reproduce

Steps to reproduce:

  1. detox build --configuration android.emu.release
  2. node_modules/.bin/cucumber-js ./e2e --require-module @babel/register --configuration android.emu.release --format node_modules/cucumber-pretty

Expected behavior

Screenshots

Device and Verbose Detox Logs

2020-05-18 18:40:49.266 8148-8311/? I/WebSocketClient: At connectToServer
2020-05-18 18:40:49.342 8148-8148/? D/RNBranch: onInitFinished
2020-05-18 18:40:49.344 8148-8148/? D/RNBranch: sendRNEvent
2020-05-18 18:40:49.344 8148-8148/? D/RNBranch: Catalyst instance poller try 1
2020-05-18 18:40:49.344 8148-8148/? D/RNBranch: Catalyst instance active
2020-05-18 18:40:49.376 1778-8323/? E/ResolverController: No valid NAT64 prefix (103, <unspecified>/0)
2020-05-18 18:40:49.784 8148-8298/? I/ReactNativeJS: Initializing react-native-branch v. 4.3.0
2020-05-18 18:40:49.811 8148-8299/? D/io.sentry.android.AndroidSentryClientFactory: Construction of Android Sentry from Android Context.
2020-05-18 18:40:49.812 8148-8299/? D/io.sentry.android.AndroidSentryClientFactory: Sentry init with ctx='com.example.MainApplication@617b518'
2020-05-18 18:40:49.815 8148-8299/? W/*ultSentryClientFactory: No 'stacktrace.app.packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://docs.sentry.io/clients/java/config/#in-application-stack-frames
2020-05-18 18:40:49.818 8148-8299/? D/io.sentry.android.AndroidSentryClientFactory: Using buffer dir: /data/user/0/com.example/cache/sentry-buffered-events
2020-05-18 18:40:49.819 8148-8298/? I/ReactNativeJS: Running "Example" with {"rootTag":1}
2020-05-18 18:40:49.823 8148-8299/? W/*ultSentryClientFactory: No 'stacktrace.app.packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://docs.sentry.io/clients/java/config/#in-application-stack-frames
2020-05-18 18:40:49.824 8148-8299/? D/io.sentry.android.AndroidSentryClientFactory: ANR is='false'
2020-05-18 18:40:49.825 8148-8299/? I/react-native-sentry: startWithDsnString
2020-05-18 18:40:49.815 8148-8148/? W/mqt_native_modu: type=1400 audit(0.0:445): avc: denied { read } for name="version" dev="proc" ino=4026532036 scontext=u:r:untrusted_app_27:s0:c195,c256,c512,c768 tcontext=u:object_r:proc_version:s0 tclass=file permissive=0
2020-05-18 18:40:49.842 1778-8326/? E/ResolverController: No valid NAT64 prefix (103, <unspecified>/0)
2020-05-18 18:40:49.906 8148-8329/? D/SoLoader: About to load: libimagepipeline.so
2020-05-18 18:40:49.907 8148-8329/? D/SoLoader: libimagepipeline.so not found on /data/data/com.example/lib-main
2020-05-18 18:40:49.907 8148-8329/? D/SoLoader: libimagepipeline.so found on /data/app/com.example-kZwk-kt8fOnsi2Zy1mO15g==/lib/x86
2020-05-18 18:40:49.908 8148-8329/? D/SoLoader: Not resolving dependencies for libimagepipeline.so
2020-05-18 18:40:49.913 8148-8331/? W/InstanceID: Instance ID SDK is deprecated, com.example should update to use Firebase Instance ID
2020-05-18 18:40:49.926 8148-8329/? D/SoLoader: Loaded: libimagepipeline.so
2020-05-18 18:40:49.989 2410-3166/? E/ActivityThread: Failed to find provider info for com.google.android.apps.wellbeing.api
2020-05-18 18:40:49.997 8148-8299/? I/Intercom: updateUser
2020-05-18 18:40:49.998 8148-8299/? I/Intercom: registerUnidentifiedUser
2020-05-18 18:40:49.998 8148-8212/? E/BluetoothAdapter: Bluetooth binder is null
2020-05-18 18:40:49.998 8148-8299/? I/Intercom: registerUnidentifiedUser
2020-05-18 18:40:50.070 8148-8298/? I/ReactNativeJS: [Branch] setRequestMetadata has limitations when called from JS.  Some network calls are made prior to the JS layer being available, those calls will not have the metadata.
2020-05-18 18:40:50.083 8148-8299/? I/Intercom: registerUnidentifiedUser
2020-05-18 18:40:50.086 8148-8299/? I/Intercom: updateUser
2020-05-18 18:40:50.088 8148-8299/? I/Intercom: updateUser
2020-05-18 18:40:50.105 8148-8335/? I/WebViewFactory: Loading com.google.android.webview version 74.0.3729.185 (code 373018518)
2020-05-18 18:40:50.142 8148-8335/? I/com.example: The ClassLoaderContext is a special shared library.
2020-05-18 18:40:50.185 8148-8335/? I/com.example: The ClassLoaderContext is a special shared library.
2020-05-18 18:40:50.210 1794-2254/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-05-18 18:40:50.210 1794-2254/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-05-18 18:40:50.222 8148-8299/? I/Intercom: updateUser
2020-05-18 18:40:50.440 8148-8299/? I/chatty: uid=10195(com.example) mqt_native_modu identical 5 lines
2020-05-18 18:40:50.441 8148-8299/? I/Intercom: updateUser
2020-05-18 18:40:50.463 8148-8335/? I/com.example: Waiting for a blocking GC ClassLinker
2020-05-18 18:40:50.489 8148-8160/? I/com.example: Background concurrent copying GC freed 147953(6493KB) AllocSpace objects, 62(2856KB) LOS objects, 36% free, 10MB/16MB, paused 1.371ms total 209.848ms
2020-05-18 18:40:50.489 8148-8335/? I/com.example: WaitForGcToComplete blocked ClassLinker on ClassLinker for 25.858ms
2020-05-18 18:40:50.548 8148-8335/? I/cr_LibraryLoader: Time to load native libraries: 11 ms (timestamps 9662-9673)
2020-05-18 18:40:50.597 1778-1778/? I/netd: firewallSetUidRule(2, 10112, 1) <0.03ms>
2020-05-18 18:40:50.613 8148-8335/? I/chromium: [INFO:library_loader_hooks.cc(50)] Chromium logging enabled: level = 0, default verbosity = 0
2020-05-18 18:40:50.748 2033-3872/? D/AlarmManagerService: Kernel timezone updated to -120 minutes west of GMT
2020-05-18 18:40:50.804 1778-8349/? E/ResolverController: No valid NAT64 prefix (103, <unspecified>/0)
2020-05-18 18:40:50.805 1778-8348/? E/ResolverController: No valid NAT64 prefix (103, <unspecified>/0)
2020-05-18 18:40:50.806 8148-8344/? W/com.example: JNI critical lock held for 96.343ms on Thread[79,tid=8344,Runnable,Thread*=0xc6bb3800,peer=0x12d45a58,"pool-18-thread-2"]
2020-05-18 18:40:50.807 1778-8347/? E/ResolverController: No valid NAT64 prefix (103, <unspecified>/0)
2020-05-18 18:40:50.823 8148-8160/? I/com.example: Background concurrent copying GC freed 66016(2916KB) AllocSpace objects, 6(22MB) LOS objects, 17% free, 28MB/34MB, paused 258us total 151.694ms
2020-05-18 18:40:50.975 8148-8167/? I/com.example: Waiting for a blocking GC ProfileSaver
2020-05-18 18:40:50.992 8148-8167/? I/com.example: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 16.247ms
2020-05-18 18:40:51.160 8148-8356/? W/com.example: JNI critical lock held for 89.006ms on Thread[87,tid=8356,Runnable,Thread*=0xc6bb5400,peer=0x12cc2d28,"pool-18-thread-3"]
2020-05-18 18:40:51.176 8148-8160/? I/com.example: Background concurrent copying GC freed 2390(459KB) AllocSpace objects, 6(21MB) LOS objects, 10% free, 49MB/55MB, paused 73.494ms total 170.033ms
2020-05-18 18:40:51.210 1794-2254/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-05-18 18:40:51.211 1794-2254/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-05-18 18:40:51.953 1778-8360/? E/ResolverController: No valid NAT64 prefix (103, <unspecified>/0)
2020-05-18 18:40:52.211 1794-2254/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-05-18 18:40:52.212 1794-2254/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-05-18 18:40:52.279 8148-8319/? D/WebSocketClient: Retrying... ==>> KEEPS RETRYING FROM HERE ON OUT
2020-05-18 18:40:52.279 8148-8319/? I/WebSocketClient: At connectToServer

Environment (please complete the following information):

dbilgin commented 4 years ago

It works when I used debug mode, I guess this is due to Android's restrictions.