New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance when push to ChatViewController not good #51
Comments
Hi @hhoangna In general there is nothing wrong with those functions. You are actually initialising a lot of views in one go. Potentially your I see you also have a flickering when chat view is being pushed to the |
I try to setup collection in viewDidLayoutSubviews but nothing change :( |
@hhoangna Lets first try to understand straight what are you doing. Are you trying to fix some performance issue related to the amount of the views you are creating or the visual glitch that the chat doesn’t appear immediately when the chat controller is being pushed into navigation controller and blame it on performance?
So if we are talking about 1 - can you please provide some code what you are doing in viewDidLayoutSubviews so I can examine it? I can’t guarantee that I will be able to help as it can be triggered by some other piece of your app. |
Yup. Still a lot of issues with my app. Such as animation while push to chat screen. I can't find any code line make that animation. |
@hhoangna I appreciate the honour but Id prefer to avoid such a close interaction unless it is going to be a paid service. I have my own work to do otherwise. But I assure you that what I said above that what is happening is that you are creating an extra animation loop while the controller is being pushed into the UINavigationController. Check that you propagate the first data within the viewDidLayoutSubviews. If your code is losely based on the Example app check that in this piece at this moment you return true collectionView.reload(using: changeSet,
interrupt: { changeSet in
guard WHATEVER else {
return true // FIRST TIME YOU MUST RETURN TRUE TO AVOID IT GOING TO performBatchUpdates
}
return false
},
onInterruptedReload: {
// IF YOU RETURN TRUE ABOVE - THIS CODE SHOULD POPULATE THE COLLECTION WITHOUT CREATING AN EXTRA ANIMATION TRANSACTION
let positionSnapshot = ChatLayoutPositionSnapshot(indexPath: IndexPath(item: 0, section: sections.count - 1), kind: .footer, edge: .bottom)
self.collectionView.reloadData()
// We want so that user on reload appeared at the very bottom of the layout
self.chatLayout.restoreContentOffset(with: positionSnapshot)
}, |
I have fixed animation when push Navigation Controller. It's a animation default of system when push from tabbarController.selectedViewController.navigationController.push(vc, animation: true), then have no animation now. The first load data in my code is same as your Example Nothing change, i think all problem is from initialing more subviews in custom chat cell |
@hhoangna Can you put a breakpoint inside of |
Thanks you so much. I'll try |
@hhoangna Good luck |
Hi there :D I had try create new synchronously function to get data and binding to collection view. And put them in viewDidLayoutSubviews. It's working, flickering was removed. But it's seem to get more time before navigation push to chat screen (about ~ 500ms) RPReplay_Final1686675933.MOVI don't know why. Then i crop a part of my project source code to sent to you. This can not run. Please review code and give me some advices. Thanks you so much |
@hhoangna I will have a look later at your code. But I still have the feeling that there is some unexpected animation happens during the push. Check it out. But I can tell you where is the delay can happen. As you can see on the gif I provided - there is no delay. This is the case that you need to check in the Instruments. This thing you need to keep in mind that there is nothing to do with the ChatLayout itself. It is already optimised. The delay comes from your code. |
Hi @ekazaev!
I used to apply ChatLayout to my ChatViewController. When push from list conversations to ChatViewController screen, i think i have a problem. It seem a little slow to show messages in Chat screen. I have run Time Profile by Instruments. I don't know why there functions and classes get more time.
RPReplay_Final1685277349.MP4
The text was updated successfully, but these errors were encountered: