LTMorphingLabel
LTMorphingLabel copied to clipboard
Crippled performance, sometimes crashing on longer strings
I've found that setting strings longer than about 50 characters crawls to a halt. Sometimes crashes. A simple fix would be to just not animate if the length is greater than a certain number. I attempted to do this by modifying the setter for the text variable, pausing the display link and setting super.text to the value if it was above a threshold. This sometimes works, but I think I'm missing something, as I still get issues with performance. Advice appreciated. Would love to use this in the next rev of Slated if I can get it reliable.
Yes, this operation has a performance issue.
func >>(lhs: String, rhs: String) -> Array<LTCharacterDiffResult>
I must solve it before adding support for multiline. But I'm not good at algorithm.
I'm not particularly great at this kind of thing either. I think a simple, quick fix could be possible, in just not animating the diffs after a certain number. In real usage, this may actually be the preferred way to go, as it could look messy animating hundred of characters, even if we get the performance perfect. What do you think, is there a simple way to just cut it off after a certain length (20 or so characters perhaps)?
It happens not only to long strings, but sometimes if many short strings appear in one controller as well.
I guess the latest Swift 1.2 comes with a lot of performance enhancements. Please try Xcode 6.3 Beta. https://github.com/lexrus/LTMorphingLabel/tree/swift1_2
I think the performance and crashing are just due to inherent design issues. I wish I understood the code enough to modify it. It's a really good effect when it works!
On Feb 12, 2015, at 12:19 AM, Lex Tang [email protected] wrote:
I guess the latest Swift 1.2 comes with a lot of performance enhancements. Please try Xcode 6.3 Beta. https://github.com/lexrus/LTMorphingLabel/tree/swift1_2
— Reply to this email directly or view it on GitHub.
:+1: UILabel is not designed to take long text. However what is long and not is defined by the use case of your App. Forcing a specific length would make this library unusable for many developers.
Instead I would make an effort to optimize the animation so that multiline and long text is not an issue for animation.