"Can't end BackgroundTask" error message on iOS 13.0

I made new project on Xcode 11 beta 7 and just run app on simulator and go back to home screen.

Then debugger shows the message below, although I didn't implement codes related background task.


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


Has anyone else experienced this problem?

Accepted Reply

Confirmed: This has been fixed in iOS 13.4 GM.

Replies

I have as well. I'm not using any Scenes. Is the old app delegate still appropriate for iOS 13 if you choose not use them? We have a 5 year old iOS app so it should work fine without using Scenes and yet we get the background task warning


Neal

me, too. I want to know the solution

Hi, do you also use Firebase Cloud Notification?

I have the same problem.

Thanks for the attention.

Massimo Senatore

R&D Manager App.

Firenze Web Division

Italy

I don't use Firebase Cloud Notification.
This problem occurs even if I run a brand new project.

Hi,


I am also experiencing the same background task problem with iOS 13-beta8 and managing an AVCaptureSession.


I start a background task when the AVCaptureSession begins delivering frames on the AVCaptureConnection. If the AVCaptureSession is interrupted then I teardown the pipeline by ensureing all frames are flushed through the connection to the AVCaptureVideoDataOutput and then end the background task. I can confirm that on iOS 13 the expiration handler has not fired, and that completing the task always raises the same error message that frnkwk originally posted.

Same here with empty new project in iOS 13 GM with Xcode 11 GM on iPhone XS Max & on iOS 13.1 Beta 3 on iPhone XS.


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


This is not happening in iOS 12.4. In iOS 13 is resulting not being able to re-start video session when coming back to foreground.

I can confirm that this issue is still occurring on iOS 13.1-beta4 as well.

Hello


From what I can tell if you are still using the old lifecycle method this is just a harmless warning, although it would be nice to be able to switch it off.


My app will happily switch between foreground and background without crashing, and I get this message every time it enters the background.

I'm very new to learning to code with Swift and develop for iOS (and coding in general), but I am having issues with this as well, as this seems to be preventing simple scheduled local notifications from appearing if I put an app in the background.


I'm in the process of learning to use User Notifications and was doing this very simple tutorial on IOSCreator.com. The simple gist of this tutorial is a Single View app with a single button that, when pressed, schedules a notification to appear with the defined content after 10 seconds. There is nothing in that which customizes the app lifecycle methods in AppDelegate or SceneDelegate. There is nothing about implementing any kinds of background tasks (which presumably weren't needed in previous versions of iOS, though I don't see how/why they'd be needed now). However, when you run the app, press the button, and go to the home screen, the same message appears in the debugger console, and the notification never appears, neither in the simulator nor on my iPhone running iOS 13.0.
Also, as frnkwk said in their original post, I can confirm that this message appears even on a blank Single View App template. I put print() calls in each of the AppDelegate and SceneDelegate methods so I could get a feel for the app lifecycle, and sure enough the message appears right after sceneDidEnterBackground() is called.


Is this a bug? Or do I need to be doing something very different in iOS 13 in order to make a simple notification appear after returning to the homescreen from an app?
Any help would be most appreciated. 🙂

I'm running into the same issue with Xcode 11.0 on iOS 13.0. Error occurs on both simulator and my iPhone when hitting the home button or simulating background fetch. I also tested this on a new Single View App project and see the same error when hitting the home button.

It's still there on iSO 13.1. Seems to be a iOS 13 bug.

Ditto. I don't see any real problem from this as my app switches to the background, just the annoying message in the Xcode debugger. App continues running just fine. The "Identifier" does seem to advance but I haven't noticed a predictable pattern to that.


iOS 13.1.2 on iPhone 7 Plus

Xcode 11.1 on macOs 10.14.5

I also get the console warning 'Can't end BackgroundTask: no background task exists with identifier 2 (0x2), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.' when my app goes to the background.


I'm on iPadOS 13.2 beta and using Xcode 11.2 beta (11B41). Adding a symbolic breakpoint to 'UIApplicationEndBackgroundTaskError' just gives a useless call stack.


My app doesn't explictly create a background task, but I have checked the 'Audio, AirPlay and Picture in Picture' Background Mode option in the Xcode project's 'Signing & Capabilities' page as my app needs to continue playing audio when in the background.


Aside from the console warning, everying behaves as expected (audio continues to play in the background) but it would be nice to get a confirmation that this issue is benign.

Using latest xcode and macOS Catalina and get the same output in the console everytime the app enters the background.However the app behaves flawlessly.If no solution emerges, after I submit my app for review, if it passes with this, I wil let everybody know here in 2 weeks maximum.

Thanks.

Same issue here on iOS 13.1.2(iPhone 6s), iOS 13.0(iPhone 10) once app enter background, it failed to scan peripherals, and reports on console with "Can't end BackgroundTask: no background task exists with identifier 2 (0x2), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug."