Skip to content

iid().delete() / iid().deleteToken() causes app to crash #4044

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

Closed
leurs247 opened this issue Aug 4, 2020 · 11 comments
Closed

iid().delete() / iid().deleteToken() causes app to crash #4044

leurs247 opened this issue Aug 4, 2020 · 11 comments
Assignees
Labels
impact: crash Behaviour causing app to crash. platform: ios Priority: P1 Type: Stale Issue has become stale - automatically added by Stale bot

Comments

@leurs247
Copy link

leurs247 commented Aug 4, 2020

Hello, I have an app where only signed in users can receive FCM notifications.

I'll describe my work flow first:

Signing in
When signing in, I use messaging().getToken()to get the FCM token, and I store this in my own database for further use.

Signing out
When signing out, I use messaging().deleteToken()to delete the token. There is also a problem with this, I've issued it here (closed issue but I did not found a solution yet).

Solution(s) tried so far:

To try to "solve" this problem (about receiving the same FCM token again after using messaging().deleteToken()), I tried iid().deleteToken()and iid().delete(), but both functions seems to crash my app. I do not get an error message, the app just closes.

Platform: iOS 13.5

Edit:

The use of iid().delete() seems to solve my problem of getting the same token every time I sign in/sign out. It seems that messaging().deleteToken() isn't doing "the job", or there is a caching problem.

The only problem is: using iid().delete() causes my app to close after signing out, but I want to be redirected to the sign in screen. The crash is not ok.

@mikehardy
Copy link
Collaborator

We need a crash stacktrace to debug crashes, you can search on how to get them, please post one here?

@leurs247
Copy link
Author

leurs247 commented Aug 4, 2020

I don't really know where to look for this, if you can please tell me.

When I run the app in XCode, the following happens:

I press on the sign out button, and the following output lines appear:

2020-08-04 21:25:29.656 [info][tid:com.facebook.react.JavaScript] []
2020-08-04 21:25:30.222465+0200 phosphor[9679:3550466] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1ae3ac794 0x1ae0cebcc 0x1ae4022dc 0x1ae40b744 0x1ae29a1fc 0x1ae28c204 0x104c09768 0x104b23938 0x104b25e3c 0x1ae308644 0x1ae30868c 0x1ae3079e4 0x1ae3076bc 0x1ae284414 0x1ae30701c 0x1ae76e8a8 0x1ae32a06c 0x1ae324f60 0x1ae3252f4 0x1ae324ce8 0x1b846f38c 0x1b2453444 0x104ad89c8 0x1ae1ac8f0)
libc++abi.dylib: terminating with uncaught exception of type NSException

Also in XCode, the following window appears:
appName > appName > main.m

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char * argv[]) {
  @autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); // this lines throws an error
  }
}

// error thrown: Thread 1: Exception: "*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]"

Edit:

By leaving out iid().delete(), this error disappears.

@mikehardy
Copy link
Collaborator

That's close to what we need, but I'm hoping not just for the "first throw call stack", I'm looking something like the crash report here firebase/firebase-ios-sdk#4205

@leurs247
Copy link
Author

leurs247 commented Aug 5, 2020

Is this the correct output?

