Skip to content

Conversation

jullianm
Copy link
Contributor

@jullianm jullianm commented May 23, 2025

BugWPB-17866 [iOS] Not able to send messages on mobile data

Issue

Context: Messages are stuck forever in a sending state, no way to recover. Next messages can't be sent as well, stuck in same state.

We introduced in this PR a mechanism that waits for pending events to be decrypted before proceeding to message sending.

Specifically in MessageSender, we await for incrementalSyncObserver.waitUntilCanSendMessage() and it only gets through when finishing decrypting the pending events and setting the decryptionState to done at the IncrementalSyncObserver level.

Causes: The decryption state might never gets updated to .done hence blocking the message sender to proceed the message which can lead to the bugs mentioned here and here.

What happens after is that if we try to send a message again we'll be stuck in a loop in try await messageDependencyResolver.waitForDependenciesToResolve(for: message) where the dependencies never resolve specifically dependentObjectNeedingUpdateBeforeProcessing (code doc below) will never be nil, probably because the initial message was never really processed and it blocks the next messages.

/// Other entities which has to complete an update before this entity can be processed, i.e. another message /// needs to be sent first because it was scheduled for sending before this message.

Solution: Update the sync state whenever the sync is suspended or when an error occurs while pulling (and decrypting) pending events so we ensure the decryption state is changed to done so the MessageSender method is "unlocked" and the messages are sent or at least attempted to be sent.

Testing

Tested internally

  • Comment out the code where the sync state is updated so the MessageSender gets stuck and the message not sent.
  • try to send message again and again
  • messages shows up as in sending state just like the screenshots from the Jira tickets

Capture d’écran   2025-05-23 à 16 47 36

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.

@jullianm jullianm requested review from a team, samwyndham, johnxnguyen and KaterinaWire and removed request for a team May 23, 2025 15:22
Copy link
Contributor

github-actions bot commented May 23, 2025

Test Results

3 525 tests   3 499 ✅  4m 3s ⏱️
  564 suites     26 💤
    4 files        0 ❌

Results for commit 72c4951.

♻️ This comment has been updated with latest results.

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.

Nice work!

@datadog-wireapp
Copy link

Datadog Report

Branch report: fix/messages-not-being-sent
Commit report: e5871c7
Test service: wire-ios-mono

✅ 0 Failed, 3497 Passed, 26 Skipped, 2m 4.59s Total Time

@jullianm jullianm requested a review from johnxnguyen May 26, 2025 10:45
Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

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

left a question and wonder if a unit test can be added

@jullianm
Copy link
Contributor Author

added some UTs in last commit @netbe , merging the PR

@jullianm jullianm enabled auto-merge (squash) May 26, 2025 15:43
@jullianm jullianm merged commit 7639bd1 into release/cycle-3.124 May 26, 2025
8 checks passed
@jullianm jullianm deleted the fix/messages-not-being-sent branch May 26, 2025 16:14
zenkins pushed a commit that referenced this pull request May 26, 2025
caldrian pushed a commit that referenced this pull request May 27, 2025
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