Bad performance when testing an Android React Native application with running animations
If you are testing a React Native Android application which involves animations running, this can have a drastic impact on record and replay performance. To understand and resolve this issue, you will need to understand the sync mechanisms in use.
There are two types of synchronization mechanisms active when testing mobile on Android:
- The ‘waitForIdle’ sync of UIAutomator2 (this is running on the Android device)
- The Silk Test sync (this is running on the Open Agent)
While the waitForIdle sync waits until no window messages are received any more for a certain amount of time (typically 500ms), the Silk Test sync captures mobile device hierarchies until they do not change anymore (also for a specified amount of time).
Within the React apps where an animation is running, UIAutomator2 waitForIdle sync does not become idle because there are always new window messages (because of the animations). With the capability disableAndroidWaitForIdle=true, you can turn off the waitForIdle sync completely. However, this capability only affects the sync that is running on the Android device.
To use this functionality, you can set this within your connectionString.
sConnectionString = “deviceName=Nexus 7;platformName=Android; disableAndroidWaitForIdle=true;app=C:\MyMobileApps\ReactAnimation.apk”
The Silk Test sync would wait by default up to 10 seconds until it gives up and declares a hierarchy as idle. If you change the OPT_SYNC_TIMEOUT, you can only influence the Silk Test sync to become idle earlier.
The recommended approach would be to use the disableAndroidWaitForIdle capability to work-around the UIAutomator2 issue first. This should in theory not lead to any failing tests. In order to speed test runs up, you could play around with the OPT_SYNC_TIMEOUT (i.e. decrease it and check if tests are still running stable).
In some situations, it may require a combination of both the disableAndroidWaitForIdle and Sync Timeout settings.