kf99916 / TimelineTableViewCell

Simple timeline view implemented by UITableViewCell
MIT License
1.32k stars 117 forks source link

Fatal error: Can't form Range with upperBound < lowerBound #19

Closed mhmmdmz closed 3 years ago

mhmmdmz commented 3 years ago

When running my app on smaller screens (iPod, iPhone SE, etc.) the pod crashes in TimelineTableViewCell.swift at line 101 with the fatal error:

Thread 1: Fatal error: Can't form Range with upperBound < lowerBound file Swift/x86_64-apple-ios-simulator.swiftinterface, line 14814

This is the code starting from line 101.

let views = viewsInStackView.count <= maxNumSubviews ? viewsInStackView : Array(viewsInStackView[0..<maxNumSubviews]) views.forEach { view in view.translatesAutoresizingMaskIntoConstraints = false view.addConstraint(NSLayoutConstraint(item: view, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: view, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant: 0)) view.contentMode = .scaleAspectFill view.clipsToBounds = true stackView.addArrangedSubview(view) }

viewsInStackView at this stage are 0, while the maxNumSubviews are -1. Hence the crash.

This is only seen on some devices, not all. Hence it is difficult to spot or reproduce. I have seen this on some iPhone 5s, iPhone SE and iPod Touch (7th Gen) so far.

Need a resolution really soon as many of my users can't use my app anymore.

kf99916 commented 3 years ago

Please try the possible fix at the master branch: https://github.com/kf99916/TimelineTableViewCell/commit/56dddbba2c3f1946b2dbb6e1c4d81a711aabff03 Let me know if you have any updates.

mhmmdmz commented 3 years ago

Thanks. This works. I can't be 100% sure because I personally can't reproduce the error all the time - I was able to only reproduce it on an iPod touch simulator and it seems to have fixed the issue. Once you update the Master, I'll update my app and keep you posted - unless, you have a way I could reproduce the error?

kf99916 commented 3 years ago

@mhmmdmz, thank you for your information. The issue will be closed first and the new version will be released. Let me know if it is not still fixed.