react-native-notifications: [Bug - Crash] Getting crash in RNNotificationStore

Hello everyone, I am seeing this crash in Crashlytics, it’s happening sporadically. Not sure why this is happening, just that its happening in (RNNotificationsStore.m:61) and (RNNotificationsStore.m:51).

here is the crash log

BUG IN CLIENT OF LIBDISPATCH: Unbalanced call to dispatch_group_leave()

Crashed: com.apple.main-thread
0  libdispatch.dylib              0x39a80 dispatch_group_leave.cold.1 + 36
1  libdispatch.dylib              0x4878 _dispatch_group_wake + 130
2  App                                   0x36ab74 __69-[RNNotificationsStore completePresentation:withPresentationOptions:]_block_invoke + 61 (RNNotificationsStore.m:61)
3  libdispatch.dylib              0x1e6c _dispatch_call_block_and_release + 32
4  libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
5  libdispatch.dylib              0x11f48 _dispatch_main_queue_drain + 928
6  libdispatch.dylib              0x11b98 _dispatch_main_queue_callback_4CF + 44
7  CoreFoundation                 0x51800 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
8  CoreFoundation                 0xb704 __CFRunLoopRun + 2532
9  CoreFoundation                 0x1ebc8 CFRunLoopRunSpecific + 600
10 GraphicsServices               0x1374 GSEventRunModal + 164
11 UIKitCore                      0x514b58 -[UIApplication _run] + 1100
12 UIKitCore                      0x296090 UIApplicationMain + 364
13 App                    0x4ed4 main + 7 (main.m:7)
14 ???                            0x104b31da4 (Missing)

And it happens here as well, seems to happen when removing key from handler dictionary.

Crashed: com.apple.main-thread
0  libdispatch.dylib              0x39a80 dispatch_group_leave.cold.1 + 36
1  libdispatch.dylib              0x4878 _dispatch_group_wake + 130
2  App                                   0x36aa50 __39-[RNNotificationsStore completeAction:]_block_invoke + 51 (RNNotificationsStore.m:51)
3  libdispatch.dylib              0x1e6c _dispatch_call_block_and_release + 32
4  libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
5  libdispatch.dylib              0x11f48 _dispatch_main_queue_drain + 928
6  libdispatch.dylib              0x11b98 _dispatch_main_queue_callback_4CF + 44
7  CoreFoundation                 0x51800 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
8  CoreFoundation                 0xb704 __CFRunLoopRun + 2532
9  CoreFoundation                 0x1ebc8 CFRunLoopRunSpecific + 600
10 GraphicsServices               0x1374 GSEventRunModal + 164
11 UIKitCore                      0x514b58 -[UIApplication _run] + 1100
12 UIKitCore                      0x296090 UIApplicationMain + 364
13 App                    0x4ed4 main + 7 (main.m:7)
14 ???                            0x1054a5da4 (Missing)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 16

Most upvoted comments

I was running into this same problem and figured out it was caused by calling the registration methods on Notifications.events() multiple times and then receiving a push notification. In my case, these event listeners were initialized inside a useEffect hook that would re-trigger every time the app was backgrounded and then foregrounded. I solved it by moving the handlers to a useEffect hook without any dependencies.

Example:

useEffect(() => {
  Notifications.events().registerNotificationReceivedForeground(() => { ... });
  ... etc
},[]);