firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

FIRAuthKeychainServices causing thread warning when calling Auth.auth().signOut() method

Open acwright opened this issue 3 years ago • 2 comments

Description

When calling:

try Auth.auth().signOut()

Xcode will issue the following thread warning "This method should not be called on the main thread as it may lead to UI unresponsiveness." in FIRAuthKeychainServices:

Screenshot 2022-12-29 at 2 09 30 AM

Reproducing the issue

I am doing the following in an ObservableObject class:

    func signOut() {
        do {
            try Auth.auth().signOut()
        } catch {
            Logger.error(error.localizedDescription)
        }
    }

Firebase SDK Version

9.6.0

Xcode Version

14.2

Installation Method

Swift Package Manager

Firebase Product(s)

Authentication

Targeted Platforms

macOS

Relevant Log Output

[Security] This method should not be called on the main thread as it may lead to UI unresponsiveness.

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

acwright avatar Dec 29 '22 08:12 acwright

Thanks for reporting, @acwright. I wasn't able to get the same warning on Auth Quickstart. However, I found this related Apple discussion, and it seems like the issue is on WKWebView.

rizafran avatar Dec 29 '22 20:12 rizafran

@rizafran There is no WKWebView anywhere in my app. The app I'm building is a SwiftUI project for more info. Very vanilla project.

I believe this may be from the method being called in an ObservableObject subclass that is marked with @MainActor which is also very common to do in a SwiftUI app. If I understand this correctly it means the function called in my ObservableObject (see above) is being called on the main thread therefore your signOut() method is being called on the main thread and thus the offending SecItemDelete method is being incorrectly called on the main thread hence the Xcode warning.

Hopefully this adds some clarification :)

Edit: I do think this issue is on Apple's end (according to the linked discussion) not Firebase's and the bad actor is SecItemDelete. I have tried backgrounding the signOut() call using DispatchQueue but the warning still appears. :(

acwright avatar Dec 30 '22 04:12 acwright

Is this still an issue in Firebase 11 and recent Xcode versions?

paulb777 avatar Aug 02 '24 22:08 paulb777

Hey @acwright. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Aug 09 '24 01:08 google-oss-bot