Skip to content
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

FIRInstanceID notifyAPNSTokenIsSet -> NSInvalidArgumentException #3439

b-onc opened this issue Jul 26, 2019 · 5 comments

FIRInstanceID notifyAPNSTokenIsSet -> NSInvalidArgumentException #3439

b-onc opened this issue Jul 26, 2019 · 5 comments


Copy link

@b-onc b-onc commented Jul 26, 2019

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.2.1
  • Firebase SDK version: _____
  • Firebase Component: FIRInstanceID (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: 6.5.0

[REQUIRED] Step 3: Describe the problem

We're seeing some crashes in the wild, with stack trace:

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x219c34518 __exceptionPreprocess
1  libobjc.A.dylib                0x218e0f9f8 objc_exception_throw
2  CoreFoundation                 0x219badf8c _CFArgv
3  CoreFoundation                 0x219b36168 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
4  CoreFoundation                 0x219b26d44 +[NSDictionary dictionaryWithObjects:forKeys:count:]
5  OurApp                       0x100d44064 __38-[FIRInstanceID notifyAPNSTokenIsSet:]_block_invoke + 1016 (FIRInstanceID.m:1016)
6  libdispatch.dylib              0x219674a38 _dispatch_call_block_and_release
7  libdispatch.dylib              0x2196757d4 _dispatch_client_callout
8  libdispatch.dylib              0x219623004 _dispatch_main_queue_callback_4CF$VARIANT$mp
9  CoreFoundation                 0x219bc5ec0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
10 CoreFoundation                 0x219bc0df8 __CFRunLoopRun
11 CoreFoundation                 0x219bc0354 CFRunLoopRunSpecific
12 GraphicsServices               0x21bdc079c GSEventRunModal
13 UIKitCore                      0x246177b68 UIApplicationMain
14 OurApp                       0x100937dc4
15 libdyld.dylib                  0x2196868e0 start

Crash happens at:

__38-[FIRInstanceID notifyAPNSTokenIsSet:]_block_invoke + 1016 (FIRInstanceID.m:1016)

with error:

Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

Steps to reproduce:

Crash happens at launch


This comment has been hidden.

Copy link

@Speakus Speakus commented Jul 26, 2019

I see the issue happens cause self.apnsTokenData == nil
the context:

    [self asyncLoadKeyPairWithHandler:^(FIRInstanceIDKeyPair *keyPair, NSError *error) {

      NSMutableDictionary *tokenOptions = [@{
        kFIRInstanceIDTokenOptionsAPNSKey : self.apnsTokenData,
        kFIRInstanceIDTokenOptionsAPNSIsSandboxKey : @(isSandboxApp)
      } mutableCopy];

So my analysis shows apnsTokenData never nil at this point even with race condition - so I guess only self could be nil - it was redefinied by FIRInstanceID_STRONGIFY() macros from weak variable.

Copy link

@Speakus Speakus commented Jul 26, 2019

BTW. It's very old issue according our Crashlytics data - but previously it was happened not so often.

Copy link

@daidongon daidongon commented Jul 28, 2019

We also experience this ( same ) crash.

Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

0  CoreFoundation                 0x1f5cf127c __exceptionPreprocess
1  libobjc.A.dylib                0x1f4ecb9f8 objc_exception_throw
2  CoreFoundation                 0x1f5c6ace8 _CFArgv
3  CoreFoundation                 0x1f5bf29a8 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
4  CoreFoundation                 0x1f5be3584 +[NSDictionary dictionaryWithObjects:forKeys:count:]
5 our app                       0x100c57f1c __38-[FIRInstanceID notifyAPNSTokenIsSet:]_block_invoke + 1016 (FIRInstanceID.m:1016)
6  libdispatch.dylib              0x1f5730a38 _dispatch_call_block_and_release
7  libdispatch.dylib              0x1f57317d4 _dispatch_client_callout
8  libdispatch.dylib              0x1f56df004 _dispatch_main_queue_callback_4CF$VARIANT$mp
9  CoreFoundation                 0x1f5c82c1c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
10 CoreFoundation                 0x1f5c7db54 __CFRunLoopRun
11 CoreFoundation                 0x1f5c7d0b0 CFRunLoopRunSpecific
12 GraphicsServices               0x1f7e7d79c GSEventRunModal
13 UIKitCore                      0x2224ac978 UIApplicationMain
14 our app                       0x1006e88ec main + 30 (AppDelegate.swift:30)
15 libdyld.dylib                  0x1f57428e0 start

crashed here

FIRInstanceID.m line 1016
__38-[FIRInstanceID notifyAPNSTokenIsSet:]_block_invoke + 1016

There are a lot of crashes, so please raise the priority and check.

Copy link

@mouness2020 mouness2020 commented Jul 29, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants