-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
LottieAnimationView layout stuck in infinite loop #2310
Comments
Can you share a sample project that demonstrates this issue? |
There seems to be an issue when you have a container view for it. let animationView = LottieAnimationView(name: "loader")
containerView.addSubview(animationView)
animationView.translatesAutoresizingMaskIntoConstraints = false
containerView.addConstraints(NSLayoutConstraint.constraints(
withVisualFormat: "V:|-(0)-[contentView]-(0)-|",
options: NSLayoutConstraint.FormatOptions.alignAllLastBaseline,
metrics: nil,
views: ["contentView": animationView]
))
containerView.addConstraints(NSLayoutConstraint.constraints(
withVisualFormat: "H:|-(0)-[contentView]-(0)-|",
options: NSLayoutConstraint.FormatOptions.alignAllLastBaseline,
metrics: nil,
views: ["contentView": animationView]
))
animationView.backgroundBehavior = .pauseAndRestore
animationView.viewportFrame = animationView.bounds
animationView.loopMode = .loop
animationView.play() |
This appears to be because you're setting I don't think that line is necessary -- if I remove it, your demo runs correctly. However, this infinite loop happens any time |
Here's a fix: #2316 |
Which Version of Lottie are you using?
Lottie 4.3.0
Expected Behavior
App does not get stuck
Actual Behavior
App is stuck in an infinite loop.
There was a bug introduced in commit ecdadec where the function
layoutAnimation
inSources/Public/Animation/LottieAnimationView.swift
callssetNeedsLayout
from within a layout function. This causes the layout function to be called again on the next runloop, and again and again repeatedly, causing the UI thread to freeze. I believe removing this line will fix the issue.The text was updated successfully, but these errors were encountered: