didReceiveRemoteNotification 和 iOS 14 崩溃

Vad*_*aev 5 swift firebase-cloud-messaging ios14

我只有 iOS14 的特定崩溃。我的代码很长一段时间没有改变,所有以前版本的 iOS 上都没有问题,但根据 Crashlytics,我看到了这个堆栈跟踪:

Crashed: com.apple.main-thread
0  libdispatch.dylib              0x19125b7f4 <redacted> + 36
1  libdispatch.dylib              0x1912298c4 dispatch_group_leave + 126
2  MyApp                          0x104e2c72c partial apply for closure #1 in AppDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:) + 4375054124 (<compiler-generated>:4375054124)
3  MyApp                          0x104e2b488 closure #1 in closure #2 in AppDelegate.configureNotificationReceipt(userInfo:completionHandler:) + 194 (AppDelegate.swift:194)
4  MyApp                          0x104e48d78 closure #1 in closure #1 in static AWSController.downloadFile(with:completion:) + 37 (AWSController.swift:37)
5  MyApp                          0x104e5d794 thunk for @escaping @callee_guaranteed () -> () + 4375254932 (<compiler-generated>:4375254932)
6  libdispatch.dylib              0x191226fd0 <redacted> + 32
7  libdispatch.dylib              0x191228ac8 <redacted> + 20
8  libdispatch.dylib              0x19123604c _dispatch_main_queue_callback_4CF + 836
9  CoreFoundation                 0x1915a71e4 <redacted> + 16
10 CoreFoundation                 0x1915a13b4 <redacted> + 2508
11 CoreFoundation                 0x1915a04bc CFRunLoopRunSpecific + 600
12 GraphicsServices               0x1a8025820 GSEventRunModal + 164
13 UIKitCore                      0x193f44734 <redacted> + 1072
14 UIKitCore                      0x193f49e10 UIApplicationMain + 168
15 MyApp                          0x104e16e30 main + 17 (AppCoordinator.swift:17)
16 libdyld.dylib                  0x191267e60 <redacted> + 4
Run Code Online (Sandbox Code Playgroud)

还有来自 Crashlytics 的信息:

BUG IN CLIENT OF LIBDISPATCH: Unbalanced call to dispatch_group_leave()
Run Code Online (Sandbox Code Playgroud)

我用 Firebase/Messaging用于通知。还有一个处理通知的代码:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                 fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    configureNotificationReceipt(userInfo: userInfo) { (result) in
        completionHandler(result)
    }
}
Run Code Online (Sandbox Code Playgroud)

正如我写的那样,此崩溃仅适用于 iOS14,以前不存在。如果我们在谈论Unbalanced call to dispatch_group_leave()我会说它可能与 iOS 的内部逻辑有关,因为我没有在任何地方明确使用 GCD。

也许有人已经遇到过相同的行为并且可以提出任何解决方法?

paj*_*mid 1

我认为是 Firebase iOS SDK 问题,已在版本 7.1.0 上修复。

请参考链接:

  1. https://github.com/firebase/firebase-ios-sdk/pull/6863
  2. https://firebase.google.com/support/release-notes/ios#7.1.0