-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Bug: Auth.auth().currentUser Returns Nil on Some Devices Despite Available User Data. #13231
Comments
@rizafran any update on this? The bug has a high repro on end devices. |
Thanks for reporting, @jesus-mg-ios. In order to investigate and replicate the issue, could you provide the following info:
|
Several ones...
|
See this stackoverflow question and answer - https://stackoverflow.com/q/69201789/556617 |
I've already implemented a state listener @paulb777, but it didn't resolve the issue. The state listener initially triggers with a nil value, even though the data is available in the keychain, and it never triggers again with the correct user value. |
Does 11.0.0 (released today) make any difference? |
Hey @jesus-mg-ios. 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! |
I have the same issue on 11.0.0 .. each time i reset the app auth is nil! Downgrading to FirebaseCore 10.29.0 (was 11.0.0) solved the issue.... Removing FirebaseAppCheckInterop not sure if those files have anything to do with it? those are removed after downgrade from 11 |
@jesus-mg-ios have you figured it out ? |
@rizafran
Auth.auth().currentUser returns nil after app restart .. |
Hi @yarodevuci, I tried to reproduce the issue using v11.0.0 on iOS 17 simulator, but my |
I can draft maybe a sample app yes, do you know if between 10 and 11 version a new json config file needs to be updated? Some people mentioned the updating their entitlements file helped too, so I am not sure if from brand new project issue does not exist, compared to older project |
@yarodevuci, may I know which json config file you're referring to? |
GoogleService-Info.plist |
Hi @yarodevuci, there's no need to update in your |
@rizafran here is my update I use to check in AppDelegate I tried
So I can't no longer use direct Auth.auth().currentUser in AppDelegate? |
I also faced this bug, In my apps, user is signed in anonymously when
So I decided to switch back to Firebase 10.29.0. |
@rizafran can you let us know if this an actual bug or updated implementation usage is now required? |
We're considering adding two alternative APIs:
|
@paulb777 can we expect a fix in the next version ? |
There are two problems discussed in this issue.
We don't yet have a plan for either of these. |
if this is true @paulb777 , then when I request the currentUser after some time (e.g., 2 minutes after app launch), it should be updated. However, it seems that this is not always the case. For example, after changing the displayName within the same app, and restart it again, sometimes the displayName reverts to the old one and no changes are made along the app lifecycle to this property, even the reload function for the current user doesn't always work as expected, and only logging out and back in resolves it. |
@jesus-mg-ios A repro case of a change getting reverted would be helpful |
@paulb777 I think there's actually a change in logic (or unintended consequence) going on between 10.29.0 and 11.0.0. With the use of In 11.x, |
Any update on this? I cannot get the user from |
I had to downgrade until 11.x mimics the 10.x behavior |
I still get |
@Pigpocket Does the |
Using Firebase SDK 11.3.0 I observe that addStateDidChangeListener initially callbacks with user=nil immediately followed by non-nil user data. I was testing on a real device (iPad) when NOT attached to the Xcode debugger (but still a debug version installed using Xcode). When the app was started using Xcode it properly provided the non-nil user on first listener callback. |
We've been seeing similar issues of
I see a recent PR #14067 |
Still happening on my project and cannot upgrade to 11.x. Are there any ways to avoid this? |
Same here. Really hoping they look at this: #13231 (comment) |
Please @yoching, @bryandubno, @tsjamm, @raho, @Pigpocket, @dfmuir @yarodevuci @unxavi upvote the issue description to give it more visibility. |
Firebase team is aware of the issue, but I feel like they not gonna do a fix for this... |
I hope they will do it, because it is a critical part of their SDK. @ncooke3, any updates on this? Do we have an ETA for a solution or any pathway to address it? |
Apologies for the delay everyone, and thank you for your patience. I'll be looking into this more this week. |
Hi everyone, thanks again for your patience. So far, I was able to make two fixes that should address some of the situations described in this thread. Theses were case related to updating from 10.x to 11.x (e.g. @bryandubno's #13231 (comment)). I'm still looking into the original case that existed on 10.25.0 (see OP). @jesus-mg-ios, a couple questions to help my repro attempts:
At this time, it's unclear to me if app pre-warming is the culprit or an SDK threading issue. |
|
@jesus-mg-ios, a couple more questions to help guide my setup
|
|
@jesus-mg-ios, this is difficult for me to replicate, but I have a suspicion that this may be due to the app extension being prewarmed by the system. Setting the user access group will write the given group to user defaults. If the I think a first step would be to confirm that the let isPrewarming = ProcessInfo.processInfo.environment["ActivePrewarm"] == "1" I would recommend adding logs to understand if the unexpected behavior is happening when It doesn't look like prewarming can be reliably reproduced, but if you're able to intermittently reproduce the issue, there is a good chance the device's OS may try prewarming the extension if it's frequently used. |
Thanks @ncooke3, I will take a look at it in a few days. |
Description
The
Auth.auth().currentUser
property consistently returns nil on specific devices, even though a logged-in user is expected. In contrast, thegetStoredUser(forAccessGroup:)
method intermittently returns a user object, suggesting that the user data is accessible. The behavior remains consistent across device lifecycles, where the method either returns a user object or does not, without variation. The whole extension works on a concurrent environment.Also functions are working authenticated despite
Auth.auth().currentUser
is nil. State listener does not change the rules, I mean, it does not change Auth.auth().currentUser, and also does not return other than nil on those cases Auth.auth().currentUser is nil.Reproducing the issue
I'm not sure, but maybe it more reproducible when updates happens. Because what I saw in some cases is:
Auth.auth().currentUser
is nil andgetStoredUser(forAccessGroup:)
is also nil until the user enters on the app, then getStoredUser(forAccessGroup:) returns a value in the extension.Even sometimes both
Auth.auth().currentUser
getStoredUser(forAccessGroup:)
are nil until the extension restart.Could be any kind of deadlock trying to get the keychain element?
Firebase SDK Version
10.25
Xcode Version
15.2
Installation Method
Swift Package Manager
Firebase Product(s)
Authentication
Targeted Platforms
iOS, macCatalyst
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand
Package.resolved
snippetReplace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand
Podfile.lock
snippetReplace this line with the contents of your Podfile.lock!
The text was updated successfully, but these errors were encountered: