optonaut / ActiveLabel.swift

UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift
MIT License
4.47k stars 686 forks source link

Poor performance inside UITableViewCell #251

Closed daurenm closed 6 years ago

daurenm commented 6 years ago

Hi there,

Seems like the pod does too many things in the main thread, blocking it.

screen shot 2018-03-31 at 2 22 12 pm

Here is code:

// cell for row uses this method to update text
func updateText(_ text: String) {
    let userName = "daurenmuratov"
    let comment = "@\(userName):"
        + (" \(text)")
    textView.text = comment
}

// initializing ActiveLabel
lazy var textView: ActiveLabel = {
    let al = ActiveLabel()
    al.customize({ (label) in
        label.numberOfLines = 0
    })
    return al
}()

Here is the same text:

Some dummy #long long text here www.aksdha.com sjhda shd #jshd jashd jahsd @jashd jashd www.jashd.com jahsdjahs djahsjd ahsjd ahjs dahjs dajshd jahsd jahs jdah jdsahj @das

Is there anything can be done with that? :)

maziyarpanahi commented 6 years ago

Hi @daurenm,

May I know a bit more about your spec? iOS version, Swift version, and device you are trying it (simulator or real). Also, by poor performance, you mean laggy when you are scrolling or just concern that the majority of CPU goes to draw ActiveLabel inside the cell?

As a test, I built this app and tested with iPhone 6s Plus (not really recent device). You can give it a try, you know where the ActiveLabel is when you see them. (Keep in mind the loading remote images and other objects inside the cells). [url removed]

PS: I remove the link after you tested to avoid self advertising even though the whole thing is french so probably useless outside France :)

daurenm commented 6 years ago

hi @maziyarpanahi,

This app is laggy. I don't know for sure if it's due to activeLabel itself, or something totally different :(

maziyarpanahi commented 6 years ago

Hi @daurenm, By this app you mean the one in the link or your own app? Cause I checked mine for performance and it is not laggy. What is your test device? And can you provide the code inside cellForRowAt pr other delegations if you change any heights?