Reputation: 261
I turned off all animations on developer options. But I still get this exception when trying to click on one of the buttons.
My app is indeed active and not idle entirely, but I can't change it.
android.support.test.espresso.AppNotIdleException: Looped for 6930
iterations over 60 SECONDS. The following Idle Conditions failed .
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:580)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
Upvotes: 25
Views: 14700
Reputation: 28748
In my case I clicked "save" button running long request in a test. To complete the test I had to add idle()
after save() method. But often it was not enough, a loader continued drawing and the test failed. Then I increased a duration: idle(10000)
and got the error: androidx.test.espresso.AppNotIdleException: Looped for 238 iterations over 10 SECONDS. The following Idle Conditions failed DELAY_HAS_PAST.
.
I wrote: idle(5000)
. Instead of Espresso I use Kakao and Kaspresso.
Upvotes: 0
Reputation: 5780
In my case this problem was happening with AnimatedVectorDrawable
and caused by an objectAnimator
that was set to repeat the animation infinitely (android:repeatCount="infinite"
). .
The problem was also present only on older platform versions. Tests were perfectly working on Android 9 while the problem was reproducible on Android 5 and 6 (not sure about 7 and 8 at the moment).
I believe, the root cause of the problem is the same as for indeterminate progress bars (covered in this SO question). However, I haven't found any nice solution, only workarounds.
One of the workarounds is to detect that the animation is turned off (animator duration is 0) in the setting and don't start the animation. Of course, this only works for platform versions where the animation does not autostart.
private fun startIconAnimation(imageView: ImageView) {
if (areAnimationsEnabled()) {
(imageView.drawable as Animatable).start()
}
}
private fun areAnimationsEnabled(): Boolean {
val animatorDurationScale = Settings.Global.getFloat(
requireContext().contentResolver,
Settings.Global.ANIMATOR_DURATION_SCALE,
1.0f
)
return animatorDurationScale != 0.0f
}
Note: API level 26 introduced a static method ValueAnimator.areAnimatorsEnabled()
which would have been handy if the problem was not happening only on the older platform versions.
Upvotes: 2
Reputation: 482
I have been struggling with this problem for the last few days.
Here is a method that I used to identify "violators":
private void dumpThreads() {
int activeCount = Thread.activeCount();
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);
for (Thread thread : threads) {
System.err.println(thread.getName() + ": " + thread.getState());
for (StackTraceElement stackTraceElement : thread.getStackTrace()) {
System.err.println("\t" + stackTraceElement);
}
}
}
In my case, Facebook SDK was using the AsyncTask thread pool.
Upvotes: 5
Reputation: 5550
As per answer by MaciejGórski to the similar question:
It was a bug in my app code, where
SwipeRefreshLayout
animated itself indefinitely. Due to a bug in this component, the refresh state was not even showing.
Upvotes: 1