Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idling Resources issue: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [ComposeIdlingResource] to become idle timed out #1

Closed
RivuChk opened this issue Jun 21, 2020 · 9 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@RivuChk
Copy link
Owner

RivuChk commented Jun 21, 2020

UI Tests, interacting with CircularProgressIndicator and AdapterList are failing with androidx.test.espresso.IdlingResourceTimeoutException: Wait for [ComposeIdlingResource] to become idle timed out
The tests failing are marked with @Ignore for the time being, can be found at app/src/androidTest/java/dev/rivu/mvijetpackcomposedemo/MovieAppUITests.kt
Stacktrace:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [ComposeIdlingResource] to become idle timed out
	at androidx.test.espresso.Espresso.onIdle(Espresso.java:342)
	at androidx.test.espresso.Espresso.onIdle(Espresso.java:361)
	at androidx.ui.test.android.SynchronizedTreeCollector.waitForIdle$ui_test_release(SynchronizedTreeCollector.kt:70)
	at androidx.ui.test.android.SynchronizedTreeCollector.collectAllSemanticsNodes$ui_test_release(SynchronizedTreeCollector.kt:51)
	at androidx.ui.test.FindersKt.getAllSemanticsNodes(Finders.kt:94)
	at androidx.ui.test.SemanticsNodeInteraction.fetchSemanticsNodes$ui_test_release(SemanticsNodeInteraction.kt:53)
	at androidx.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:116)
	at androidx.ui.test.SemanticsNodeInteraction.fetchSemanticsNode(SemanticsNodeInteraction.kt:72)
	at androidx.ui.test.AssertionsKt.checkIsDisplayed(Assertions.kt:295)
	at androidx.ui.test.AssertionsKt.assertIsDisplayed(Assertions.kt:64)
	at dev.rivu.mvijetpackcomposedemo.MovieAppUITests.test_list_state(MovieAppUITests.kt:97)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:531)
	at androidx.ui.test.android.AndroidComposeTestRule$AndroidComposeStatement.evaluate(AndroidComposeTestRule.kt:167)
	at androidx.ui.test.AnimationClockTestRule$AnimationClockStatement.evaluate(TestAnimationClock.kt:130)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
	at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2206)
Caused by: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [ComposeIdlingResource] to become idle timed out
	at java.util.concurrent.FutureTask.report(FutureTask.java:123)
	at java.util.concurrent.FutureTask.get(FutureTask.java:193)
	at androidx.test.espresso.Espresso.onIdle(Espresso.java:334)
	... 42 more
Caused by: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [ComposeIdlingResource] to become idle timed out
	at androidx.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:61)
	at androidx.test.espresso.base.UiControllerImpl$5.resourcesHaveTimedOut(UiControllerImpl.java:434)
	at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleTimeout(IdlingResourceRegistry.java:481)
	at androidx.test.espresso.base.IdlingResourceRegistry$Dispatcher.handleMessage(IdlingResourceRegistry.java:414)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at androidx.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:148)
	at androidx.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:525)
	at androidx.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:447)
	at androidx.test.espresso.Espresso$1.run(Espresso.java:324)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at android.os.Handler.handleCallback(Handler.java:907)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:216)
	at android.app.ActivityThread.main(ActivityThread.java:7506)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:956)

While it's waiting for the idling resources, you can see in the attached screenshot, the expected UI is already showing in the emulator.
Screenshot 2020-06-21 at 8 32 50 PM

@RivuChk RivuChk added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Jun 21, 2020
@RivuChk
Copy link
Owner Author

RivuChk commented Jul 1, 2020

Issue persists with new LazyColumnItems as well.

@RivuChk
Copy link
Owner Author

RivuChk commented Jul 1, 2020

Tried calling waitForIdle, even though it's not needed, since Compose calls it internally whenever you call something like findByTag or findBySubstring. Used Modifier.testTag in the CircularProgressIndicator and tried that with LazyColumnItems as well, the same result.
suspected LiveData earlier, so I tried setting value, instead of postValue, but it got an error, saying something like 'can't set value from background thread', so I tried using runOnUIThread, and FrameManager.framed but got no luck there as well.
With FrameManager.framed getting Cannot invoke setValue on a background thread (I tried calling setValue as with postValue it was all the same)
With runOnUiThread The value gets posted, I can see the UI change in the emulator, but still getting IdlingResourceTimeoutException: Wait for [ComposeIdlingResource] to become idle timed out after a while.

@RivuChk
Copy link
Owner Author

RivuChk commented Jul 1, 2020

As I believe this might be a bug, created an issue here: https://issuetracker.google.com/issues/160259537, if you agree, please upvote

@JoseAlcerreca
Copy link

Not a bug on the Compose side. Added some findings to https://issuetracker.google.com/issues/160259537 that should be enough to close this issue.

@RivuChk
Copy link
Owner Author

RivuChk commented Jul 6, 2020

Thanks, I've looked into the status update and trying those right now. Thanks for being so helpful and awesome, and also for the awesome work. I'll work on the things mentioned by you.

@RivuChk
Copy link
Owner Author

RivuChk commented Jul 6, 2020

I'll close this issue here, once I have a fix ready from my side though. when I first opened this issue I didn't think it was from Compose side.

@RivuChk RivuChk closed this as completed in f367fcc Jul 6, 2020
@RowickaM
Copy link

@RivuChk could you present what was wrong?

@hosseinaminii
Copy link

When I use BottomSheetScaffold this error occurs, any suggestions?

@RivuChk
Copy link
Owner Author

RivuChk commented Sep 17, 2022

The fix is here: f367fcc
The issue described here: https://issuetracker.google.com/issues/160259537?pli=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants