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.
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)
}
}
It is fixed on iOS 13.2 beta 3, you can test it there, it should be fixed.