Skip to content

Comments

chore: make a number of calls async to prevent app hangs - WPB-22986#4337

Draft
samwyndham wants to merge 1 commit intodevelopfrom
chore/improve-hangs-setting-up-sync-agent-WPB-22986
Draft

chore: make a number of calls async to prevent app hangs - WPB-22986#4337
samwyndham wants to merge 1 commit intodevelopfrom
chore/improve-hangs-setting-up-sync-agent-WPB-22986

Conversation

@samwyndham
Copy link
Contributor

@samwyndham samwyndham commented Feb 19, 2026

BugWPB-22986 [iOS] WireSyncEngine: ZMUserSession.setUpSyncAgent(clientID:)

Issue

Please describe the issue.

Optional: add details about technical approach, solutions etc.

Optional: reference dependencies to other pull requests etc.

Testing

Describe how to test.

Optional: attachments like images, videos, etc.


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.

Comment on lines -1249 to -1297
// Creates the user session for @c account given, calls @c completion when done.
@MainActor
private func startBackgroundSession(
for account: Account,
with coreDataStack: CoreDataStack,
journal: Journal,
logFilesProvider: LogFilesProviding
) -> ZMUserSession {
guard let newSession = createUserSession(
for: account,
with: coreDataStack,
journal: journal,
logFilesProvider: logFilesProvider
) else {
preconditionFailure("Unable to create session for \(account)")
}

finishSettingUpUserSession(
account: account,
newSession: newSession,
coreDataStack: coreDataStack
)

return newSession
}

@MainActor
private func createUserSession(
for account: Account,
with coreDataStack: CoreDataStack,
journal: Journal,
logFilesProvider: LogFilesProviding
) -> ZMUserSession? {
let sessionConfig = ZMUserSession.Configuration(
appLockConfig: configuration.legacyAppLockConfig
)

return authenticatedSessionFactory.session(
for: account,
coreDataStack: coreDataStack,
configuration: sessionConfig,
sharedUserDefaults: sharedUserDefaults,
isDeveloperModeEnabled: isDeveloperModeEnabled,
journal: journal,
logFilesProvider: logFilesProvider,
faultyMLSRemovalKeysByDomain: configuration.faultyMLSRemovalKeysByDomain
)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is not called

journal[.isInitialSyncRequired] = true
let isConsumableNotificationsCapable = userClient.isConsumableNotificationsCapable // TODO: Is it to early to get that here?
Task {
await setUpSyncAgent(clientID: selfClientID, isNewClient: true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

QUESTION: Is it safe to make this async escaping?

@sonarqubecloud
Copy link

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