Detox
Detox copied to clipboard
(WIP) Detox init timeout with Android API 32
What happened?
A follow-up on the discussions in #3342.
It seems that there are issues with API 32. Most likely, 33 has those as well. We need to check.
What was the expected behaviour?
API 32 should work just as 28 and 29 do.
Was it tested on latest Detox?
- [X] I have tested this issue on the latest Detox release and it still reproduces.
Did your test throw out a timeout?
- [ ] I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
Help us reproduce this issue!
No response
In what environment did this happen?
Detox version: React Native version: Node version: Device model: Android version: Test-runner (select one): jest-circus / jest+jasmine / mocha / other
Detox logs
Detox logs
paste logs here!
Device logs
Device logs
paste logs here!
More data, please!
No response
@d4vidi I have similar problems than described in https://github.com/wix/Detox/issues/3071 with android-31, android-32 and android-33 (android-30 works fine). Detox version is 19.7.1. In #3071 it is mentioned "If the emulator is already up and running when starting detox, tests are executed as expected.". Is it documented somewhere how to start emulator first and only after this Detox? When I try this I get "Running multiple emulators with the same AVD". I have stackoverflow question about it, without no reply. I would appreciate if someone from Detox team would reply to that? https://stackoverflow.com/questions/73319635/how-to-configure-detox-to-be-able-to-use-android-emulator-running-already
@jaheikki you might like this:
https://github.com/ankidroid/Anki-Android/blob/58341e381a5773dd86744fa2d549ffa4da226b50/.github/workflows/tests_emulator.yml#L80-L148
- caches / handles caching for emulator snapshots
- handles "no cache" / cold boot case by starting + warming up the emulator + then taking snapshot if needed
- starts emulator from snapshot (which is now guaranteed to exist)
- runs your thing (could be detox)
That's a pure Android project but we have run that workflow 11,399 times at last count (!) and it's mostly non-flaky / as fast as I know how to make it. It is not android 31/32/33 but the strategy should be sound, for starting up an emulator and having it be high-performance for use (because of the warmup) in the normal case.
I'll note that if you chose the ATD device types it should be that much faster, I haven't experimented with them much as they don't support firebase dynamic links and that's a requirement of mine so they are not as interesting to me. Possibly also of interest if people are testing these things - a gist that lays out an emulator performance testing framework, and has the results from last time I ran it, attempting to determine what was flaky what was not, what was fast, what was not https://gist.github.com/mikehardy/f076172f3b28826898c55dc03fe202de
@d4vidi @mikehardy I was able to use work around for using Android API 31 and above with Detox. So making emulator running before Detox as described in #3071 (see my update on https://stackoverflow.com/questions/73319635/how-to-configure-detox-to-be-able-to-use-android-emulator-running-already). But it requires also the 'adb reverse tcp:8081 tcp:8081' to hit the bundler as described in #2899. Is this the best work around for the #3560 at the moment? Of cource I would prefer getting official fix for this issue if it is released in near future?
I frequently need to do adb reverse without detox these days. Why? Unknown, but easy to script. I no longer carry any patches for detox vs official release personally
I landed the feature for reversing TCP ports into Detox 20 preview: Soon an alpha version will be released: 20.0.11-prerelease.0
, I guess.
Meanwhile, you could add await device.reverseTcpPort(8081)
right before your device.launchApp()
. 🤷 .
As for why it might happen more often, I have a theory or two:
- aside from the fact you have that problem, you often spawn clean devices (with no reversed port)
- the problem itself might be due to the altered default bundler URL: see how to change and also see the defaults for
localhost
:
- you might have something like
preferences.edit().putString("debug_http_host", "localhost:8081").apply();
in your Android native code and that it works worse than10.0.2.2:8081
(which automatically forwards everything to your localhost on Android emulators – contrary tolocalhost
where you need to reverse the ports)
😌 hope that helps
The problem is being investigated in https://github.com/wix/Detox/issues/3636