10

Context: My app is made using SwiftUI, which is a game using SpriteKit.

When pressing the home button on my device, my app encounters an error called 'UIApplicationEndBackgroundTaskError'. The log looks like so:

Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

I have tried making the breakpoint, but it doesn't give me any helpful information I understand. There is no log, it just shows the Debug Navigator.

Debug Navigator

I tried to investigate where the issue came from. I just added some simple print statements. The print Update repeats a few times quickly, before the application is halted by the breakpoint:

struct SceneView: UIViewRepresentable {

    let bounds: CGRect


    // Conformance to UIViewRepresentable
    func makeUIView(context: Context) -> SKView {
        SKView(frame: bounds)
    }
    func updateUIView(_ uiView: SKView, context: Context) {
        print("Update")

        let scene = Scene(size: bounds.size)
        uiView.ignoresSiblingOrder = true
        uiView.showsFPS = true
        uiView.showsDrawCount = true
        uiView.showsNodeCount = true
        uiView.presentScene(scene)
    }
}

  • What is causing the issue, and how can I fix this?
  • Could this be due to SwiftUI or my Xcode betas and iPhone betas not matching up?
George
  • 25,988
  • 10
  • 79
  • 133
  • Search through your code to see where you are calling `endBackgroundTask` – Paulw11 Aug 20 '19 at 21:12
  • @Paulw11 I am not calling that from anywhere in my project – George Aug 20 '19 at 21:13
  • Did you set a symbolic breakpoint on UIApplicationEndBackgroundTaskError? If so, turn off that breakpoint. – matt Sep 11 '19 at 03:40
  • 1
    Getting the same message when going into background running my app on iOS13. Same code for previous iOS versions does not output this error. Think this rules out. SwiftUI being the cause though. – instAustralia Sep 18 '19 at 01:22
  • 1
    Agreed about SwiftUI not being the direct cause. I have a regular Swift project. Using Xcode 11 GM, I experienced the crash when returning to Home in Simulator. In Xcode 11 GM Seed 2, I no longer get the crash, but still get the warning in console. – David James Sep 19 '19 at 11:51
  • Related thread from the apple developer forum: https://forums.developer.apple.com/thread/121990 – Patrick Boos Sep 24 '19 at 06:33

1 Answers1

2

It is fixed on iOS 13.2 beta 3, you can test it there, it should be fixed.

JERC
  • 1,584
  • 3
  • 17
  • 38