chore: add some concurrency safety to SessionManager state - WPB-23571#4400
Open
samwyndham wants to merge 31 commits intodevelopfrom
Open
chore: add some concurrency safety to SessionManager state - WPB-23571#4400samwyndham wants to merge 31 commits intodevelopfrom
samwyndham wants to merge 31 commits intodevelopfrom
Conversation
…ger:appStateCalculator:trackingManager:) as @mainactor and some of it's method calls
…ly used. Also clean up init of ProxyCredentials
…ive session at the same time.
7dbc3f5 to
6ab1bb1
Compare
Contributor
Test Results 3 files 463 suites 3m 32s ⏱️ For more details on these failures, see this check. Results for commit 0079317. ♻️ This comment has been updated with latest results. Summary: workflow run #23639896422 |
samwyndham
commented
Mar 5, 2026
| + account.userIdentifier.safeForLoggingDescription | ||
| ) | ||
|
|
||
| delegate?.sessionManagerDidChangeActiveUserSession(userSession: session) |
Contributor
Author
There was a problem hiding this comment.
This is a no-op so deleting the delegate method altogether
Base automatically changed from
chore/concurrency-safe-account-manager-WPB-23570
to
develop
March 16, 2026 11:30
…ate-WPB-23571 # Conflicts: # wire-ios-sync-engine/Source/SessionManager/SessionManager.swift
|
David-Henner
approved these changes
Apr 1, 2026
Contributor
David-Henner
left a comment
There was a problem hiding this comment.
Nice work! Were there a lot of issues related to concurrency in the SessionManager before ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue
With this PR I'm trying to add some concurrency safety around updating state in the session manager. I was quite optimistic before starting it but it has become a bit of a struggle. The ideal would be that SessionManager is an Actor but this doesn't feel achievable in the short term. I had hoped to perhaps mark some properties as
@MainActorbut I don't think this is possible as it looks like much of this state might be accessed from various threads/queues. So in this PR I:activeUserSession,backgroundUserSessions&unauthenticatedSessionusing anOSAllocatedUnfairLock.withLockUncheckedcall. I've been careful in these cases to avoid calling out to other methods to avoid possible deadlocks.As you can see this code all gets additionally complex when we try to bring thread safety into it.
Testing
No specific test steps. Instead:
Checklist
[WPB-XXX].