firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.67k stars 1.49k forks source link

Firebase Crashing internally at startup [FIRMessagingTokenFetchOperation handleResponseWithData:response:error:] #10710

Closed DanielReyesDev closed 1 year ago

DanielReyesDev commented 1 year ago

Description

Hi, Yesterday we detected an aggressive spike of crashes right after our app is trying to execute FirebaseApp.configure() to some users. The stacktrace that we're getting is:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  5

Last Exception Backtrace:
0   CoreFoundation                  0x1aed0d288 __exceptionPreprocess + 220 (NSException.m:200)
1   libobjc.A.dylib                 0x1c7a3d744 objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                  0x1aedeaef0 +[NSObject(NSObject) doesNotRecognizeSelector:] + 144 (NSObject.m:140)
3   CoreFoundation                  0x1aeca1e98 ___forwarding___ + 1764 (NSForwarding.m:3577)
4   CoreFoundation                  0x1aeca0f70 _CF_forwarding_prep_0 + 96 (:-1)
5   Walmart.mx                      0x106c6e2bc -[FIRMessagingTokenFetchOperation handleResponseWithData:response:error:] + 1012
6   Walmart.mx                      0x106c6de9c __56-[FIRMessagingTokenFetchOperation performTokenOperation]_block_invoke + 100
7   CFNetwork                       0x1af4b9b6c __40-[__NSURLSessionLocal taskForClassInfo:]_block_invoke + 532 (LocalSession.mm:675)
8   CFNetwork                       0x1af4cad80 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke_2 + 196 (LocalSessionTask.mm:543)
9   libdispatch.dylib               0x1ae972e6c _dispatch_call_block_and_release + 32 (init.c:1517)
10  libdispatch.dylib               0x1ae974a30 _dispatch_client_callout + 20 (object.m:560)
11  libdispatch.dylib               0x1ae97c124 _dispatch_lane_serial_drain + 668 (inline_internal.h:2622)
12  libdispatch.dylib               0x1ae97ccb4 _dispatch_lane_invoke + 444 (queue.c:3944)
13  libdispatch.dylib               0x1ae987500 _dispatch_workloop_worker_thread + 648 (queue.c:6732)
14  libsystem_pthread.dylib         0x21fec90bc _pthread_wqthread + 288 (pthread.c:2599)
15  libsystem_pthread.dylib         0x21fec8e5c start_wqthread + 8 (:-1)

spike

Reproducing the issue

No response

Firebase SDK Version

9.4.0

Xcode Version

13.4

Installation Method

Carthage

Firebase Product(s)

Analytics, Crashlytics, Messaging, Remote Config

Targeted Platforms

iOS

Relevant Log Output

2023-01-17 17:27:27.725849-0600 Walmart.mx[33909:1905408] 9.4.0 - [FirebaseCore][I-COR000003] The default Firebase app has not yet been configured. Add `FirebaseApp.configure()` to your application initialization. This can be done in in the App Delegate's application(_:didFinishLaunchingWithOptions:)` (or the `@main` struct's initializer in SwiftUI). Read more: https://goo.gl/ctyzm8.

If using Swift Package Manager, the project's Package.resolved

No response

If using CocoaPods, the project's Podfile.lock

No response

google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

paulb777 commented 1 year ago

Did you add the -ObjC flag to "Other Linker Flags" in "Build Settings"?

Recent backend changes may be causing a new error and the NSError+FIRMessaging.m category may not be linked.

DanielReyesDev commented 1 year ago

Did you add the -ObjC flag to "Other Linker Flags" in "Build Settings"?

Recent backend changes may be causing a new error and the NSError+FIRMessaging.m category may not be linked.

We added the -ObjC flag but we got a similar crash:

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x00000001cc05de60 in __pthread_kill ()
#1  0x00000001cc0b13c0 in pthread_kill ()
#2  0x00000001801023f4 in abort ()
#3  0x000000018023feb4 in abort_message ()
#4  0x000000018023066c in demangling_terminate_handler() ()
#5  0x000000018017aea0 in _objc_terminate() ()
#6  0x000000018023f364 in std::__terminate(void (*)()) ()
#7  0x0000000180241b44 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) ()
#8  0x0000000180241b04 in __cxa_throw ()
#9  0x0000000180198284 in objc_exception_throw ()
#10 0x00000001804031ec in +[NSObject(NSObject) doesNotRecognizeSelector:] ()
#11 0x00000001803f7fe0 in ___forwarding___ ()
#12 0x00000001803fa07c in _CF_forwarding_prep_0 ()
#13 0x0000000107227ba4 in -[FIRInstallationsStore installationExistsForAppID:appName:] ()
#14 0x00000001072274e8 in -[FIRInstallationsStore installationForAppID:appName:] ()
#15 0x0000000107222ab4 in -[FIRInstallationsIDController getStoredInstallation] ()
#16 0x0000000107222900 in -[FIRInstallationsIDController createGetInstallationItemPromise] ()
#17 0x0000000107222720 in __131-[FIRInstallationsIDController initWithGoogleAppID:appName:installationsStore:APIService:IIDStore:IIDTokenStore:backoffController:]_block_invoke ()
#18 0x0000000107227010 in -[FIRInstallationsSingleOperationPromiseCache getExistingPendingOrCreateNewPromise] ()
#19 0x0000000107222854 in -[FIRInstallationsIDController getInstallationItem] ()
#20 0x000000010721dffc in -[FIRInstallations installationIDWithCompletion:] ()
#21 0x00000001071daa4c in +[FIRAnalytics updateFirebaseInstallationID] ()
#22 0x00000001071da99c in +[FIRAnalytics startWithConfiguration:options:] ()
#23 0x00000001071dec8c in -[FIRApp configureCore] ()
#24 0x00000001071de8f8 in +[FIRApp addAppToAppDictionary:] ()
#25 0x00000001071de068 in +[FIRApp configureWithName:options:] ()
#26 0x00000001071ddca4 in +[FIRApp configureWithOptions:] ()
#27 0x00000001071ddc30 in +[FIRApp configure] ()
#28 0x0000000106865354 in static FIRApp.start(_:) at /Users/vn52you/ios/glass-app/Plugins/CrashLogger/CrashLogger/Plugin/CrashLoggerPluginAPI.swift:74
#29 0x0000000106865394 in protocol witness for static CrashLoggingConfigurable.start(_:) in conformance FIRApp ()
#30 0x0000000106864794 in CrashLoggerPluginAPI.init(type:quimbySource:analyticsSessionProvider:crashlytics:) at /Users/vn52you/ios/glass-app/Plugins/CrashLogger/CrashLogger/Plugin/CrashLoggerPluginAPI.swift:28
#31 0x000000010686463c in CrashLoggerPluginAPI.__allocating_init(type:quimbySource:analyticsSessionProvider:crashlytics:) ()
#32 0x0000000106865090 in CrashLoggerPluginAPI.__allocating_init(container:) at /Users/vn52you/ios/glass-app/Plugins/CrashLogger/CrashLogger/Plugin/CrashLoggerPluginAPI.swift:47
#33 0x0000000102d86ff0 in closure #21 in BootstrapCoordinator.start() at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/Startup/BootstrapCoordinator.swift:148
#34 0x000000013032a140 in closure #1 in Container.registerProvidingChild<τ_0_0>(_:_:) at /Users/vn52you/ios/glass-app/Platform/Modules/WalmartPlatform/WalmartPlatform/Container/Container+extension.swift:46
#35 0x000000013032b6dc in closure #1 in Container.register<τ_0_0>(_:_:) at /Users/vn52you/ios/glass-app/Platform/Modules/WalmartPlatform/WalmartPlatform/Container/Container.swift:203
#36 0x000000013032da8c in Container.resolve<τ_0_0>() at /Users/vn52you/ios/glass-app/Platform/Modules/WalmartPlatform/WalmartPlatform/Container/Container.swift:505
#37 0x000000013032d258 in Container.getIfRegistered<τ_0_0>(_:) at /Users/vn52you/ios/glass-app/Platform/Modules/WalmartPlatform/WalmartPlatform/Container/Container.swift:335
#38 0x000000013032cf24 in Container.get<τ_0_0>(_:) at /Users/vn52you/ios/glass-app/Platform/Modules/WalmartPlatform/WalmartPlatform/Container/Container.swift:318
#39 0x0000000102d8a750 in BootstrapCoordinator.loadStartupPlugins() at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/Startup/BootstrapCoordinator.swift:302
#40 0x0000000102d85944 in BootstrapCoordinator.start() at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/Startup/BootstrapCoordinator.swift:291
#41 0x0000000102d7ca2c in AppStartupCoordinator.startBootstrapCoordinator() at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/Startup/AppStartupCoordinator.swift:91
#42 0x0000000102d7c470 in AppStartupCoordinator.start() at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/Startup/AppStartupCoordinator.swift:44
#43 0x0000000102d7ae38 in AppDelegate.application(_:didFinishLaunchingWithOptions:) at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/AppDelegate.swift:63
#44 0x0000000102d7af54 in @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) ()
#45 0x0000000184d84e20 in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] ()
#46 0x0000000184d86760 in -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] ()
#47 0x0000000184d8bf98 in -[UIApplication _runWithMainScene:transitionContext:completion:] ()
#48 0x00000001843ac164 in -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] ()
#49 0x0000000184d886a8 in -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] ()
#50 0x0000000184d88a8c in -[UIApplication _run] ()
#51 0x0000000184d8d634 in UIApplicationMain ()
#52 0x00000001b6946224 in UIApplicationMain(_:_:_:_:) ()
#53 0x0000000102d7b038 in static UIApplicationDelegate.main() ()
#54 0x0000000102d7afc0 in static AppDelegate.$main() at /Users/vn52you/ios/glass-app/markets/mexico/Walmart.mx/AppDelegate.swift:14
#55 0x0000000102d7b4e4 in main ()
#56 0x000000012e3d9cd8 in start_sim ()
#57 0x000000012e22108c in start ()
paulb777 commented 1 year ago

I'm not sure what selector is not being seen. It would be helpful if you could catch that in the debugger or from the crash reporter.

Even though something seems strange about how the app is linked, the recent behavior change may be related to https://github.com/firebase/firebase-ios-sdk/issues/10679.

paulb777 commented 1 year ago

Going to close since it seems resolved by the server rollback discussed in #10679