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.
I'm facing the same error.
I also encountered this problem in version 3.4.0. And the logs are as follows.
Fatal Exception: java.lang.StackOverflowError
stack size 8192KB
java.lang.ThreadLocal.get (ThreadLocal.java:161)
android.view.Choreographer.getInstance (Choreographer.java:300)
com.airbnb.lottie.utils.LottieValueAnimator.removeFrameCallback (LottieValueAnimator.java:275)
com.airbnb.lottie.utils.LottieValueAnimator.removeFrameCallback (LottieValueAnimator.java:270)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:216)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$innerChangeState$1.onAnimationEnd (CarStateBgAnimView2.java:217)
android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
com.airbnb.lottie.utils.BaseLottieAnimator.notifyEnd (BaseLottieAnimator.java:73)
com.airbnb.lottie.utils.LottieValueAnimator.endAnimation (LottieValueAnimator.java:217)
com.airbnb.lottie.LottieDrawable.resumeAnimation (LottieDrawable.java:455)
com.airbnb.lottie.LottieAnimationView.resumeAnimation (LottieAnimationView.java:563)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2.innerChangeState (CarStateBgAnimView2.java:318)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2.access$innerChangeState (CarStateBgAnimView2.java:20)
com.niu.cloud.main.niustatus.view.CarStateBgAnimView2$retryInitAnim$task$1.run (CarStateBgAnimView2.java:349)
android.os.Handler.handleCallback (Handler.java:888)
android.os.Handler.dispatchMessage (Handler.java:100)
android.os.Looper.loop (Looper.java:213)
android.app.ActivityThread.main (ActivityThread.java:8178)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)
I have the same problem. did you find a solution?
have the same bug
have the same bug in 3.4.0 . any solutions?
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 10Bug 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.
Do you use an Android timer instead? Why is it not the correct way?
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
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
Did you resolve that?
Yes, I changed the way I am using the listener so I wouldn't repeat the animation definitely
Yes, I changed the way I am using the listener so I wouldn't repeat the animation definitely
Do you use an Android timer instead? Could you share the solution?
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
It looks like you all are using
onAnimationEndto 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
In some cases, we need to replace the lottie each time it loops. I tried to use OS timer, it helps to fix this issue. Should contributors to this repo concern to update this?
@huynguyennovem What would the correct behavior be? If you call playAnimation() with animations disabled, Lottie jumps to the end and calls onAnimationEnd() which, to me, seems like the correct behavior. If Lottie were to delay the end call by a frame then you would just see the animation loop through a different animation on each frame which solves the crash but is a completely undesirable user experience.
In my opinion, the best thing to do here would be to check for this case and come up with what you want the behavior to be in your app.
I'm going to close this for now unless there is an explicit behavior change that Lottie could implement that would solve this without other consequences.
Hi!
Info here helps. Just posting a runnable on the view instead of direct calling startAnimation fixes the issue for us.
What I don't get is why close this, behavior of the new version is different compared to the old one and it behaves differently when using public apis (which addAnimatorListener and onAnimationEnd definitely are)? So basically new version breaks the contract that old version set and people were counting on it working certain way.
Having in mind that this is dependent on kind of obscure Accessibility setting I guess it is reasonable to guess that a lot of people might get to this issue only once app is in production.
What was the previous logic used pre 3.4.0 version regarding this part, was there posting of runnable inside the lib or some other approach was used to avoid endless recurrent calls?
Most helpful comment
I'm facing the same error.