-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(messaging): Fixes a race condition between `FIRAuth/didReceiveRem… #6392
Closed
glesperance
wants to merge
2
commits into
invertase:main
from
glesperance:fix/messaging-didReceiveRemoteNotification-race
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there some documentation about what a probe notification is? First I have heard of it! It seems to be detectable (via your
data && data[@"warning"]
test but I'd love a canonical source for that test as nothing came up in my attempt at a searchThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question & sorry if I put pressure on you :)
This can wait for you to be back to normal, I just would hate this bug to be in the codebase.
Regarding the probe notification, I haven't found it through the documentation but rather through inspecting the Firebase iOS SDK code.
https://github.com/firebase/firebase-ios-sdk/blob/eb30b6fdd809cbfe3a9eb7f3ccf1dd46326bef2d/FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.m#L105-L110
https://github.com/firebase/firebase-ios-sdk/blob/eb30b6fdd809cbfe3a9eb7f3ccf1dd46326bef2d/FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.m#L45-L48
I looked at the blame log and this was part of the iOS Firebase SDK's first commit ever.
The fix has been found through dissecting the code until I found most minimal cause of the bug, and then got a matching fix.
Perhaps @paulb777 (the original author of the SDK) could give us some details?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did the original open sourcing, but not the authoring so I can't help with the purpose of FirebaseAuth probe notifications, but maybe @renkelvin can?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi all, I'm not the author either, while my understanding is that this key is to help Firebase Auth to decide whether they should handle the notification or let the App handle it. See https://github.com/firebase/firebase-ios-sdk/blob/eb30b6fdd809cbfe3a9eb7f3ccf1dd46326bef2d/FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.m#L150
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @paulb777 @renkelvin (that was some awesomely quick feedback)! This definitely brings me back to when I found the fix.
@mikehardy I should have taken notes when I made the original fix, but my understanding was that (thank you Paul & Chuanr for jogging my memory back) we should always callback when we receive a probe notification, since that is what the SDK does when it has pending callbacks:
https://github.com/firebase/firebase-ios-sdk/blob/eb30b6fdd809cbfe3a9eb7f3ccf1dd46326bef2d/FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.m#L150-L158
Moreover, even if we redundantly call there would be no side effect to call the completion handler since it is effectively no-op:
https://github.com/firebase/firebase-ios-sdk/blob/eb30b6fdd809cbfe3a9eb7f3ccf1dd46326bef2d/FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.m#L116-L117
Therefore the thinking is:
therefore just always call back the completion handler when it's a probe notification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Salakar or @Ehesp just dropping you a notification that links you into some really interesting firebase messaging / auth race condition that is deep enough / subtle enough it probably lives in FlutterFire too - you might take a look. I hate to create new notification pings just for gratitude when we probably get too many, but I'll do it anyway, thanks @paulb777 and @renkelvin for the assist here, much appreciated.