[Bug]: Main thread is getting blocked during initialisation
What happened?
The app's main thread hanged for more than 3 seconds due to usage of synchronous deprecated API applicationIconBadgeNumber.
Steps to reproduce?
Can not be reliably reproduced locally due to nature of the issue.
The info is gathered using BugSnag error reporter from one of our users.
What did you expect to happen?
The app's main thread is not blocked during OneSignal initialisation.
OneSignal iOS SDK version
Release 5.2.1
iOS version
17
Specific iOS version
17.0.2
Relevant log output
Thread 0 - com.apple.usernotifications.UNUserNotificationServiceConnection - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x11d4 _mach_msg2_trap
1 libsystem_kernel.dylib +0xf6c _mach_msg2_internal
2 libsystem_kernel.dylib +0xe84 _mach_msg_overwrite
3 libsystem_kernel.dylib +0xcc4 _mach_msg
4 libdispatch.dylib +0x1eefc __dispatch_mach_send_and_wait_for_reply
5 libdispatch.dylib +0x1f29c _dispatch_mach_send_with_result_and_wait_for_reply
6 libxpc.dylib +0x106cc _xpc_connection_send_message_with_reply_sync
7 Foundation +0x396bc ___NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__
8 Foundation +0x213b8 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]
9 Foundation +0x3b4bc -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:]
10 Foundation +0x3b3e8 __NSXPCDistantObjectSimpleMessageSend2
11 UserNotifications +0x46fc ___70-[UNUserNotificationServiceConnection badgeNumberForBundleIdentifier:]_block_invoke
12 libdispatch.dylib +0x42fc __dispatch_client_callout
13 libdispatch.dylib +0x136b0 __dispatch_lane_barrier_sync_invoke_and_complete
14 UserNotifications +0x5090 -[UNUserNotificationServiceConnection badgeNumberForBundleIdentifier:]
15 UserNotifications +0x4f40 -[UNUserNotificationCenter badgeNumber]
16 UIKitCore +0x390530 -[UIApplication applicationIconBadgeNumber]
17 OneSignalNotifications +0x7580 +[OSNotificationsManager clearBadgeCount:fromClearAll:]
18 OneSignalFramework +0x9188 +[OneSignal init]
<redacted>
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I'm seeing the same thing ... launch time is really slow after adding the OneSignal SDK for iOS.
+1
+1 This crash happened during an app review and caused us to get rejected. Any workarounds??
+1 crashed on app review and was rejected.
seems like we have the same crash
Thread 0 name: Dispatch queue: com.apple.usernotifications.UNUserNotificationServiceConnection
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x1dfef0728 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1dfef3e38 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x1dfef3d50 mach_msg_overwrite + 424
3 libsystem_kernel.dylib 0x1dfef3b9c mach_msg + 24
4 libdispatch.dylib 0x197d70f14 _dispatch_mach_send_and_wait_for_reply + 544
5 libdispatch.dylib 0x197d712b4 dispatch_mach_send_with_result_and_wait_for_reply + 60
6 libxpc.dylib 0x21747a9a0 xpc_connection_send_message_with_reply_sync + 256
7 Foundation 0x18ecece2c __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16
8 Foundation 0x18ece9594 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2160
9 Foundation 0x18ed50adc -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:] + 128
10 Foundation 0x18ed50898 _NSXPCDistantObjectSimpleMessageSend2 + 68
11 UserNotifications 0x1bae21418 __70-[UNUserNotificationServiceConnection badgeNumberForBundleIdentifier:]_block_invoke + 240
12 libdispatch.dylib 0x197d560d0 _dispatch_client_callout + 20
13 libdispatch.dylib 0x197d65750 _dispatch_lane_barrier_sync_invoke_and_complete + 56
14 UserNotifications 0x1bae210d8 -[UNUserNotificationServiceConnection badgeNumberForBundleIdentifier:] + 292
15 UserNotifications 0x1bae20f88 -[UNUserNotificationCenter badgeNumber] + 48
16 UIKitCore 0x192c39070 -[UIApplication applicationIconBadgeNumber] + 44
17 OneSignalNotifications 0x100f73708 +[OSNotificationsManager clearBadgeCount:fromClearAll:] + 224
18 OneSignalFramework 0x100f3d1ac +[OneSignal init] + 544
And once again, we have the same crash from app review team:
Thread 0 name: Dispatch queue: com.apple.usernotifications.UNUserNotificationServiceConnection
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x1ddae2688 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1ddae5d98 mach_msg2_internal + 80
2 libsystem_kernel.dylib 0x1ddae5cb0 mach_msg_overwrite + 424
3 libsystem_kernel.dylib 0x1ddae5afc mach_msg + 24
4 libdispatch.dylib 0x195440f14 _dispatch_mach_send_and_wait_for_reply + 544
5 libdispatch.dylib 0x1954412b4 dispatch_mach_send_with_result_and_wait_for_reply + 60
6 libxpc.dylib 0x215c86930 xpc_connection_send_message_with_reply_sync + 256
7 Foundation 0x18c3723ac __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16
8 Foundation 0x18c36eb14 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2160
9 Foundation 0x18c3d614c -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:] + 128
10 Foundation 0x18c3d5f08 _NSXPCDistantObjectSimpleMessageSend2 + 68
11 UserNotifications 0x1b86cff9c __70-[UNUserNotificationServiceConnection badgeNumberForBundleIdentifier:]_block_invoke + 240
12 libdispatch.dylib 0x1954260d0 _dispatch_client_callout + 20
13 libdispatch.dylib 0x195435750 _dispatch_lane_barrier_sync_invoke_and_complete + 56
14 UserNotifications 0x1b86cfc5c -[UNUserNotificationServiceConnection badgeNumberForBundleIdentifier:] + 292
15 UserNotifications 0x1b86cfb0c -[UNUserNotificationCenter badgeNumber] + 48
16 UIKitCore 0x1902bd8cc -[UIApplication applicationIconBadgeNumber] + 44
17 OneSignalNotifications 0x103693708 +[OSNotificationsManager clearBadgeCount:fromClearAll:] + 224
18 OneSignalFramework 0x10365d1ac +[OneSignal init] + 544
+1
Hi all, thanks for your patience, the SDK has dropped its usage of [UIApplication applicationIconBadgeNumber] in Release 5.2.13.
Please upgrade and reach out if you are still seeing any issues.