badoo / Chatto

A lightweight framework to build chat applications, made in Swift
MIT License
4.49k stars 596 forks source link

Improve performance by removing Blended Layers #54

Open ogres opened 8 years ago

ogres commented 8 years ago

Hello,

Currently the TextBubbleView instances have clear background color, if you check device with "Color Blended Layers" option, you will see the red area around the messages,

First fix would be to update the background view ( and background view of the subviews , because otherwise textView still has non-opaque subviews ) of the TextBubbleView with the same color as the message container has itself.

This will change from this simulator screen shot mar 9 2016 5 35 04 pm

To this simulator screen shot mar 9 2016 5 33 33 pm

There is still red area in the TextBubbleView container view, because it has rounded-rect/image with alpha, to go further and fix them, I`d suggest to use stretchable background image with no alpha, so the background color of the image = background color of the collectionView, then you can put the stretchable bubble image on this background and create a new image without an alpha , which then will be used as a background of the CollectionViewCell.

diegosanchezr commented 8 years ago

Hi @ogres. Thank you very much for showing this up. The current frame rate is pretty good, 58-60 fps on iPhone 4s; did you see any improvements?

Regarding the alpha-channel in the background image, we should keep it in the framework as it allows different background colors. If someone wants to avoid the blending then they should provide their custom style with the opaque images at the app level.

Regarding the text bubble blending, I totally support your solution. Would you be keen to make a PR?

Thanks again!

ogres commented 8 years ago

Thanks for your response @diegosanchezr , I do not have 4s/iPod with me at the moment to check the actual FPS, it was a suggestion, but I will be able to test it in following days

ogres commented 8 years ago

I have tried both but did not see any significant changes, I was also wondering about pre-calculating the NSAttributedString with data-detector enumeration instead of assigning the text and letting the textview always detecting them from the scratch, what do you think ?

diegosanchezr commented 8 years ago

I haven't looked into that tbh, but I guess you have to let UITextView do its magic as it's responsible for triggering the actions (open calendar, Safari, phone call, etc) when you press on the links.