cordova-plugin-firebasex: iOS Crash Reports

Bug report

We just released our iOS App yesterday and received some Crashes, which seems to be related to this Plugin.

Current behavior:

Crash 1

-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m, line 389

SIGBUS

MAIN THREAD - CRASHED

libobjc.A.dylib
objc_getAssociatedObject
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:willPresentNotification:withCompletionHandler:] AppDelegate+FirebasePlugin.m:389

Crash 2

-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m, line 455

SIGBUS

MAIN THREAD - CRASHED

WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:455
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460
WayGuard
-[AppDelegate(FirebasePlugin) userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] AppDelegate+FirebasePlugin.m:460

As the second Crash happened to my Chef, i can told you what he told me: A Push appeared, he clicked on it -> App Crash.

The “Stack Traces” doesn’t seem to be very helpful, so if i can give you any more information, please told me which.

Environment information

  • Cordova CLI version
    • 9.0.0 (cordova-lib@9.0.1)
  • Cordova platform version
    • ios 5.1.1

Runtime issue

  • Device details
    • _e.g. iPhone XS
  • OS details
    • _e.g. iOS 13.4.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 51 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I was hoping to be able to repro this to be able to confirm a fix but as quick hack you can try this:

Add if(center == nil) return; at line 140 and line 162.

Since it appears this occurs with the UNUserNotificationCenter instance is nil so this should abort before the crash occurs.

OK thanks, that’s probably enough info that I can repro the crash. Will have a look when I get some time and investigate.

Could it be an incompatibility with the OneSignal plugin?

@epetre We don’t use that plugin and experience same issue.

We encounter the same error on multiple devices. It happens always at the first notification after app update through TestFlight (crash). After app restart, it works and no crash.

@thibaultv I can confirm we can replicate the issue this way. After updating app through TestFlight taping on first notification causes crash. After app restart everything works fine.

I’ve had a quick look and I still can’t recreate the issue but I think the commit that’s responsible for introducing it is this: https://github.com/dpa99c/cordova-plugin-firebasex/commit/4e9a0f4a1fd4ceb871af40629e1ddf146f287ca8

Somehow this is leading to the delegate referencing itself leading to infinite recursion. I’ll investigate further how this can be resolved when I get some more time.

The fix has been merged from dev to master and published as cordova-plugin-firebasex@10.2.0(-cli). Therefore I’m closing this issue as the crashes should now stop occurring. Integration with cordova-plugin-local-notifications and other plugins will be addressed separately under #230 but is likely to take a while due to needing a significant change of approach to resolve the conflicts.

I am still unable to reproduce this issue. All the info I have so far:

  • It seems like the users who have had these crashes have the app opened for a longer time period (several hours), than in background for several minutes up to 1 hour, and than the crash appears on clicking a notification.

  • The crashes occured like 10 times in 300 notifications. Different iOS versions (13.x) and devices.

Here is some of the code I use:

Sending notifications in my NodeJS backend via firebase-admin

await messaging().sendToTopic(topic, {
            notification: {
                title,
                body,
                sound: 'default',
                badge: `${badgeCount || 0}`
            }
        });

title and body can be dynamic string values.

In my mobile app project I log the messages via and do not do anything else with them

this.firebase.onMessageReceived().subscribe(async(msg) => {
            this.loggerService.log(`[FCM] received a message in ${(msg && msg.tap) ? 'background' : 'foreground'}`);
        });

the XCode log show the following native log (I changed the message id and sender id numbers)

FirebasePlugin[native] LOG: willPresentNotification: {
    aps =     {
        alert =         {
            body = "example body";
            title = "example title";
        };
        badge = 14;
        sound = default;
    };
    "gcm.message_id" = 159000000000;
    "google.c.a.e" = 1;
    "google.c.sender.id" = 1500000000;
    messageType = notification;
}

possibly related issues from other projects using firebase push notifications

I dont know if this helps at all, but thats all I can get for now.