Change to didEnterForeground() behavior with iOS 12.4?

Not sure where this should be posted. If you prefer it be somewhere else, just let me know.


With the update to iOS 12.4, a user and I are noticing that my app is behaving a bit zombie-like when it's brought forward from the background. The app does background fetches and makes a few calculations while in the background, so it's necessary to refresh the GUI whenever the user returns to the app.


The previous behavior, code below, performs a GUI refresh whenever the app was brought forward. This seemed fairly snappy and gave the user the freshest data. Now, the GUI is showing old data and feels dead when the app is brought forward. By "feels dead", I mean that nothing appears to be happening. Normally, the HomeKit homemanager is immediately called and the user can see the progress of that. And fresh web data might be called for, and arrive a few seconds later. None of this is happening.


I should say it's not happening all the time. It does often happen properly, and only occasionally goes zombie on me.


My background fetches trigger notifications and these are arriving as expected, so I don't think the problem is the lack of new data, it's an unresponsive GUI.


Any ideas what's going on here, what might have changed?


This is the code that's in my "Main" home screen class describing the view controller that is usually frontmost when the app enters or leaves the background.


    @objc func didEnterForeground() {   //This executes EVERY time the app starts OR is brought forward.

        Central().calcThermSetting()  // Forces a calculation based on the latest data
        
        self.logSB.info("didEnterForeground   Ready for duty")  // Mankes an entry into my Swifty ****** logging
        //        weatherSourceLabel.isHidden = false
        self.setIndicator()  // Sets the UI elements based on stored values of the Homekit indicators
        updateGUIWeather()
        updateGUIRate()
        updateWebData()
        updateGUIThermostat()
    }

Replies

Could you add some logs at each line of the func, to check if you reach there and if values have been updated correctly.


Where do you call didEnterForeground ?


Why don't you use

func applicationWillEnterForeground(application: UIApplication!)

Oops, I forgot to make that clear, that "didEnterForeground" was my function and not built in. This line is in the ViewDidLoad for that view.


NotificationCenter.default.addObserver(self, selector: #selector(didEnterForeground), name: UIApplication.didBecomeActiveNotification, object: nil)

Coming to the foreground in the zombie state is pretty rare, although less rare in iOS 12.4. I'll need to be diligent in capturing the log file when I see it happen again. And yeah, I can throw in a few more logging statements.

Can you show the results of the added logs.