Fix hiding typing indicator crash.#1804
Merged
Kaspik merged 3 commits intoMessageKit:mainfrom Aug 23, 2023
Merged
Conversation
…w layout from requesting message type from DataSource for typing indicator section.
Contributor
Author
|
@Kaspik Are you the right person to tag for this? If so, could you take a look at my PR? |
Kaspik
approved these changes
Jul 18, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
👻
Set typing indicator hidden inside performBatchUpdates to prevent flow layout from requesting message type from DataSource for typing indicator section.
What does this implement/fix? Explain your changes.
Showing the typing indicator works fine, but when hiding it, a crash occurs in the following function of
MessagesDataSourcewith messageindex out of bounds:The stacktrace indicates this is coming from the following function in
MessagesCollectionViewFlowLayout:This is because
messagesCollectionView.performBatchUpdates()causes theMessagesCollectionViewFlowLayoutto update. But because we have already set the typing indicator toisHidden = truebefore callingperformBatchUpdates(), the call toisSectionReservedForTypingIndicatorin flow layout will return false. This causes a call tomessageForItemfor a section dedicated to the typing indicator, which causes theindex out of boundscrash since we are not expecting the library to request anything for this section.When I made the change in this PR to my local codebase, it fixed the issue and the typing indicator hiding worked properly. This was tested within the app I am using MessageKit.
I've seen the example app crash a couple of times aswell and I think this might be because of the same issue. Specifically the advanced example.
Does this close any currently open issues?
Found this crash myself while developing an app that is using MessageKit.
Possible fix for #1788
Any relevant logs, error output, etc?
Any other comments?
…
Where has this been tested?
Devices/Simulators:
iOS Version:
Swift Version: Latest
MessageKit Version: 4.1.1