setInterval in ReactNative app forces me to wait a lot of time to find any element

I’m automating React Native app with python client and having trouble with Javascript’s setInterval.
When I use setInterval on a page, Appium takes a very long time to find any element on that page regardless of which locator I use.
For example, it takes 10000ms to find by accessibility ID while setInterval exists, but it become 200ms if I remove setInterval.

How can I avoid this behavior without quitting using setInterval on app side.
It’s the only issue on Android app and nothing problematic on iOS app.

  • Platform you are automating (iOS or Android): Android (React Native)
  • Appium version: v1.19.0
  • Simulator/Emulator or Real Device: Both
  • The language you are using for writing tests (client binding): Python
  • Your OS: macOS 10.15.7

Most likely the usage of this API incorrectly affects the main UI thread preventing it from switching to the idle state. I would try to report that to React as a bug. Although, if your interval value is short then the described behaviour is expected. UiAutomator cannot perform its action if the app UI thread is not idling.

Thank you for your quick response.
It’s 500ms.
Just FYI: This is the code uses setInterval.

Then the behaviour above is expected. Check for possible workarounds

This worked. Thank you!

self.driver.update_settings({"waitForIdleTimeout": milliseconds})