Skip to content
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

fix: crash on conversation content - WPB-15979 #2554

Open
wants to merge 5 commits into
base: release/cycle-3.118
Choose a base branch
from

Conversation

netbe
Copy link
Collaborator

@netbe netbe commented Feb 18, 2025

BugWPB-15979 [iOS] Crashes with many unread messages

Issue

Screenshot 2025-02-18 at 15 17 31

In the crash report associated to the ticket, we can see that the app is killed by the system while fetching messages of the conversation in CoreData while in background.

It's not directly clear if the exhaustion of resources we get is caused by just fetching a lot of messages or processing in another thread messages.

Solution

In case of the first one, we could remove the observation of changes in the current conversation when moving to background.

  • Remove fetchController delegate on applicationDidEnterBackground
  • Reset fetchController delegate on applicationWillEnterForeground

Testing

  1. spam messages on mls account
  2. going back and again in foreground

Copy link
Contributor

github-actions bot commented Feb 18, 2025

Test Results

    1 files      2 suites   2m 2s ⏱️
1 789 tests 1 763 ✅ 26 💤 0 ❌
1 799 runs  1 773 ✅ 26 💤 0 ❌

Results for commit 582ee7f.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Feb 18, 2025

Datadog Report

Branch report: fix/WPB-15979
Commit report: b3f1a28
Test service: wire-ios-mono

✅ 0 Failed, 1687 Passed, 26 Skipped, 2m 1.84s Total Time

@netbe netbe requested review from a team, samwyndham, johnxnguyen and jullianm and removed request for a team February 18, 2025 14:49
Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: If the conversations are updated while in the background can things become out of sync or is the data reloaded when we enter the foreground again?

Copy link
Collaborator

@johnxnguyen johnxnguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good but I want to see the answer to @samwyndham 's question.

Copy link
Contributor

@jullianm jullianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good for the background. I think I saw (but I'm not certain) in the attached crash files that sometimes it also occurred in the foreground, there might be a different fix to do if that's the case.

@netbe
Copy link
Collaborator Author

netbe commented Feb 20, 2025

@samwyndham I changed the implementation to refetch when resuming to foreground, so no updates are missed

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I just added a non-blocking comment.

do {
try fetchController?.performFetch()
tableView.reloadData()
tableView.setContentOffset(contentOffset, animated: false)
Copy link
Contributor

@samwyndham samwyndham Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I'm surprised that this is needed - I assume you saw an issue with the content offset changing when calling reload data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants