Skip to content

fix(ear): messages can't be displayed - WPB-24136#4450

Merged
David-Henner merged 14 commits intorelease/cycle-4.16from
fix/sync-cancellation-issues
Mar 24, 2026
Merged

fix(ear): messages can't be displayed - WPB-24136#4450
David-Henner merged 14 commits intorelease/cycle-4.16from
fix/sync-cancellation-issues

Conversation

@David-Henner
Copy link
Copy Markdown
Contributor

@David-Henner David-Henner commented Mar 18, 2026

BugWPB-24136 [iOS] Messages can't be displayed due to decryption errors

Issue

Sometimes, with EAR enabled, after opening the app, some messages can't be displayed.

Screenshot 2026-03-18 at 11 53 24

Cause

Messages couldn't be encrypted at rest because the database key was missing.

This happens because the app went to the background and locked the database (nullified the database key from cache) while the incremental sync was running and processing messages.

When this happens, we cancel the sync

However, the cancellation doesn't get propagated properly from the suspend method to the inner sync task. Hence, the sync continues and tries to process messages while the database key is nil

Solution

  • Propagate task cancellation properly in NonReentrantTaskManager and ExpiringActivity
  • Add a Task.checkCancellation before processing individual events in the incremental sync
  • Add a guard against having the database locked before processing any non-backgroundAccessible event, and handle cleaning up the processed events from the current batch

Testing

  1. Log in & Enable EAR
  2. Put the app in the background
  3. Receive many messages (use a spambot to send 100s of messages)
  4. Open the app and immediately put it in the background once the sync starts
  5. Reopen the app

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

Test Results

   14 files  1 112 suites   11m 15s ⏱️
8 377 tests 8 344 ✅ 31 💤 2 ❌
8 389 runs  8 358 ✅ 31 💤 0 ❌

For more details on these failures, see this check.

Results for commit 3b9e148.

♻️ This comment has been updated with latest results.

Summary: workflow run #23488867210
Allure report (download zip): html-report-28736-fix_sync-cancellation-issues

Copy link
Copy Markdown
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

@netbe netbe force-pushed the release/cycle-4.16 branch from 6545bce to 50c6a90 Compare March 23, 2026 10:08
@David-Henner David-Henner enabled auto-merge (squash) March 24, 2026 12:14
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
12.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@David-Henner David-Henner merged commit 93e486c into release/cycle-4.16 Mar 24, 2026
23 of 24 checks passed
@David-Henner David-Henner deleted the fix/sync-cancellation-issues branch March 24, 2026 13:02
zenkins pushed a commit that referenced this pull request Mar 24, 2026
Co-authored-by: KaterinaWire <57407805+KaterinaWire@users.noreply.github.com>
Co-authored-by: François Benaiteau <netbe@users.noreply.github.com>
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.

5 participants