Skip to content

fix: use fetchRequest instead of in memory predicate - WPB-17064 #2809

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

netbe
Copy link
Collaborator

@netbe netbe commented Apr 7, 2025

BugWPB-17064 [iOS] hang on conversation list

Issue

When resuming the app, the conversation lists are recreated and conversations filtered and sort again. This is done in memory and causes a hang when applying the filtering (touching conversationType).

Use fetchRequests for all filters instead.

Note: Eventually, we could replace ConversationList and ConversationListSnapshot with just a fetchrequestController that would be applied a predicate each time.

Testing

  1. enable hang detection
  2. put app in background
  3. put app in foreground
    Observe no hang is produced

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

@netbe netbe requested a review from dmitrysimkin April 7, 2025 07:12
@netbe netbe changed the title fix: use fetchRequest instead of in memory predicate fix: use fetchRequest instead of in memory predicate - WPB-17064 Apr 8, 2025
@netbe netbe requested review from a team, samwyndham and KaterinaWire and removed request for a team April 10, 2025 09:15
@netbe netbe marked this pull request as ready for review April 10, 2025 09:16
Copy link
Contributor

github-actions bot commented Apr 10, 2025

Test Results

2 425 tests   2 420 ✅  4m 18s ⏱️
  259 suites      0 💤
    1 files        5 ❌

For more details on these failures, see this check.

Results for commit c657f4d.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Apr 10, 2025

Datadog Report

Branch report: fix/perf-conversationList
Commit report: 2d500c6
Test service: wire-ios-mono

❌ 5 Failed (0 Known Flaky), 2420 Passed, 0 Skipped, 4m 17.91s Total Time

❌ Failed Tests (5)

  • testThatItReturnsAllConversations - WireDataModelTests.ZMConversationListDirectoryTests

  • testThatItReturnsUnarchivedConversations - WireDataModelTests.ZMConversationListDirectoryTests

  • testThatItsReturnsOneToOneConversations - WireDataModelTests.ZMConversationListDirectoryTests - Details

    Expand for error
     ZMConversationListDirectoryTests.m:329: (([NSSet setWithArray:list.items]) equal to (expected)) failed: ("{(
         <ZMConversation: 0x60000296c700> (entity: Conversation; id: 0x600000669e00 <x-coredata://ACF5D5DD-E3C8-49DB-80B8-70C0496E3D1C/Conversation/p43>; data: {
         accessModeStrings = nil;
         accessRoleString = nil;
         accessRoleStringsV2 = nil;
         allMessages =     (
         );
         archivedChangedTimestamp = nil;
         cellName = nil;
         ciphersuite = 0;
     ...
    
  • testThatItDoesNotReturnNonOneOnOneConversations() - WireDataModelTests.ZMConversationListTests_OneOnOne - Details

    Expand for error
     ZMConversationListTests+OneOnOne.swift:100: XCTAssertEqual failed: ("[<ZMConversation: 0x6000029a57a0> (entity: Conversation; id: 0x60000064eca0 x-coredata://673C2273-DAA6-40F4-94B4-020DF1EACD4D/Conversation/p17; data: {
         accessModeStrings = nil;
         accessRoleString = nil;
         accessRoleStringsV2 = nil;
         allMessages = "count: 0 {}";
         archivedChangedTimestamp = nil;
         cellName = nil;
         ciphersuite = 0;
         clearedTimeStamp = nil;
         commitPendingProposalDate = nil;
     ...
    
  • testThatItReturnsAllOneOnOneConversations() - WireDataModelTests.ZMConversationListTests_OneOnOne - Details

    Expand for error
     ZMConversationListTests+OneOnOne.swift:68: XCTAssertEqual failed: ("[<ZMConversation: 0x60000296d960> (entity: Conversation; id: 0x600000607780 x-coredata://10CB23B3-7B75-4132-A6F2-091BFA62D008/Conversation/p26; data: {
         accessModeStrings = nil;
         accessRoleString = nil;
         accessRoleStringsV2 = nil;
         allMessages = "count: 0 {}";
         archivedChangedTimestamp = nil;
         cellName = nil;
         ciphersuite = 0;
         clearedTimeStamp = nil;
         commitPendingProposalDate = nil;
     ...
    

Copy link
Contributor

@dmitrysimkin dmitrysimkin 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 👍
Only concern, is it covered by any test, implicitly or explicitly?

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.

I'm actually very surprised this is an improvement. Any idea what specifically was the bottleneck before?

@netbe netbe force-pushed the fix/perf-conversationList branch from 415243c to ee3f660 Compare April 11, 2025 14:40
@netbe
Copy link
Collaborator Author

netbe commented Apr 11, 2025

Looks good 👍 Only concern, is it covered by any test, implicitly or explicitly?

@dmitrysimkin yes actually I forgot to update the tests

@netbe netbe changed the base branch from develop to release/cycle-3.122 April 11, 2025 14:41
@netbe netbe changed the base branch from release/cycle-3.122 to develop May 2, 2025 10:30
Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Please update it or close it in case is not relevant anymore.

@github-actions github-actions bot added the stale label Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants