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
lottie crashed in AnimationContainer.init() on iOS9 device when used Xcode11.4 #1155
Comments
Same for me, only iOS 9 devices will crash, the same code on Xcode 11.3 is OK.
|
The example project in the repo can reproduce the crash, with Xcode 11.4 on an iOS 9 device. Change the deployment target to 9.0 first. |
Same for me |
Can confirm this problem on iOS 9 with Xcode 11.4 as well. Enabling Zombie Objects in Xcode 11.4 results in the following output before crashing the application: |
Same problem here. I blame the changed embedding of frameworks in Xcode 11.4. Downgraded to Xcode 11.3 for now and waiting for Apple to fix the embedding of frameworks. |
@brunsman Do you have more details on what the change in embedding of frameworks entails? |
After digging into the issue more, I can now isolate the issue to something else. Will post the same here for reference, see https://forums.developer.apple.com/thread/131551 The code seems related to Xcode 11.4, ios 9 devices, and custom CALayers with properties. To see this problem, Create an extension of an CALayer:
Now programmatically create such a layer, e.g. in a viewDidLoad
Compile and run this on a iOS 9 device (my tests were with an iPhone 4S with iOS 9.3.6). The device crashes when initializing the layer. It is deallocated BEFORE it can actually set the property on the customLayer. Enable zombies for a more detailed stack trace. Since lottie uses custom CALayers with properties, it now crashes on iOS 9 devices when using Xcode 11.4. Hoping for a fix or workaround from Apple. Filed a bug report about it. |
Great work @brunsman ! Looking forward to hearing the about the response. |
@brunsman I tried to circumvent the initializer of
#import <QuartzCore/QuartzCore.h>
NS_ASSUME_NONNULL_BEGIN
@interface CALayer (Init)
+(instancetype)newInstance;
@end
NS_ASSUME_NONNULL_END
#import "CALayer+Init.h"
@implementation CALayer (Init)
+(instancetype)newInstance {
return [[CALayer alloc] init];
}
@end Making use of the class method in this category seems to work. class CustomLayer: CALayer {
var someProperty: CGFloat = 0
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let customLayer = CustomLayer.newInstance() // this seems to work
let customLayer2 = CustomLayer() // <- this still crashes
view.layer.addSublayer(customLayer)
view.layer.addSublayer(customLayer)
}
} Edit: Unfortunately, trying to access the property on Interestingly, changing the property to be a class CustomLayer: CALayer {
let someProperty: CGFloat = 0
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let customLayer = CustomLayer()
view.layer.addSublayer(customLayer)
}
} |
@hakonk If you find a workaround, that would be great! So far, no dice. Edit: XCode 11.4.1 also does not fix this issue. Still waiting for a response from Apple. |
@brunsman The approach above with the Objective-C category is flawed for sure. My colleagues have pointed me in the direction of reading up on I attempted to make use of Objective-C's runtime capabilities (associated objects) to implement a property on a subclass of class CustomLayer: CALayer {
private static var somePropertyHandle = 0
var someProperty: CGFloat {
get {
guard let val = objc_getAssociatedObject(
self,
&CustomLayer.somePropertyHandle
) as? CGFloat else { fatalError("No obj found") }
return val
}
set {
objc_setAssociatedObject(
self,
&CustomLayer.somePropertyHandle,
newValue,
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC
)
}
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let customLayer = CustomLayer()
// needs to be assigned, or else the computed property logic will crash
customLayer.someProperty = 123
print(customLayer.someProperty)
view.layer.addSublayer(customLayer)
}
} While it works, it's a cumbersome and somewhat hacky approach for just implementing a simple property. |
Reported the bug to apple on the 15th of april. Got an update from Apple:
Hoping for this best and that the new xCode will fix the problem... |
XCode 11.5 GM is out and the release notes state:
Is it the bug we are hunting? Many thanks |
@falcon283 @brunsman |
Thanks a lot for the feedback @hakonk |
It looks like the issue is still present in the latest Xcode 11.6 beta (11N700h). |
This is so bad :( |
Hii, For the moment the only solution to fix the issue is to rollback to Xcode 11.3 ? Thank you |
I have tried downgrading to Lottie 2.5.3, which is written in Objective-C. This works without crashes with Xcode 11.5. As @brunsman pointed out, the issue seems to be related to properties on subclasses of |
Yes,It's work. |
Did anyone try testing with Xcode 12 beta? |
@caioremedio When testing on iOS 9 with a 32 bit device, I'm still getting the crashes, even with Xcode 12. I've sent them a report with Feedback assistant, but I haven't gotten a reply. @brunsman Did you get a reply from Apple? |
No.... and Apple even reverted the resolution from "Potential fix identified - For a future OS update" to "Open". I doubt they will ever fix this... I stopped using Lottie on iOS < 11. |
Wow, that's a bummer, @brunsman! Anyway, it's interesting to know that the issue is still open. |
xcode 12.0.1 still crash !!!!!!!!!! |
How to fix this? |
xcode 12.1 still crash |
Maybe it is time to consider dropping support for iOS9 in your app. |
same to me. xcode 12.0 |
Xcode 12.3 still crash. 😥 |
I switched to a gif animation in Kingfisher's AnimatedImageView only on iOS9 instead of lottie's way . |
From Apple:
I haven't tested whether this works since we stopped using iOS 9. Perhaps it can be used by others. |
也许用OC实现CALayer的子类,Swift中使用,iOS10以上就不用这样了 |
use xib crah, need code xcode 12.3 ios9 lottie 3.2.1 |
anything new? |
Closing since Lottie no longer supports iOS 9 (the minimum deployment version is now iOS 11) |
When I compiled and ran with the latest version of Xcode 11.4, there was a crash anywhere I used Lottie on iOS 9 devices
Check these before submitting:
This issue is a:
Which Version of Lottie are you using?
Lottie 3.1.6
What Platform are you on?
What Language are you in?
Expected Behavior
Actual Behavior
Code Example
Animation JSON
The text was updated successfully, but these errors were encountered: