Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application crashing with UIApplicationEndBackgroundTaskError

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?
like image 788
George Avatar asked Aug 20 '19 20:08

George


1 Answers

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

like image 110
JERC Avatar answered Nov 19 '22 15:11

JERC