Draft
Conversation
…on mismatch - WPB-23912 Use currentSections to resolve a message's section index instead of the fetch controller, ensuring the index is always consistent with what the table view displays and eliminating the race condition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
JaCaLlaSchwarz
approved these changes
Mar 9, 2026
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.



Issue
The app crashed when scrolling to a specific message (e.g. via push notification or search result) in a long conversation while background sync was active.
topIndexPath(for:)calledtableView.numberOfRows(inSection:)with a section index derived from the fetch controller. Because calculateSections snapshots allMessages before dispatching to a background thread, thefetch controller can gain new objects (via
NSFetchedResultsControllerDelegate) by the time the result is applied andreloadData()is called. This made the fetch controller index exceed the number of sections thetable view knew about, triggering UIKit's internal assertion.
The fix changes
index(of:)to look up the message by nonce incurrentSectionsinstead of the fetch controller. Since currentSections is always the exact snapshot the table view was last reloaded with, thereturned index is guaranteed to be in bounds.
Testing
Checklist
[WPB-XXX].UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: