Q:

iOS - NSNotificationCenter delay

Basically, i am trying to create an app which allows users to log in via Google or Facebook. I have managed to create the whole login process however i have a small issue when displaying the Facebook profile image. So what happens is when the users choses to log in with Facebook or Google (from firstViewController.swift) they are sent to a new view controller (secondViewController.swift) where they can see their current Facebook profile picture (only if logged in with FB) and they also have an option to log out with a button. Also when they are logged in with either FB or Google they can kill the app and when they open the app again they are brought back to the second view controller as they didn't log out.
It all works as intended however when i re-open the app after killing it (if i'm logged in with FB) the UIView i have used to view the FB profile Picture appears blank for about 2 sec then it changes to the actual FB picture as it was intended to and i'm not sure how to get rid of that delay! 
This is what my code looks like:
Appdelegate.swift
func applicationDidBecomeActive(_ application: UIApplication) {
    FBSDKAppEvents.activateApp();

    GIDSignIn.sharedInstance().signInSilently()
    if (GIDSignIn.sharedInstance().hasAuthInKeychain() || (FBSDKAccessToken.current() != nil)){
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "homePageVC") as! secondViewController
        let appDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate
        appDelegate.window?.rootViewController = vc

        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "setFBProfilePictureID"), object: nil)
    }

}

firstViewController.swift
@IBAction func handleCustomFBLogin() {
    FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
        if err != nil {
            print("FB login failed", err!)
            return
        }
        self.performSegue(withIdentifier: "loggedIn", sender: self) //sends user to the second VC
        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "setFBProfilePictureID"), object: nil) //post notification for the FB profile picture view in homePage VC
    }
}

SecondViewController.swift
 @IBOutlet weak var fbProfilePicture: FBSDKProfilePictureView! //fb profile pic UIView

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.

    NotificationCenter.default.addObserver(self, selector: #selector(setFBProfilePicture(Notification:)), name: NSNotification.Name(rawValue: "setFBProfilePictureID"), object: nil)

}
func setFBProfilePicture(Notification: NSNotification) {
    fbProfilePicture.isHidden = false
}

A:

I believe it's the network call to the facebook API for the profile picture which takes 2 seconds. Try to set the background of the fbProfilePicture to an color, then you should be able to see that the view is not hidden immeadialty, but it's the image being loaded which takes 2 seconds. An idea could be to cache it? 

