Espresso freezing on view with looping animation

后端 未结 1 946
感动是毒
感动是毒 2021-02-07 15:11

I have a view in which an element is animated with the following in an infinite loop:



        
相关标签:
1条回答
  • 2021-02-07 15:30

    Yes, the problem you are having with the test is due to the animation.

    The only solution I can think of is indeed to turn off the infinite animations.

    In general it is a good idea to turn off animations when running functional tests, as they always introduce some flakiness.

    A bit of background:

    The UI thread is never idle from Espresso's perspective, because the message queue always contains an event that is scheduled for handling closer than the threshold used to determine if thread is idle.

    When you look at QueueInterrogator, you can see that it's determineQueueState() returns TASK_DUE_SOON when message queue contains an event that is scheduled for handling in less than 16ms. UiController will only continue execution when all idle conditions are fulfilled, in case of the QueueInterrogator this is only the case if the message queue is empty or the next message is scheduled for handling in 16ms or later.

    Animations will invalidate the View they are transforming, and this will trigger a new view hierarchy traversal by the Choreographer. And this trigger message coming from ViewRoot to the Choreographer is what is keeping your UI thread message queue not idle.

    0 讨论(0)
提交回复
热议问题