Facebook-ios-sdk: Facebook SDK crashing on first launch after updating to version 9.0.0

Created on 21 Jan 2021  路  5Comments  路  Source: facebook/facebook-ios-sdk

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

  • Xcode Version: 12.3
  • Installation Platform & Verison: [Cocoapods] version 1.10.1

Expected Results

I expected my application to run as usual.

Actual Results

Facebook SDK crashed on first launch after sdk version updated to 9.0.0.
It runs as usual on other launches.

Steps to Reproduce

Update Facebook SDK from a lower version to version 9.0.0. Then run the app, it crashes.
It will run as usual on second launch.

Code Samples & Details

I didn't do any advanced integration, just called activateApp method.

AppEvents.activateApp()

Most helpful comment

Hi @alperkayabasi , @ishch , can you remove the call of activateapp and use following in application:didFinishLaunchingWithOptions: instead to see if the issue can be fixed? Thanks

[[FBSDKApplicationDelegate sharedInstance] application:application
                             didFinishLaunchingWithOptions:launchOptions];

All 5 comments

Hi @alperkayabasi , thanks for the report. Can you share the crash log/stacktrace?

Hi, i have the same problem

stacktrace

```

  • thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x0000000103d5f613 libdispatch.dylib_dispatch_once_wait.cold.1 + 14 frame #1: 0x0000000103d2d2bc libdispatch.dylib_dispatch_once_wait + 97

    • frame #2: 0x0000000101d6cde8 FBSDKCoreKit+[FBSDKAppEvents singleton] [inlined] _dispatch_once(predicate=0x0000000101ea0410, block=0x0000000101d6ce10) at once.h:84:3 frame #3: 0x0000000101d6cdcd FBSDKCoreKit+FBSDKAppEvents singleton at FBSDKAppEvents.m:925

      frame #4: 0x0000000101d6cb66 FBSDKCoreKit+[FBSDKAppEvents logInternalEvent:valueToSum:parameters:isImplicitlyLogged:accessToken:](self=FBSDKAppEvents, _cmd="logInternalEvent:valueToSum:parameters:isImplicitlyLogged:accessToken:", eventName=@"fb_sdk_settings_changed", valueToSum=0x0000000000000000, parameters=4 key/value pairs, isImplicitlyLogged=YES, accessToken=0x0000000000000000) at FBSDKAppEvents.m:901:6 frame #5: 0x0000000101d6c83f FBSDKCoreKit+FBSDKAppEvents logInternalEvent:parameters:isImplicitlyLogged: at FBSDKAppEvents.m:863:3

      frame #6: 0x0000000101e1b804 FBSDKCoreKit+[FBSDKSettings _logIfSDKSettingsChanged](self=FBSDKSettings, _cmd="_logIfSDKSettingsChanged") at FBSDKSettings.m:447:5 frame #7: 0x0000000101e17d0e FBSDKCoreKit+FBSDKSettings initialize at FBSDKSettings.m:106:5

      frame #8: 0x00007fff20178453 libobjc.A.dylibCALLING_SOME_+initialize_METHOD + 17 frame #9: 0x00007fff20179326 libobjc.A.dylibinitializeNonMetaClass + 717

      frame #10: 0x00007fff2017a3ad libobjc.A.dylibinitializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) + 173 frame #11: 0x00007fff20185b8f libobjc.A.dyliblookUpImpOrForward + 668

      frame #12: 0x00007fff2017421b libobjc.A.dylib_objc_msgSend_uncached + 75 frame #13: 0x0000000101e148a6 FBSDKCoreKit+FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock: at FBSDKServerConfigurationManager.m:118:23

      frame #14: 0x0000000101d6eacb FBSDKCoreKit-[FBSDKAppEvents fetchServerConfiguration:](self=0x0000600001ea63f0, _cmd="fetchServerConfiguration:", callback=(null)) at FBSDKAppEvents.m:1078:3 frame #15: 0x0000000101d69821 FBSDKCoreKit-FBSDKAppEvents init at FBSDKAppEvents.m:375:5

      frame #16: 0x0000000101d6ce3c FBSDKCoreKit__27+[FBSDKAppEvents singleton]_block_invoke(.block_descriptor=0x00007ffeef7fd368) at FBSDKAppEvents.m:926:14 frame #17: 0x0000000103d2c9c8 libdispatch.dylib_dispatch_client_callout + 8

      frame #18: 0x0000000103d2df33 libdispatch.dylib_dispatch_once_callout + 66 frame #19: 0x0000000101d6cde8 FBSDKCoreKit+[FBSDKAppEvents singleton] [inlined] _dispatch_once(predicate=0x0000000101ea0410, block=0x0000000101d6ce10) at once.h:84:3

      frame #20: 0x0000000101d6cdcd FBSDKCoreKit+[FBSDKAppEvents singleton](self=FBSDKAppEvents, _cmd="singleton") at FBSDKAppEvents.m:925 frame #21: 0x0000000101d6b201 FBSDKCoreKit+FBSDKAppEvents activateApp at FBSDKAppEvents.m:639:30

      frame #22: 0x00000001008d8a29 XXXAppDelegate.application(application=0x00007fb3f0c044a0, launchOptions=nil, self=0x0000600003db92e0) at AppDelegate.swift:32:19 frame #23: 0x00000001008db173 XXX@objc AppDelegate.application(_:didFinishLaunchingWithOptions:) at :0

      frame #24: 0x00007fff2467146d UIKitCore-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232 frame #25: 0x00007fff24672fef UIKitCore-[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3919

      frame #26: 0x00007fff246789fd UIKitCore-[UIApplication _runWithMainScene:transitionContext:completion:] + 1237 frame #27: 0x00007fff23ca37bb UIKitCore-[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122

      frame #28: 0x00007fff2423120a UIKitCore_UIScenePerformActionsWithLifecycleActionMask + 88 frame #29: 0x00007fff23ca42ca UIKitCore__101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198

      frame #30: 0x00007fff23ca3d8e UIKitCore-[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 474 frame #31: 0x00007fff23ca40fb UIKitCore-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 819

      frame #32: 0x00007fff23ca398f UIKitCore-[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345 frame #33: 0x00007fff23cabc27 UIKitCore__186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 178

      frame #34: 0x00007fff2413afe7 UIKitCore+[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 871 frame #35: 0x00007fff2424dab2 UIKitCore_UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240

      frame #36: 0x00007fff23cab92d UIKitCore-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 361 frame #37: 0x00007fff23acf034 UIKitCore__64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 797

      frame #38: 0x00007fff23acdade UIKitCore-[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253 frame #39: 0x00007fff23acec6d UIKitCore-[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 208

      frame #40: 0x00007fff24676e9c UIKitCore-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 508 frame #41: 0x00007fff241633f3 UIKitCore-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358

      frame #42: 0x00007fff25a7e0ae FrontBoardServices-[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 391 frame #43: 0x00007fff25aa6b41 FrontBoardServices__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102

      frame #44: 0x00007fff25a8bad5 FrontBoardServices-[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209 frame #45: 0x00007fff25aa680f FrontBoardServices__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352

      frame #46: 0x0000000103d2c9c8 libdispatch.dylib_dispatch_client_callout + 8 frame #47: 0x0000000103d2f910 libdispatch.dylib_dispatch_block_invoke_direct + 295

      frame #48: 0x00007fff25acc7a5 FrontBoardServices__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30 frame #49: 0x00007fff25acc48b FrontBoardServices-[FBSSerialQueue _targetQueue_performNextIfPossible] + 433

      frame #50: 0x00007fff25acc950 FrontBoardServices-[FBSSerialQueue _performNextFromRunLoopSource] + 22 frame #51: 0x00007fff2038c37a CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

      frame #52: 0x00007fff2038c272 CoreFoundation__CFRunLoopDoSource0 + 180 frame #53: 0x00007fff2038b754 CoreFoundation__CFRunLoopDoSources0 + 248

      frame #54: 0x00007fff20385f1f CoreFoundation__CFRunLoopRun + 878 frame #55: 0x00007fff203856c6 CoreFoundationCFRunLoopRunSpecific + 567

      frame #56: 0x00007fff2b76adb3 GraphicsServicesGSEventRunModal + 139 frame #57: 0x00007fff24675187 UIKitCore-[UIApplication _run] + 912

      frame #58: 0x00007fff2467a038 UIKitCoreUIApplicationMain + 101 frame #59: 0x00000001008dfdab XXXmain at AppDelegate.swift:22:7

      frame #60: 0x00007fff20256409 libdyld.dylibstart + 1 frame #61: 0x00007fff20256409 libdyld.dylibstart + 1

Hi @alperkayabasi , @ishch , can you remove the call of activateapp and use following in application:didFinishLaunchingWithOptions: instead to see if the issue can be fixed? Thanks

[[FBSDKApplicationDelegate sharedInstance] application:application
                             didFinishLaunchingWithOptions:launchOptions];

The reason is that FBSDK v9.0.0 removes the auto init of SDK and it's required to initialize the SDK explicitly with the initializeSDK method or implicitly by calling it in applicationDidFinishLaunching before calling activateApp

This is still crashing app after trying both implementations and removing activateApp.
Previous FB SDK version was 6.5.2
pod 'FBSDKCoreKit/Swift', '6.5.2'

New one
pod 'FBSDKCoreKit', '9.0.0'

Was this page helpful?
0 / 5 - 0 ratings