airbnb / lottie-ios

An iOS library to natively render After Effects vector animations
http://airbnb.io/lottie/
Apache License 2.0
25.76k stars 3.75k forks source link

Lottie Crash EXC_BAD_ACCESS #1926

Closed mihaicris-adoreme closed 1 year ago

mihaicris-adoreme commented 1 year ago

Which Version of Lottie are you using?

Lottie 4.1.0 (lottie-spm)

Expected Behavior

Animation to load

Actual Behavior

App is crashing

Code

private func setupWheelAnimation() {
       // CRASH ON NEXT LINE        Thread 1: EXC_BAD_ACCESS (code=1, address=0x1e) 
        animationView.animation = LottieAnimation.named("wheel_animation")
        animationView.loopMode = .loop
        animationView.play()
    }

Notes

Works as expected in Lottie 3.5.0

Animation JSON

{"v":"5.5.1","fr":23.9759979248047,"ip":0,"op":191.999983381819,"w":563,"h":598,"nm":"deal wheel (1)","ddd":0,"assets":[{"id":"image_0","w":56,"h":56,"u":"images/","p":"img_0.png","e":0},{"id":"image_1","w":35,"h":52,"u":"images/","p":"img_1.png","e":0},{"id":"image_2","w":501,"h":502,"u":"images/","p":"img_2.png","e":0},{"id":"image_3","w":526,"h":526,"u":"images/","p":"img_3.png","e":0}],"layers":[{"ddd":0,"ind":1,"ty":2,"nm":"inner button","refId":"image_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[281,316,0],"ix":2},"a":{"a":0,"k":[28,28,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":191.999983381819,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":2,"nm":"DIAL","refId":"image_1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":11,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":13,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":16,"s":[-45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":18,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":22,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":25,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":29,"s":[10]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":31,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":32,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":35,"s":[-100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":40,"s":[10]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":42,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":51,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":54,"s":[-90]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":56,"s":[-98]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":62,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":64,"s":[10]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":66,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":105,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":106,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":108,"s":[-62]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":109,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":111,"s":[-69]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":113,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":116,"s":[-61]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":118,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":123,"s":[-33]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":125,"s":[-110]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":132,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":134,"s":[-90]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":141,"s":[10]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":143,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":147,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":149,"s":[-90]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":155,"s":[10]},{"t":156.999986411175,"s":[0]}],"ix":10},"p":{"a":0,"k":[282.5,49,0],"ix":2},"a":{"a":0,"k":[17.5,26,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":191.999983381819,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":2,"nm":"spinner copy 5","refId":"image_2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.774],"y":[1.825]},"o":{"x":[0.613],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.14],"y":[1]},"o":{"x":[0.063],"y":[0.09]},"t":9,"s":[-14]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":83,"s":[279]},{"i":{"x":[0.703],"y":[1.667]},"o":{"x":[0.683],"y":[0]},"t":94,"s":[279]},{"i":{"x":[0.074],"y":[1]},"o":{"x":[0.072],"y":[0.052]},"t":102,"s":[265]},{"t":185.999983901137,"s":[720]}],"ix":10},"p":{"a":0,"k":[281.5,313,0],"ix":2},"a":{"a":0,"k":[250.5,251,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":191.999983381819,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":2,"nm":"purple outer circle","refId":"image_3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[281,315,0],"ix":2},"a":{"a":0,"k":[263,263,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"ip":0,"op":191.999983381819,"st":0,"bm":0}],"markers":[]}

calda commented 1 year ago

Can you share a sample project that reproduces this issue?

calda commented 1 year ago

Ah, I can reproduce this when running an app using lottie-spm on a physical device. Thanks for the report.

calda commented 1 year ago

Here's a fix: https://github.com/airbnb/lottie-spm/pull/5. We'll release 4.1.1 with this fix later today.

mihaicris-adoreme commented 1 year ago

Thanks, @calda !

mihaicris-adoreme commented 1 year ago

Tested version 4.1.1, still happening. :( DEBUG build, from Xcode, Device iPhone 12 Pro

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x00000001c2a871b4 in objc_opt_class ()
#1  0x00000001c39c2d54 in swift_getObjectType ()
#2  0x00000001137ff274 in ___lldb_unnamed_symbol8467 ()
#3  0x0000000100b23340 in NotificationsOnboardingViewController.setupWheelAnimation() 
#4  0x0000000100b23120 in NotificationsOnboardingViewController.viewDidLoad()
calda commented 1 year ago

Can you share a copy of a project that reproduces that issue? Are you embedding the Lottie framework in your app target?

Like this:

image
mihaicris-adoreme commented 1 year ago

Unfortunately I can't share the project.

mihaicris-adoreme commented 1 year ago
image
mihaicris-adoreme commented 1 year ago
image

Content of App application bundle

mihaicris-adoreme commented 1 year ago
image

Package dependency in Xcode

mihaicris-adoreme commented 1 year ago
image

Buiding with RELEASE mode reveals this error.

calda commented 1 year ago

I'm not able to reproduce this problem with the Example app in the lottie-spm repo, including when building to a physical device with a release configuration. Could you create a standalone sample Xcode project that reproduces this issue for you and share that sample project?

honkmaster commented 1 year ago

Maybe the crash of @mihaicris-adoreme is related to my reported issue. https://github.com/airbnb/lottie-spm/pull/5#issuecomment-1398991609

mihaicris-adoreme commented 1 year ago

Tested with non-SPM repo and 4.1.1 works fine. - I'll skip the xcframework version for the moment.

I was not able to reproduce with a blank project, although I tried, no crash, however the animation didn't even start. LottieAnimationView is there as a subview, but transparent. No errors in the console.

Maybe other users will reproduce and send a project sample.

mihaicris-adoreme commented 1 year ago

I am using Tuist to generate the project, maybe could be a reason, however, I have many other xcframework dependencies and no issues. (e.g. Firebase, etc)

SajjadKharrazi commented 1 year ago

i added lottie-spm repository with 4.1.1 version. i can run app in physical and simulator device in both Release and Debug env. but i cant archive my app and i get this error:

Screenshot 2023-01-21 at 19 20 45

i also deleted my DerivedData and problem still happens

calda commented 1 year ago

@SajjadKharrazi, can you test the potential fix I mentioned here: https://github.com/airbnb/lottie-spm/pull/5#issuecomment-1399026263? According to @honkmaster that change fixes a similar problem he was encountering.

SajjadKharrazi commented 1 year ago

yes it works

calda commented 1 year ago

Great! Will make this change and then probably release 4.1.2 on Monday

Jamonek commented 1 year ago

Thanks! This was driving me crazy haha

calda commented 1 year ago

Published lottie-spm 4.1.2 with a fix for this issue. Thanks for the report and working with us to find a solution!

mihaicris-adoreme commented 1 year ago

I confirm my issue is resolved with 4.1.2 Thanks!

Jaeki-Lee commented 7 months ago

I use lottie-ios (4.3.3) but it crush still please anyone help me It works when use code let lottie = LottieAnimationView() but storyboard property has the issue