ekazaev / ChatLayout

ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView. It supports dynamic cells and supplementary view sizes.
MIT License
898 stars 67 forks source link

Huge bottom space and weird behavior for 1.1.11 #26

Closed aplr closed 3 years ago

aplr commented 3 years ago

Hi, some issues popped up with your lib. Up until 1.1.10 my app behaved fine, but as soon as I've upgraded ChatLayout to 1.1.11, things got flaky. When entering a chat room, a huge chunk of empty space without any chat message cells is shown. When looking into layout inspector, no cells show up within the collectionView. When scrolling up, some chat message cells appear, but when scrolling back down they start to disappear again. I first thought it is some autolayout issue (which it could still be), but it worked pre 1.1.11, so I thought I want to ask you here if you know what the issue could be.

trim 99C16C45-89F9-4ABF-98F9-6EC81DEFBCE1

Thank you, and it's a really cool library you have here! Andreas

ekazaev commented 3 years ago

@aplr Hi, thank you for your issue. So you con confirm that in 1.1.10 everything was fine and is brokein in 1.1.11? Just to double check where to seek for the issue? In version 1.1.11 i optimized a bit the way how I try to find cells that are visible. Can you please check and confirm for me that everything is fine with 1.1.10 version and I roll my changes back. It will be also a great help if you can try to modify the Example app to achieve such behaviour? But it is less urgent. I dont face this issues in my apps.

aplr commented 3 years ago

Yes, I've reverted now to 1.1.10 and everything works fine as before. I will look into it, but at least for the cells themselves they are totally different from the example app. I will dig into it when I find time. I'll also look at your code if I can find the potential code that breaks. But yea modifying the example app would be good in the first place, of course it was clear to me that this issue is specific to me right now as I suspected your example app works perfectly.

ekazaev commented 3 years ago

@aplr Can you give me a sneak-pick about your cells. What are so unique about them? Like they can be much bigger than the screen? Or something? Ill invest sometime otherwise Ill rolback my changes. There are just more efficient way to search for visible cells that I added for performance. But it seems it doesnt cover all the cases.

aplr commented 3 years ago

Noo by no means, I'm just not using the cells from your demo app. But overall, they behave exactly like the ones in iMessage. Seems like an interesting topic, I'll also check the code changes you did, seems like it's not too much. Maybe it is also some instability due to autolayout issues in the first place, and the old way of searching for visible cells was more resilient to them?

ekazaev commented 3 years ago

Could be, but on the gif that you attached it looks like its calculating the content offset correctly - but some bottom cells are considered not visible. Not sure what is the issue. Will keep looking. But if you can either emulate it in the Example app or try to debug the difference of old and current algorithms and what has changed - it will be a great help.

ekazaev commented 3 years ago

@aplr Do you use sections in your code?

ekazaev commented 3 years ago

Please check 1.1.12. I think your case should be covered :) break was the issue

ekazaev commented 3 years ago

@aplr Feel free to reopen issue if its not. But I am certain that it should be as good as 1.1.10 just faster.