Detox: V18 hangs on main thread when unresolved promise
Description
We have a Promise that waits for confirmation result from a dialog. This use to work fine with v17, but on v18 synchronization is waiting for all promises to complete, causing a deadlock.
I tried to disable synchronization but it seems that it isn’t supported with v18
Reproduction
Provide the steps necessary to reproduce the issue. If you are seeing a regression, try to provide the last known version where the issue did not reproduce.
- Create a promise that only resolves once onClick of button or view has been tapped
Expected behavior
promises on main thread should not wait for synchronization (as with v17) or we need to have a way to disable synchronization for main thread.
Environment (please complete the following information):
- Detox: 10.1.0
- React Native: 0.63.3
- Node: v15.4.0
- Device: iPhone 8 Plus
- Xcode: 12.3
- iOS: 14.2
- macOS: 11.1
Logs
detox[11736] INFO: [actions.js] The system is busy with the following tasks:
Dispatch Queue
⏱ Queue: “Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)” with 1 work blocks
Run Loop
⏱ “Main Run Loop”
UI Elements
⏱ 0 layer animations pending
detox[11736] INFO: [actions.js] The system is busy with the following tasks:
Dispatch Queue
⏱ Queue: “Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)” with 1 work blocks
Run Loop
⏱ “Main Run Loop”
UI Elements
⏱ 0 layer animations pending
detox[11736] INFO: [actions.js] The system is busy with the following tasks:
Dispatch Queue
⏱ Queue: “Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)” with 1 work blocks
Run Loop
⏱ “Main Run Loop”
UI Elements
⏱ 0 layer animations pending
detox[11736] INFO: [actions.js] The system is busy with the following tasks:
Dispatch Queue
⏱ Queue: “Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)” with 1 work blocks
Run Loop
⏱ “Main Run Loop”
UI Elements
⏱ 0 layer animations pending
detox[11736] DEBUG: [exec.js/EXEC_SUCCESS, #16] Matched Finger!
detox[11736] INFO: [actions.js] The system is busy with the following tasks:
Dispatch Queue
⏱ Queue: “Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)” with 1 work blocks
Run Loop
⏱ “JS Run Loop”
⏱ “Main Run Loop”
One Time Events
⏱ “Runloop Perform Block” with object: “JS Run Loop”
⏱ “Runloop Perform Block” with object: “JS Run Loop”
⏱ “Runloop Perform Block” with object: “JS Run Loop”
⏱ “Runloop Perform Block” with object: “JS Run Loop”
⏱ “Runloop Perform Block” with object: “JS Run Loop”
⏱ “Runloop Perform Block” with object: “JS Run Loop”
If you are experiencing a timeout in your test
- I have followed the instructions under Lower-level Idling Resources Debug and am providing the log below:
Device and verbose Detox logs
- I have run my tests using the
--loglevel trace
argument and am providing the verbose log below:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (13 by maintainers)
@jkhusanov FYI when running with Detox’s
debug-synchronization
feature enabled (on by default), you should be able to get specific logs telling you what’s holding the app back from going idle - so as to save your time on inspecting whether these are animations or network calls that are behind it.Just documenting here - my problem causing “The system is busy with the following tasks” was not awaiting
device.launchApp()
in the tests file. Fixed like this:As I said, Detox has no awareness of your JS code, such as promises. If the log says later animation, that’s what it is.
@LeoNatan Thanks for pushing me in the right direction, after investigating deeper i realized that we show a spinner on the button when submitting, I couldn’t see it because it was rendered underneath the modal. Switching this animation off for Detox builds have resolved the issue. Thanks for the help!
“ ⏱ 0 layer animations pending”
While the “0” is incorrectly reported, and has already been fixed in master, it looks like you have an infinite animation, likely from a spinning activity indicator view.
You should either mock or disable infinite animations for tests.