Skip to content

Commit

Permalink
Bugfix FXIOS-10832 Possible workaround for FXIOS-10832 withCheckedCon…
Browse files Browse the repository at this point in the history
…tinuation crash in JumpBackInDataAdaptor (#23678)

Possible workaround for FXIOS-10832 by removing an completion block for the hasAccount() call and cleaning up some weird code.
  • Loading branch information
ih-codes authored Dec 11, 2024
1 parent 8f44b4b commit e4de9c8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 48 deletions.
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()
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

0 comments on commit e4de9c8

Please sign in to comment.