2020-08-05 10:46:34.781671+0200 <redacted>[95138:6561643] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010cdb8e6e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x000000010c5339b2 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010ce4b9d1 _CFThrowFormattedException + 194
	3   CoreFoundation                      0x000000010ce56426 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.4 + 38
	4   CoreFoundation                      0x000000010ce176e7 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 247
	5   CoreFoundation                      0x000000010cdb4d71 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
	6   <redacted>                             0x0000000106a6031a -[RNFBMessagingFIRMessagingDelegate messaging:didReceiveRegistrationToken:] + 186
	7   <redacted>                             0x0000000106972271 -[FIRMessaging notifyDelegateOfFCMTokenAvailability] + 577
	8   <redacted>                             0x00000001069747e9 -[FIRMessaging defaultInstanceIDTokenWasRefreshed:] + 985
	9   CoreFoundation                      0x000000010cce3d2c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	10  CoreFoundation                      0x000000010cce31a5 _CFXRegistrationPost1 + 421
	11  CoreFoundation                      0x000000010cce2f11 ___CFXNotificationPost_block_invoke + 193
	12  CoreFoundation                      0x000000010cde0473 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1795
	13  CoreFoundation                      0x000000010cce2866 _CFXNotificationPost + 950
	14  Foundation                          0x000000010812d439 postQueueNotifications + 700
	15  CoreFoundation                      0x000000010cd1c087 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	16  CoreFoundation                      0x000000010cd16b3e __CFRunLoopDoObservers + 430
	17  CoreFoundation                      0x000000010cd16f57 __CFRunLoopRun + 919
	18  CoreFoundation                      0x000000010cd168a4 CFRunLoopRunSpecific + 404
	19  GraphicsServices                    0x000000010f37abbe GSEventRunModal + 139
	20  UIKitCore                           0x00000001158ae968 UIApplicationMain + 1605
	21  <redacted>                            0x0000000106924e80 main + 112
	22  libdyld.dylib                       0x000000010dfb11fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Output after typing (lldb) bt:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x000000010e35833a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x000000010e3b5e60 libsystem_pthread.dylib`pthread_kill + 430
    frame #2: 0x000000010e0dab7c libsystem_c.dylib`abort + 120
    frame #3: 0x000000010ddf4858 libc++abi.dylib`abort_message + 231
    frame #4: 0x000000010dde5cbf libc++abi.dylib`demangling_terminate_handler() + 262
    frame #5: 0x000000010c533c0b libobjc.A.dylib`_objc_terminate() + 96
    frame #6: 0x000000010ddf3c87 libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x000000010ddf65f0 libc++abi.dylib`__cxa_rethrow + 99
    frame #8: 0x000000010c533b46 libobjc.A.dylib`objc_exception_rethrow + 37
    frame #9: 0x000000010cd16923 CoreFoundation`CFRunLoopRunSpecific + 531
    frame #10: 0x000000010f37abbe GraphicsServices`GSEventRunModal + 139
    frame #11: 0x00000001158ae968 UIKitCore`UIApplicationMain + 1605
  * frame #12: 0x0000000106924e80 phosphor`main(argc=1, argv=0x00007ffee92dbd68) at main.m:7:12
    frame #13: 0x000000010dfb11fd libdyld.dylib`start + 1
    frame #14: 0x000000010dfb11fd libdyld.dylib`start + 1

@mikehardy
Copy link
Collaborator

Yes! That's a crash trace we can work with, those are like smoking guns pointing at the problem usually, thank you
@Salakar anyone available to take a look at a code snippet trigger + crash trace? With the trace should be quick work, I'm swamped unfortunately :-(

@russellwheatley
Copy link
Member

Hey, @yesterday24, I've tested on a device, version 13.1 & on a simulator , version 13.6. I've tried messaging().deleteToken() & iid().deleteToken() methods. I am unable to produce the above noted crash.

do you mind providing a reproducible snippet of code? Thanks.

@mikehardy
Copy link
Collaborator

@yesterday24 perhaps more important, I should have asked this before but you should really fill out the template, it would have version information. Perhaps this is old versions? I would confirm you are up to date as of this typing on all stable versions of react-native-firebase, including firebase-ios-sdk override to 6.29.0 (current) so we know we are not chasing phantoms (override like so: https://rnfirebase.io/#overriding-native-sdk-versions)

@mortocks
Copy link

mortocks commented Sep 4, 2020

@yesterday24 Thanks for posting the iid().deleteToken() solution - lifesaver. Can confirm all the bugs listed here but as a temporary work around using the iid() package solves the problem

@mikehardy
Copy link
Collaborator

mikehardy commented Sep 4, 2020

@mortocks we are still looking for complete issue information and a reproduction as noted above. I'm happy (in a way) to hear that you can confirm it, but what would be ideal is if you opened a new issue following the template (edit: leaving this open until/in case a more complete issue with details does not appear, as it does seem to be a reproducible crash)

@mikehardy mikehardy added Workflow: Needs Review Pending feedback or review from a maintainer. Workflow: Waiting for User Response Blocked waiting for user response. labels Sep 4, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Oct 4, 2020
@stale
Copy link

stale bot commented Nov 7, 2020

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Nov 7, 2020
@mikehardy mikehardy removed Workflow: Needs Review Pending feedback or review from a maintainer. Workflow: Waiting for User Response Blocked waiting for user response. labels Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: crash Behaviour causing app to crash. platform: ios Priority: P1 Type: Stale Issue has become stale - automatically added by Stale bot
Projects
None yet
Development

No branches or pull requests

6 participants