Skip to content

Comments

chore: make AccountManager concurrency safe - WPB-23570#4340

Open
samwyndham wants to merge 5 commits intodevelopfrom
chore/concurrency-safe-account-manager-WPB-23570
Open

chore: make AccountManager concurrency safe - WPB-23570#4340
samwyndham wants to merge 5 commits intodevelopfrom
chore/concurrency-safe-account-manager-WPB-23570

Conversation

@samwyndham
Copy link
Contributor

@samwyndham samwyndham commented Feb 20, 2026

TaskWPB-23570 [iOS] Make `AccountManager` thread safe

Issue

This PR makes AccountManager, AccountStore & Account Sendable and therefore thread safe. It is part of a larger effort to make Session management safer across concurrent contexts.

I intentionally chose to do this with the aid of locks instead of Actors or @mainactor annotation as:

  • As these types are accessed from many places in nonisolated contexts, marking them as isolated would be a large effort and may lead to bugs.
  • I don't believe there to be performance issues doing this - in fact performance is likely better using locks than using the await keyword.

The negative is there is some additional complexity added to these types themselves.

Note:

I tried to add some tests checking for threading issues but was unsuccessful. I could do it by enabling the thread sanitizer in the test plan and having tests fail on error but there were too many existing tests that would fail in such cases.

Testing

  1. Logging in with multiple account on an older app
  2. Migrating to the new app
  3. There shouldn't be any issues - user should not be logged out.

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.

@samwyndham samwyndham marked this pull request as ready for review February 20, 2026 11:32
@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

Test Results

  1 files  132 suites   21s ⏱️
482 tests 477 ✅ 0 💤 5 ❌
483 runs  478 ✅ 0 💤 5 ❌

For more details on these failures, see this check.

Results for commit 0e4704b.

Summary: workflow run #22222448426
Allure report (download zip): html-report-28041-chore_concurrency-safe-account-manager-WPB-23570

@datadog-wireapp
Copy link

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 5 Tests failed

    It can add and select an account from WireDomainTests.AccountManagerTests (Fix with Cursor)

It can delete an account manager from WireDomainTests.AccountManagerTests (Datadog) (Fix with Cursor)
AccountManagerTests.swift:137: Expectation failed: (sut.selectedAccount → nil) == (account2 → <WireDataModel.Account: 0x600003031320>): // Then

    It can select an account from WireDomainTests.AccountManagerTests (Fix with Cursor)

View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0e4704b | Docs | Was this helpful? Give us feedback!

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.

1 participant