facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.77k stars 3.53k forks source link

Upgrade from 14.0 to 16.0, The App launch time has increased 100ms #2193

Open xidipeng opened 1 year ago

xidipeng commented 1 year ago

Checklist before submitting a bug report

Xcode version

14.2.0

Facebook iOS SDK version

16.0.1

Dependency Manager

CocoaPods

SDK Framework

FBSDKLoginKit

Goals

Upgrade from SDK 14.0 to 16.0, My project is OC,The App launch time has increased 100ms.

FB SDK

Expected results

Hope to optimize the SDK in launch.

Actual results

no stack trace

Steps to reproduce

No response

nolimitdev commented 1 year ago

Really someone initializes FB SDK as recommended in doc at app start? I immediately knew that it is not good idea. I do it after user request sign in via facebook only...

MyLoginManager.swift

import FBSDKLoginKit;
import Foundation;
import GoogleSignIn;

class MyLoginManager: NSObject, LoginButtonDelegate {

...

    public func initAppleLogin() {
        ...
    }

    public func initGoogleLogin() {
        ...
    }

    public func initFacebookLogin() {
        // (!!!) Init FB SDK now, not at app start because of performance reason
        FBSDKCoreKit.ApplicationDelegate.shared.application(UIApplication.shared, didFinishLaunchingWithOptions: nil);

        // Logout before sign in to avoid dialog that user already logged in
        let facebookLoginManager = FBSDKLoginKit.LoginManager();
        facebookLoginManager.logOut();

        // Fake login button
        let loginButton = FBLoginButton(frame: .zero);
        loginButton.permissions = ["public_profile", "email"];
        loginButton.delegate = self;
        loginButton.isHidden = true;
        loginButton.sendActions(for: .touchUpInside);
    }

    func loginButton(_ loginButton: FBLoginButton, didCompleteWith result: FBSDKLoginKit.LoginManagerLoginResult?, error: Error?) -> Void {
        ...
    }

    func loginButtonDidLogOut(_ loginButton: FBLoginButton) -> Void {
        ...
    }

    ...

}

Btw consider disabling FB useless bloatware... Info.plist

<key>FacebookAdvertiserIDCollectionEnabled</key>
<false/>
<key>FacebookAutoLogAppEventsEnabled</key>
<false/>
eXhausted commented 3 weeks ago

Any updates? latest version adds even more, we have increase up to 200ms.