lottie-android: StackOverflowError on some devices when using AnimatorListener

This bug occurs only on some devices. I can’t reproduce it on my devices, but I see it in crash reports.

java.lang.StackOverflowError: 
  at com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation.setProgress (BaseKeyframeAnimation.java:54)
  at com.airbnb.lottie.animation.keyframe.TransformKeyframeAnimation.setProgress (TransformKeyframeAnimation.java:124)
  at com.airbnb.lottie.model.layer.BaseLayer.setProgress (BaseLayer.java:519)
  at com.airbnb.lottie.model.layer.CompositionLayer.setProgress (CompositionLayer.java:147)
  at com.airbnb.lottie.LottieDrawable$1.onAnimationUpdate (LottieDrawable.java:74)
  at com.airbnb.lottie.utils.BaseLottieAnimator.notifyUpdate (BaseLottieAnimator.java:88)
  at com.airbnb.lottie.utils.LottieValueAnimator.setFrame (LottieValueAnimator.java:159)
  at com.airbnb.lottie.utils.LottieValueAnimator.playAnimation (LottieValueAnimator.java:208)
  at com.airbnb.lottie.LottieDrawable.playAnimation (LottieDrawable.java:420)
  at com.airbnb.lottie.LottieAnimationView.playAnimation (LottieAnimationView.java:549)
  at com.myetherwallet.mewwalletui.feature.main.util.LottieHelper$Companion$loopSegment$1.onAnimationEnd (LottieHelper.kt:86)
  at android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:552)
  at com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
  at com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
  at com.airbnb.lottie.LottieDrawable.playAnimation (LottieDrawable.java:424)
  at com.airbnb.lottie.LottieAnimationView.playAnimation (LottieAnimationView.java:549)

Device list:

Sony Xperia XZ3 (SOV39), 3840MB RAM, Android 9
Motorola Moto X (4) (payton), 2816MB RAM, Android 9
Huawei HUAWEI Y9 Prime 2019 (HWSTK-HF), 3840MB RAM, Android 10
Samsung Galaxy S8 (dreamlte), 3840MB RAM, Android 9
Xiaomi MI 8 Lite (platina), 3840MB RAM, Android 9
ZTE Z717VL (lavender), 1024MB RAM, Android 9
Samsung Galaxy S10 5G (beyondx), 7424MB RAM, Android 10

Bug was occured several times on each device from this list.

I replaced onAnimationEnd with Handler.postDelayed and handle animation end by time. It works well on all of devices. But this is not a correct way.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 19

Most upvoted comments

I’m facing the same error.

For those who want an easy way to overcome this, you can just make Lottie ignore this setting completely, using setIgnoreDisabledSystemAnimations(true) in code, or app:lottie_ignoreDisabledSystemAnimations="true" in XML.

I had this issue in production on a handful of users when using an onAnimationListener which was changing the progress of the animation. The users had the OS settings ‘remove animations’ set to true and this is how I could replicate the issue. It’s causing the animation to terminate immediately and call the animation again and again and again

It looks like you all are using onAnimationEnd to restart the animation. Are you trying to achieve looping? If so, Lottie has the ability to loop built in. If you would like to detect when animations are disabled and do something different, you can detect it the same way Lottie does: https://github.com/airbnb/lottie-android/blob/master/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java#L261