Lottie-ios: Animation is played when the user goes back to ViewController from another ViewController

Created on 16 May 2019  路  5Comments  路  Source: airbnb/lottie-ios

Check these before submitting:

  • [x] The issue doesn't involve an Unsupported Feature
  • [x] This issue isn't related to another open issue

This issue is a:

  • [x] Non-Crashing Bug (Visual or otherwise)
  • [ ] Crashing Bug
  • [ ] Feature Request
  • [ ] Regression (Something that once worked, but doesn't work anymore)

Which Version of Lottie are you using?

Lottie 3.0.6 (freshly downloaded from the github page)

What Platform are you on?

  • [ ] MacOS
  • [x] iOS

What Language are you in?

  • [x] Swift
  • [ ] Objective-C

Setup

To recreate this issue please add NavigationController and connect two ViewControllers to it. First VC should have two buttons:

  1. Taping the first button should trigger the animation.
  2. Taping on the second button should move the user to the second VC.

Second VC can be left empty. We need it only to move to it, and then go back to the first one.

Expected Behavior

  • As a user, on the first VC I tap the first button which triggers the animation - Animation is played.
  • I tap the second button - I am taken to the second VC.
  • On the second VC, I tap "<" icon on the left side of the navbar - I am taken back to the first VC.
  • The animation is not played as long as I don't tap the first button responsible for triggering the animation.

Actual Behavior

  • As a user, on the first VC I tap the first button which triggers the animation - Animation is played.
  • I tap the second button - I am taken to the second VC.
  • On the second VC, I tap "<" icon on the left side of the navbar - I am taken back to the first VC.
  • When I am back on the first VC, the animation is played again. I did not tap the button nor the breakpoint on the said button was triggered. The animation seems to be started by itself.

Animation JSON

I've reproduced this issue on Lottie Example downloaded straight from the github page.
I've only added NavigationController, empty ViewController and two buttons (for starting animation and moving to the second ViewController).

Most helpful comment

I have the same issue as @JanSzala.

All 5 comments

Try setting the BackgroundBehavior of the animation view.

https://github.com/airbnb/lottie-ios/blob/master/README.md#background-behavior

Hello Buba447,
Thanks for your reply and sorry I haven't answered you earlier. I've set BackgroundBehavior but it didn't work. I've modified the example project, so you can check out how the issue works:

  1. Run the example project.
  2. Tap "Start animation" button and wait for "Animation Complete" message to appear in the console.
  3. When the message was presented, tap "Show next VC" button.
  4. Tap the "Back" button on the navigation bar.
  5. The animation is started once again, even though it was not manually stared.

My colleague found out that setting the animation progress in the completion solves the problem, but in my opinion, it shouldn't be necessary.


Here is repo with the modified example project:
https://github.com/JanSzala/lottie_issue

I have the same issue as @JanSzala.

I have found a fix for this bug here https://github.com/airbnb/lottie-ios/pull/926
Please pull and verify it works.

Thanks for bringing this to my attention!

Hey @buba447, now it works perfectly thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

albertoNovo picture albertoNovo  路  3Comments

WZBbiao picture WZBbiao  路  5Comments

whisterlee picture whisterlee  路  3Comments

amannayak0007 picture amannayak0007  路  3Comments

Mushrankhan picture Mushrankhan  路  4Comments