LTMorphingLabel icon indicating copy to clipboard operation
LTMorphingLabel copied to clipboard

Crippled performance, sometimes crashing on longer strings

Open alariccole opened this issue 11 years ago • 6 comments
trafficstars

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.

alariccole avatar Nov 13 '14 19:11 alariccole

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.

lexrus avatar Nov 17 '14 05:11 lexrus

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)?

alariccole avatar Nov 17 '14 19:11 alariccole

It happens not only to long strings, but sometimes if many short strings appear in one controller as well.

eriktelepovsky avatar Nov 18 '14 09:11 eriktelepovsky

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

lexrus avatar Feb 12 '15 08:02 lexrus

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.

alariccole avatar Feb 12 '15 16:02 alariccole

:+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.

artworkad avatar Apr 28 '15 13:04 artworkad