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

Speed up unnecessarily and unintentionally slow waitForAnimationsToFinish calls #1301

Merged

Conversation

justinseanmartin
Copy link
Contributor

@justinseanmartin justinseanmartin commented Sep 5, 2024

We identified 3 issues where calls to waitForAnimationsToFinish would wait longer than we'd expect:

  1. We're traversing through hidden views, which will sometimes finds animations on elements that aren't visible on the screen.
  2. We're ignoring infinitely repeating animations, but not really long animations. In some cases this might be just a huge value that someone made up or it could be a slow animation. In either case, we probably don't want to wait for those to complete implicitly.
  3. The KIFTouchVisualizerView was added to show where touch events are happening, but they animate in a separate window and have an alpha fade for .75s. Every tap action then will wait for a minimum of .75s after the tap for that animation to complete, which was unintentional. Credit to @amorde for finding and testing this issue.

This does alter test timing slightly, and even if your code doesn't explicitly use waitForAnimationsToFinish, it is also called automatically called after UI actions, such as tapping the screen. If you have tweaked the timeouts to be faster and more aggressive, you might encounter some race conditions. You might be able to work around some of this temporarily by increasing the KIFTestStepDefaultAnimationStabilizationTimeout to .75s or 1s, but that will also slow down the execution of all of your tests (likely back to the speed before this change lands).

This change has turned up quite a few race conditions in our tests, but nothing that seemed like it wasn't something that shouldn't have more explicit validation of the screen state.

I recommend reviewing this with whitespace diffs ignored.

CC: @amorde @dnkoutso

justinseanmartin pushed a commit to justinseanmartin/KIF that referenced this pull request Sep 19, 2024
It doesn't really make sense that the default animation wait time
is the same as the stabilization time. This effectively means the
behavior of scanning the UI hierarchy for animations in progress is
never utilized for most tests out of the box.

For what its worth, we've used a 2s animation wait time and .1s
stabilization time as our defaults for a very long time.

This should generally not slow down any tests if there weren't any
animations in progress. If there were animations in progress, this
is probably a worthwhile tradeoff to make things more reliable. This
can still be configured globally to be overidden.

As part of this change, use `waitForAnimationsToFinish` in place of
a static .5s sleep for the `longPress` action.

There will be a followup PR kif-framework#1301 that should speed up some scenarios
where we're waiting longer than desired for animations to complete.
justinseanmartin pushed a commit to justinseanmartin/KIF that referenced this pull request Sep 19, 2024
It doesn't really make sense that the default animation wait time
is the same as the stabilization time. This effectively means the
behavior of scanning the UI hierarchy for animations in progress is
never utilized for most tests out of the box.

For what its worth, we've used a 2s animation wait time and .1s
stabilization time as our defaults for a very long time.

This should generally not slow down any tests if there weren't any
animations in progress. If there were animations in progress, this
is probably a worthwhile tradeoff to make things more reliable. This
can still be configured globally to be overidden.

As part of this change, use `waitForAnimationsToFinish` in place of
a static .5s sleep for the `longPress` action.

There will be a followup PR kif-framework#1301 that should speed up some scenarios
where we're waiting longer than desired for animations to complete.
@justinseanmartin justinseanmartin force-pushed the jmartin/long-animations branch 2 times, most recently from bd90a8f to 7e3217d Compare September 22, 2024 04:38
This was referenced Sep 23, 2024
Justin Martin added 2 commits September 23, 2024 16:12
Two changes:
* We won't recurse into layers that are hidden
* We don't count animations that run for longer than 1 minute
Credit to @amorde for finding this
@justinseanmartin justinseanmartin merged commit 8f094a6 into kif-framework:master Sep 24, 2024
5 checks passed
@justinseanmartin justinseanmartin deleted the jmartin/long-animations branch September 24, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants