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: duplicate message - WPB-11435 #2657

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

Conversation

netbe
Copy link
Collaborator

@netbe netbe commented Mar 10, 2025

BugWPB-11435 [iOS] All messages in a 1:1 conversation duplicated in iOS

Issue

On the legacy code, it happens message get processed multiple times.
It could be that in the following recursive method, because of a suspension point, the fetchNextEventsBatch fetch the same event before we actually delete it from the database and so reprocess it.

  private func process(
        with privateKeys: EARPrivateKeys?,
        _ consumeBlock: ConsumeBlock,
        firstCall: Bool,
        callEventsOnly: Bool
  • Make EventDecoder an actor so it's always executed on the same queue.
  • Safe guard the method with isProcessing so we don't process twice the same event.

Testing

  1. on a conversation, run web spam messages
  2. on the receiver side, send messages

Actual:
You'll see duplicate messages

Fix:
You'll get no duplicate messages


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 johnxnguyen March 10, 2025 16:48
@netbe netbe requested a review from jullianm March 10, 2025 16:49
Copy link
Contributor

github-actions bot commented Mar 10, 2025

Test Results

    1 files      1 suites   1m 34s ⏱️
1 207 tests 1 206 ✅ 0 💤 1 ❌
1 207 runs  1 207 ✅ 0 💤 0 ❌

For more details on these failures, see this check.

Results for commit afaa539.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Mar 10, 2025

Datadog Report

Branch report: fix/duplicate-message
Commit report: 5584811
Test service: wire-ios-mono

✅ 0 Failed, 1108 Passed, 0 Skipped, 1m 34.68s Total Time

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.

LGTM, just one non blocking comment about events batch processing logic

) async {
guard !isProcessing else {
WireLogger.updateEvent.debug("⚠️ process called before end of processing, abort")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

question(non-blocking): so if a second events batch wants to be processed while the first one is not finished yet, we discard it (early return). And I guess it will be processed again once the first is finished otherwise we'll lose that events batch, right ?

Copy link
Contributor

@jullianm jullianm Mar 11, 2025

Choose a reason for hiding this comment

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

Or maybe this logic only concerns the duplicated events since the function is recursive. Just checking that we don't lose any events along the way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to be honest I am not sure, this might be not completely correct

@netbe netbe changed the base branch from release/cycle-3.119 to develop March 12, 2025 12:33
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