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

Bugfix FXIOS-10832 Possible workaround for FXIOS-10832 withCheckedContinuation crash in JumpBackInDataAdaptor #23678

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2777,22 +2777,21 @@ class BrowserViewController: UIViewController,
)

// Credit card sync telemetry
self.profile.hasSyncAccount { [unowned self] hasSync in
logger.log("User has sync account setup \(hasSync)",
level: .debug,
category: .setup)
let hasSync = self.profile.hasAccount()
logger.log("User has sync account setup \(hasSync)",
level: .debug,
category: .setup)

guard hasSync else { return }
let syncStatus = self.profile.syncManager.checkCreditCardEngineEnablement()
TelemetryWrapper.recordEvent(
category: .information,
method: .settings,
object: .creditCardSyncEnabled,
extras: [
TelemetryWrapper.ExtraKey.isCreditCardSyncEnabled.rawValue: syncStatus
]
)
}
guard hasSync else { return }
let syncStatus = self.profile.syncManager.checkCreditCardEngineEnablement()
TelemetryWrapper.recordEvent(
category: .information,
method: .settings,
object: .creditCardSyncEnabled,
extras: [
TelemetryWrapper.ExtraKey.isCreditCardSyncEnabled.rawValue: syncStatus
]
)
}

private func autofillCreditCardNimbusFeatureFlag() -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ actor JumpBackInDataAdaptorImplementation: JumpBackInDataAdaptor, FeatureFlaggab
// MARK: Jump back in data

private func updateTabsAndAccountData() async {
hasSyncAccount = await getHasSyncAccount()
hasSyncAccount = getHasSyncAccount()
lmarceau marked this conversation as resolved.
Show resolved Hide resolved
await updateTabsData()
}

Expand Down Expand Up @@ -124,12 +124,8 @@ actor JumpBackInDataAdaptorImplementation: JumpBackInDataAdaptor, FeatureFlaggab

// MARK: Synced tab data

private func getHasSyncAccount() async -> Bool {
return await withCheckedContinuation { continuation in
profile.hasSyncAccount { hasSync in
continuation.resume(returning: hasSync)
}
}
private func getHasSyncAccount() -> Bool {
return profile.hasAccount()
}

private func updateRemoteTabs() async -> [ClientAndTabs]? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,16 @@ class UpdateViewModel: OnboardingViewModelProtocol,
// Function added to wait for AccountManager initialization to get
// if the user is Sign in with Sync Account to decide which cards to show
func hasSyncableAccount(completion: @escaping () -> Void) {
profile.hasSyncAccount { result in
self.hasSyncableAccount = result
ensureMainThread {
completion()
}
hasSyncableAccount = profile.hasAccount()
ensureMainThread {
completion()
}
}

func hasSyncableAccount() async -> Bool {
return await withCheckedContinuation { continuation in
profile.hasSyncAccount { hasSync in
self.hasSyncableAccount = hasSync
continuation.resume(returning: hasSync)
}
}
let hasSync = profile.hasAccount()
hasSyncableAccount = hasSync
return hasSync
}

func setupViewControllerDelegates(with delegate: OnboardingCardDelegate, for window: WindowUUID) {
Expand Down
9 changes: 0 additions & 9 deletions firefox-ios/Providers/Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ protocol Profile: AnyObject {
// <http://stackoverflow.com/questions/26029317/exc-bad-access-when-indirectly-accessing-inherited-member-in-swift>
func localName() -> String

// Async call to wait for result
func hasSyncAccount(completion: @escaping (Bool) -> Void)

// Do we have an account at all?
func hasAccount() -> Bool

Expand Down Expand Up @@ -696,12 +693,6 @@ open class BrowserProfile: Profile {
}
}()

func hasSyncAccount(completion: @escaping (Bool) -> Void) {
rustFxA.hasAccount { hasAccount in
completion(hasAccount)
}
}

func hasAccount() -> Bool {
return rustFxA.hasAccount()
}
Expand Down
6 changes: 0 additions & 6 deletions firefox-ios/RustFxA/RustFirefoxAccounts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,6 @@ open class RustFirefoxAccounts {
cachedUserProfile = nil
}

public func hasAccount(completion: @escaping (Bool) -> Void) {
if let manager = RustFirefoxAccounts.shared.accountManager {
completion(manager.hasAccount())
}
}

public func hasAccount() -> Bool {
guard let accountManager = RustFirefoxAccounts.shared.accountManager else { return false }
return accountManager.hasAccount()
Expand Down