Crash: com.apple.usernotifications.UNUserNotificationServiceConnection.call-out : EXC_BAD_ACCESS KERN_INVALID_ADDRESS

As iOS 17 has begun to roll out, our team has noticed a crash increasing in our production application. This crash revolves around UNUserNotificationCenter and calling .getNotificationSettings(completionHandler:) in order to retrieve the users UNNotificationSettings. Upon adding extra logging to our production app, we've determined that in the callback of getNotificationSettings, trying to access the returned value UNNotificationSettings is what's crashing our app. Here's our stacktrace:

Crashed: com.apple.usernotifications.UNUserNotificationServiceConnection.call-out
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
0  libswiftCore.dylib             0x3fd3ec swift_getObjectType + 40
1  libswiftCore.dylib             0xd660c _print_unlocked<A, B>(_:_:) + 348
2  OurApp                          0x23f8ec closure #1 in closure #1 in MessagingPermissionsModel.authorizationStatus.getter + 155 (MessagingPermissionsModel.swift:155)
3  OurApp                          0x8bd98 partial apply for closure #1 in UNUserNotificationCenter.getNotificationSettings(completionHandler:) + 28
4  OurApp                          0x8b9bc thunk for @escaping @callee_guaranteed (@guaranteed UNNotificationSettings) -> () + 52 (<compiler-generated>:52)
5  libdispatch.dylib              0x26a8 _dispatch_call_block_and_release + 32
6  libdispatch.dylib              0x4300 _dispatch_client_callout + 20
7  libdispatch.dylib              0xb894 _dispatch_lane_serial_drain + 748
8  libdispatch.dylib              0xc3f8 _dispatch_lane_invoke + 432
9  libdispatch.dylib              0x17004 _dispatch_root_queue_drain_deferred_wlh + 288
10 libdispatch.dylib              0x16878 _dispatch_workloop_worker_thread + 404

Here is also the variable in which this crash is happening (along with our extra logging). We wrap the auth status in a RxSwift single for subscribers.

149     private var authorizationStatus: Single<UNAuthorizationStatus> {
150        Logger.debug("MessagingPermissionsModel.authorizationStatus GET")
151        return Single.create { [weak self] observer -> Disposable in
152            Logger.debug("MessagingPermissionsModel.authorizationStatus Single created")
153            self?.userNotificationCenter.getNotifictionSettings { [weak self] settings in
154                Logger.debug("MessagingPermissionsModel.authorizationStatus Retrieved notification settings")
155 (Crashes here) Logger.debug("MessagingPermissionsModel.authorizationStatus Settings \(settings)")
156                Logger.debug("MessagingPermissionsModel.authorizationStatus Auth Status \(settings.authorizationStatus)")
157                Logger.debug("MessagingPermissionsModel.authorizationStatus Observer \(String(describing: observer))")
158                Logger.debug("MessagingPermissionsModel.authorizationStatus Self \(String(describing: self))")
159                observer(.success(settings.authorizationStatus))
160                Logger.debug("MessagingPermissionsModel.authorizationStatus Observer invoked")
161            }
162            Logger.debug("MessagingPermissionsModel.authorizationStatus Disposable will return")
163            return Disposables.create()
164        }
165    }

From what we've seen so far, I'm lead to believe this is a bug in iOS 17.

Post not yet marked as solved Up vote post of SkyGanfor22 Down vote post of SkyGanfor22
557 views