IOS7: Background Task (“MyApp” has an active assertion after exceeding the allowable time)

Crash report details:

Hardware Model: iPhone5,2
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 3

Application Specific Information:
MyApp[1369] has active assertions beyond permitted time:
{(
< BKProcessAssertion: 0x175ca7d0> identifier: Called by MyApp, from -[AppDelegate applicationDidEnterBackground:] process: MyApp[1369] permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1369 preventSuspend preventIdleSleep preventSuspendOnSleep
)}

Thread 3:

Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:
0 libsystem_kernel.dylib 0x3937ea50 mach_msg_trap + 20
1 libsystem_kernel .dylib 0x3937e848 mach_msg + 36
2 CoreFoundation 0x2e61261c __CFRunLoopServiceMachPort + 152
3 CoreFoundation 0x2e610d3c __CFRunLoopRun + 788
4 CoreFoundat ion 0x2e57b7a4 CFRunLoopRunSpecific + 520
5 CoreFoundation 0x2e57b586 CFRunLoopRunInMode + 102
6 Foundation 0x2efbb23c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
7 Foundation 0x2f030a0a + lib dylib 0x393f8956 _pthread_body + 138
9 libsystem_pthread.dylib 0x393f88c6 _pthread_start + 98
10 libsystem_pthread.dylib 0x393f6ae4 thread_start + 4

My application uses this code as a background task in “applicationDidEnterBackground” :

// 10min background task
UIBackgroundTaskIdentifier myLongTask;
myLongTask = [[UIApplication sharedApplication]
beginBackgroundTaskWithExpirationHandler:^{
[locationMgrInstance timerSet];
}];
// cell change
[locationMgrInstance startMonitoringSignificantLocationChanges];

It works on iOS 6…but! iOS 7 throws an assertion after 180 seconds.
Help!

This message indicates that your background tasks are running too long. iOS7 has changed some of the background processing Aspect. Especially the background task should be completed in a short time, if not, your application will be terminated. You need to understand how the background task runs. In particular, you need to make sure to call [[UIApplication sharedApplication] endBackgroundTask: task]; Timely. You should also call this method in the expiration handler.

Check the background execution and multitasking section in the Apple iOS App Programming Guide Background Execution Guide.

Also, you can check [[UIApplication sharedApplication] backgroundTimeRemaining] – on iOS 6, this time is 10 minutes. In iOS 7 it starts from 3 minutes – this is why you time out after 180 seconds. You You need to re-evaluate your background strategy to handle the new restrictions.

Crash report details:

Hardware Model : iPhone5,2
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 3

Application Specific Information:
MyApp[1369] has active assertions beyond permitted time:
{(
identifier: Called by MyApp, from -[AppDelegate applicationDidEnterBackground:] process: MyApp[1369] permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1369 preventS uspend preventIdleSleep preventSuspendOnSleep
)}

Thread 3:

Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:< br />0 libsystem_kernel.dylib 0x3937ea50 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3937e848 mach_msg + 36
2 CoreFoundation 0x2e61261c __CFRunLoopServiceMachPort + 152
3 CoreFoundation + 152
4 CFRunLoopRunSpecific + 520
5 CoreFoundation 0x2e57b586 CFRunLoopRunInMode + 102
6 Foundation 0x2efbb23c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
7 Foundation 0x2f030a0a __NSThread__main__ + 1058x393030.895libsystem 0x393a0a __NSThread__main__ + 1058x393a0a _pthread_body + 138
9 libsystem_pthread.dylib 0x393f88c6 _pthread_start + 98
10 libsystem_pthread.dylib 0x393f6ae4 thread_start + 4

My application uses this code for background tasks in “applicationDidEnterBackground”:

// 10min background task
UIBackgroundTaskIdentifier myLongTask;
myLongTask = [[UIApplication sharedApplication]
beginBackgroundTaskWithExpirationHandler:^{
[locationMgrInstance timerSet];
}];
// cell change
[locationMgrInstance startMonitoringSignificantLocationChanges ];

It works on iOS 6…but! iOS 7 throws an assertion after 180 seconds.
Help!

This message indicates that your background tasks are running too long. iOS7 has changed some aspects of background processing. Especially background tasks should be in a short time If not, your application will be terminated. You need to understand how the background task runs. In particular, you need to make sure to call [[UIApplication sharedApplication] endBackgroundTask: task]; promptly. You should also deal with it when it expires This method is called in the program.

Check the background execution and multitasking section in the Apple iOS App Programming Guide Background Execution Guide.

In addition, you can check [[UIApplication sharedApplication ] backgroundTimeRemaining] – On iOS 6, this time is 10 minutes. In iOS 7 it starts from 3 minutes – that’s why you time out after 180 seconds. You need to re-evaluate your background policy to handle the new limit.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3919 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.