Exodus from the iOS phonogram causes a black screen when launching the application

I have successfully used background selection in an iOS app I am developing, but I noticed a strange error that caused me to have seeding issues.

The original symptom was that sometimes when I launched the application, the launch image was displayed and then replaced with a black screen. If I press the Home button and then reopen the application, everything is fine and the application functions as intended. I also noticed that this seems to have happened if I haven't used the app after a while. After adding the registration pool, I realized that the black screen on startup only happened if the OS was running a background selection on startup. It looks like if the selection hasn't been done in a while and then you launch the app, iOS will trigger a "background" selection in your running application. The error only occurs in this situation.

I did some searches and it seemed like one of the reasons for this behavior might be if you are launching an animation at the wrong point in the application lifecycle. I checked my app and didn't find much. I also found this Stack Overflow post that describes a similar problem, except that my application is not crashing and I am not doing anything with background threads in my implementation application:performFetchWithCompletionHandler:

.

I figured the next step would be to come up with a minimal test case that still causes the problem. So, using Xcode 6.1, I created a blank Single View (Swift) app. Then I did a little bit of work to add to the background selection:

  • Added the "Background Fetch" option to the "Background Modes" section of the "Features" screen for my purpose.
  • Updated AppDelegate.swift to include relevant background extraction snippets.

    import UIKit
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        var window: UIWindow?
    
        func application(application: UIApplication,
            didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
                application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum);
                return true
        }
    
        func application(application: UIApplication!,
            performFetchWithCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)!) {
                completionHandler(UIBackgroundFetchResult.NewData);
        }
    }
    
          

I didn't make any other changes and then launched the app on the device. For the situation to arise, I ran several Simulate Background Fetch commands from Xcode, stopped the application inside Xcode, and then waited for a while (about 10 minutes). Then I restarted the application from Xcode and experienced the same behavior that was happening in my real application.

At this point, I am having trouble not concluding that this is some kind of bug in the SDK. Has anyone else seen this situation? Is there a workaround?

+3


source to share





All Articles