FIRAuthKeychainServices causing thread warning when calling Auth.auth().signOut() method
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:
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!
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 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. :(
Is this still an issue in Firebase 11 and recent Xcode versions?
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!