firebase-ios-sdk: Crash on Xcode 13 beta 5 - Apple M1
Step 1: Describe your environment
- Xcode version: Xcode 13 beta 5 -> MacBook Pro M1
- Firebase SDK version: 8.5.0
- Installation method:
Swift Package Manager - Firebase Component: Messaging
Step 2: Describe the problem
Steps to reproduce:
My team implemented the basic code for Firebase messaging. However the app is crashing upon first launch on my M1. We did some testing here are our results: Xcode 12, iOS 14 simulator, Apple M1 -> Working Xcode 13, iOS 14 simulator, Apple M1 -> Working Xcode 13, iOS 15 simulator, Apple M1 -> Not working Xcode 12, iOS 14 simulator, Intel -> Working Xcode 13, iOS 14 simulator, Intel -> Working Xcode 13, iOS 15 simulator, Intel -> Working
Crash in the GoogleUtilities library on line 97 GULHeartbeatDateStorage.m I don’t know if it’s relevant but here is the reason -> Edit this is wrong it wasn’t captured at the same time as the stack trace: ~Thread 8: EXC_BREAKPOINT (code=1, subcode=0x1036fc4b8)~ It’s the thread 5 which crashed in the stack trace.
thread #1, queue = 'com.apple.main-thread'
frame #0: 0x00000001c809c410 libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001c809c7b4 libsystem_kernel.dylib`mach_msg + 72
frame #2: 0x000000018034f320 CoreFoundation`__CFRunLoopServiceMachPort + 368
frame #3: 0x0000000180349834 CoreFoundation`__CFRunLoopRun + 1136
frame #4: 0x0000000180348eb8 CoreFoundation`CFRunLoopRunSpecific + 572
frame #5: 0x000000018c2745ec GraphicsServices`GSEventRunModal + 160
frame #6: 0x0000000184d337b4 UIKitCore`-[UIApplication _run] + 992
frame #7: 0x0000000184d38138 UIKitCore`UIApplicationMain + 112
frame #8: 0x00000001021bce78 kDrive`main at AppDelegate.swift:34:7
frame #9: 0x0000000103109c04 dyld_sim`start_sim + 20
thread #2, queue = 'com.apple.root.utility-qos'
frame #0: 0x00000001c809c44c libsystem_kernel.dylib`semaphore_wait_trap + 8
frame #1: 0x0000000103585ec8 libdispatch.dylib`_dispatch_sema4_wait + 24
frame #2: 0x0000000103586540 libdispatch.dylib`_dispatch_semaphore_wait_slow + 128
frame #3: 0x00000001808b9ecc Foundation`-[NSFileCoordinator(NSPrivate) _blockOnAccessClaim:withAccessArbiter:] + 356
frame #4: 0x00000001808bb140 Foundation`-[NSFileCoordinator(NSPrivate) _coordinateWritingItemAtURL:options:error:byAccessor:] + 568
frame #5: 0x00000001808b8c6c Foundation`-[NSFileCoordinator coordinateWritingItemAtURL:options:error:byAccessor:] + 92
frame #6: 0x000000010960439c kDriveCore`-[GULHeartbeatDateStorage checkAndCreateDirectory:](self=0x0000600000f37580, _cmd="checkAndCreateDirectory:", directoryPathURL=0x0000600002c7c5a0) at GULHeartbeatDateStorage.m:78:3
frame #7: 0x0000000109604198 kDriveCore`-[GULHeartbeatDateStorage fileURL](self=0x0000600000f37580, _cmd="fileURL") at GULHeartbeatDateStorage.m:50:5
frame #8: 0x00000001096045b0 kDriveCore`-[GULHeartbeatDateStorage heartbeatDateForTag:](self=0x0000600000f37580, _cmd="heartbeatDateForTag:", tag=0x00000001098e4688) at GULHeartbeatDateStorage.m:97:57
frame #9: 0x00000001096140bc kDriveCore`+[FIRHeartbeatInfo updateIfNeededHeartbeatDateForTag:](self=FIRHeartbeatInfo, _cmd="updateIfNeededHeartbeatDateForTag:", heartbeatTag=0x00000001098e4688) at FIRHeartbeatInfo.m:42:29
frame #10: 0x0000000109614270 kDriveCore`+[FIRHeartbeatInfo heartbeatCodeForTag:](self=FIRHeartbeatInfo, _cmd="heartbeatCodeForTag:", heartbeatTag=0x00000001098e4688) at FIRHeartbeatInfo.m:56:31
frame #11: 0x00000001096211d4 kDriveCore`__96-[FIRInstallationsAPIService requestWithURL:HTTPMethod:bodyDict:refreshToken:additionalHeaders:]_block_invoke(.block_descriptor=0x0000600002b129e0) at FIRInstallationsAPIService.m:278:34
frame #12: 0x00000001095f95e0 kDriveCore`__38+[FBLPromise(.block_descriptor=0x0000600001dc5040) onQueue:do:]_block_invoke at FBLPromise+Do.m:33:16
frame #13: 0x0000000103584028 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #14: 0x0000000103585828 libdispatch.dylib`_dispatch_client_callout + 16
frame #15: 0x00000001035980ac libdispatch.dylib`_dispatch_root_queue_drain + 1336
frame #16: 0x0000000103598814 libdispatch.dylib`_dispatch_worker_thread2 + 188
frame #17: 0x00000001c80effec libsystem_pthread.dylib`_pthread_wqthread + 212
thread #3
frame #0: 0x00000001c80eedf0 libsystem_pthread.dylib`start_wqthread
thread #4
frame #0: 0x00000001c809df64 libsystem_kernel.dylib`__workq_kernreturn + 8
* thread #5, queue = 'com.google.FIRCoreDiagnostics', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1035bc4b8)
frame #0: 0x00000001035bc4b8 libdispatch.dylib`_dispatch_sema4_wait.cold.3 + 36
frame #1: 0x0000000103585ee4 libdispatch.dylib`_dispatch_sema4_wait + 52
frame #2: 0x0000000103586540 libdispatch.dylib`_dispatch_semaphore_wait_slow + 128
frame #3: 0x00000001808b9ecc Foundation`-[NSFileCoordinator(NSPrivate) _blockOnAccessClaim:withAccessArbiter:] + 356
frame #4: 0x00000001808babd4 Foundation`-[NSFileCoordinator(NSPrivate) _coordinateReadingItemAtURL:options:error:byAccessor:] + 628
frame #5: 0x00000001808b8b48 Foundation`-[NSFileCoordinator coordinateReadingItemAtURL:options:error:byAccessor:] + 92
* frame #6: 0x000000010960465c kDriveCore`-[GULHeartbeatDateStorage heartbeatDateForTag:](self=0x0000600000f3ff80, _cmd="heartbeatDateForTag:", tag=0x00000001098e2968) at GULHeartbeatDateStorage.m:97:3
frame #7: 0x000000010960c274 kDriveCore`-[FIRCoreDiagnostics setHeartbeatFlagIfNeededToConfig:](self=0x0000600000f3fd20, _cmd="setHeartbeatFlagIfNeededToConfig:", config=0x000000016dec2800) at FIRCoreDiagnostics.m:531:7
frame #8: 0x000000010960c024 kDriveCore`__42-[FIRCoreDiagnostics sendDiagnosticsData:]_block_invoke(.block_descriptor=0x000060000062e070) at FIRCoreDiagnostics.m:513:5
frame #9: 0x0000000103584028 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #10: 0x0000000103585828 libdispatch.dylib`_dispatch_client_callout + 16
frame #11: 0x000000010358ca5c libdispatch.dylib`_dispatch_lane_serial_drain + 756
frame #12: 0x000000010358d710 libdispatch.dylib`_dispatch_lane_invoke + 436
frame #13: 0x000000010359977c libdispatch.dylib`_dispatch_workloop_worker_thread + 820
frame #14: 0x00000001c80f0028 libsystem_pthread.dylib`_pthread_wqthread + 272
thread #6
frame #0: 0x00000001c80eedf0 libsystem_pthread.dylib`start_wqthread
thread #7
frame #0: 0x00000001c80eedf0 libsystem_pthread.dylib`start_wqthread
thread #8, name = 'com.apple.uikit.eventfetch-thread'
frame #0: 0x00000001c809c410 libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001c809c7b4 libsystem_kernel.dylib`mach_msg + 72
frame #2: 0x000000018034f320 CoreFoundation`__CFRunLoopServiceMachPort + 368
frame #3: 0x0000000180349834 CoreFoundation`__CFRunLoopRun + 1136
frame #4: 0x0000000180348eb8 CoreFoundation`CFRunLoopRunSpecific + 572
frame #5: 0x000000018080ec88 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
frame #6: 0x000000018080ef40 Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 88
frame #7: 0x0000000184de6dcc UIKitCore`-[UIEventFetcher threadMain] + 472
frame #8: 0x000000018083885c Foundation`__NSThread__start__ + 724
frame #9: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
thread #9, name = 'com.apple.CFSocket.private'
frame #0: 0x00000001c80a60c0 libsystem_kernel.dylib`__select + 8
frame #1: 0x0000000180365224 CoreFoundation`__CFSocketManager + 620
frame #2: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
thread #10
frame #0: 0x00000001c809f6bc libsystem_kernel.dylib`__semwait_signal + 8
frame #1: 0x00000001800fb86c libsystem_c.dylib`nanosleep + 212
frame #2: 0x00000001800fb66c libsystem_c.dylib`sleep + 44
frame #3: 0x000000010874a23c kDriveCore`monitorCachedData(userData=0x00000001096e89cd) at SentryCrashCachedData.c:139:9
frame #4: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
thread #11, name = 'Realm notification listener'
frame #0: 0x00000001c80a1e2c libsystem_kernel.dylib`kevent + 8
frame #1: 0x0000000108d856bc kDriveCore`realm::_impl::ExternalCommitHelper::listen(this=0x00006000006c3030) at external_commit_helper.cpp:220:15
frame #2: 0x0000000108d88ac0 kDriveCore`realm::_impl::ExternalCommitHelper::ExternalCommitHelper(this=0x0000600000a50b38)::$_0::operator()() const at external_commit_helper.cpp:176:13
frame #3: 0x0000000108d88a5c kDriveCore`decltype(__f=0x0000600000a50b38)::$_0>(fp)()) std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) at type_traits:3747:1
frame #4: 0x0000000108d889bc kDriveCore`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(__t=size=2, (null)=__tuple_indices<> @ 0x000000016e20af6f)::$_0>&, std::__1::__tuple_indices<>) at thread:280:5
frame #5: 0x0000000108d880c0 kDriveCore`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >(__vp=0x0000600000a50b30) at thread:291:5
frame #6: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
thread #12, name = 'AVAudioSession Notify Thread'
frame #0: 0x00000001c809c410 libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001c809c7b4 libsystem_kernel.dylib`mach_msg + 72
frame #2: 0x000000018034f320 CoreFoundation`__CFRunLoopServiceMachPort + 368
frame #3: 0x0000000180349834 CoreFoundation`__CFRunLoopRun + 1136
frame #4: 0x0000000180348eb8 CoreFoundation`CFRunLoopRunSpecific + 572
frame #5: 0x00000001bb464428 AudioSession`CADeprecated::GenericRunLoopThread::Entry(void*) + 156
frame #6: 0x00000001bb476584 AudioSession`CADeprecated::CAPThread::Entry(CADeprecated::CAPThread*) + 84
frame #7: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
thread #13, name = 'AMCP Logging Spool'
frame #0: 0x00000001c809c44c libsystem_kernel.dylib`semaphore_wait_trap + 8
frame #1: 0x00000001a71a61f4 caulk`caulk::mach::semaphore::wait_or_error() + 24
frame #2: 0x00000001a71a1198 caulk`caulk::concurrent::details::worker_thread::run() + 52
frame #3: 0x00000001a71a1210 caulk`void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*> > >(void*) + 48
frame #4: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
thread #14, name = 'com.apple.NSURLConnectionLoader'
frame #0: 0x00000001c809c410 libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001c809c7b4 libsystem_kernel.dylib`mach_msg + 72
frame #2: 0x000000018034f320 CoreFoundation`__CFRunLoopServiceMachPort + 368
frame #3: 0x0000000180349834 CoreFoundation`__CFRunLoopRun + 1136
frame #4: 0x0000000180348eb8 CoreFoundation`CFRunLoopRunSpecific + 572
frame #5: 0x0000000183df543c CFNetwork`___lldb_unnamed_symbol11236$$CFNetwork + 424
frame #6: 0x000000018083885c Foundation`__NSThread__start__ + 724
frame #7: 0x00000001c80f3c8c libsystem_pthread.dylib`_pthread_start + 288
Relevant Code:
The whole code is on our github but here are the most relevant parts:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)
application.registerForRemoteNotifications()
Messaging.messaging().delegate = self
//...
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
let dataDict = ["token": fcmToken ?? ""]
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 15 (7 by maintainers)
Hi everyone,
It seems that there were some synchronization issues that originated with the use of
NSFileCoordinator. We are planning on publishing a patch update for one of Firebase’s dependencies within the next day or so. At that point, you’ll be to pull in the update by updating to the latest package versions for SPM (or updating your pods for CocoaPods).While the patch update should fix this issue’s specific crash, there seems to be a larger issue in Xcode 13b5 you can follow at https://developer.apple.com/forums/thread/687682 (thanks @alexfringes for the mention).
We have done some experiments and this semaphore related crash appears in apps running in the simulator on an M1 machine (for Xcode 13b5) regardless of whether or not they use Firebase.
We will be following the Apple forums thread for updates regarding this broader issue.
Thanks @PhilippeWeidmann for reporting the issue!
The Release Notes reference to the issue and workaround is at https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-15-beta-release-notes
For anyone still running into the underlying bug, a workaround was mentioned in today’s beta release notes (thanks to sjs from the dev forums for pinging the aforementioned thread with this):
In case it’s of any use, I thought I’d highlight a thread documenting seemingly similar issues (some not involving Firebase) from the Apple dev forums: https://developer.apple.com/forums/thread/687682
Thank you for the updates. We were able to reproduce the issue and are investigating it.
I have not seen it on RC. When RC came out, I reverted the workaround Apple posted of disabling backtrace recording and have been using RC + simulators on an M1 without issues since then.