进程有超过允许时间 iOS 的活动断言
Posted
技术标签:
【中文标题】进程有超过允许时间 iOS 的活动断言【英文标题】:Process has active assertions beyond permitted time iOS 【发布时间】:2014-12-04 13:22:33 【问题描述】:我有一个使用 Cordova 构建的应用程序,它在后台有一些任务。问题是我遇到随机崩溃,我无法弄清楚它出了什么问题。
我得到下一个异常:
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 2
Application Specific Information:
<BKNewProcess: 0x1758f950; com.app; pid: 2675; hostpid: -1> has active assertions beyond permitted time:
(
<BKProcessAssertion: 0x17692970> id: 2675-CA057A50-06BF-4BA1-9F0C-7641112B945E name: Called by MyApp, from unknown method process: <BKNewProcess: 0x1758f950; gbi.cro; pid: 2675; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:2675 preventSuspend preventIdleSleep preventSuspendOnSleep ,
<BKProcessAssertion: 0x17697c30> id: 2675-A03FFC10-1D0A-4BDC-BF64-61358346530E name: Called by MyApp, from unknown method process: <BKNewProcess: 0x1758f950; gbi.cro; pid: 2675; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:2675 preventSuspend preventIdleSleep preventSuspendOnSleep
)
线程2是:
Thread 2 name: com.apple.NSURLConnectionLoader
Thread 2:
0 libsystem_kernel.dylib 0x30ae3518 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x30ae330c mach_msg + 36
2 CoreFoundation 0x227d1596 __CFRunLoopServiceMachPort + 142
3 CoreFoundation 0x227cfb5c __CFRunLoopRun + 1012
4 CoreFoundation 0x2271cb2c CFRunLoopRunSpecific + 472
5 CoreFoundation 0x2271c93e CFRunLoopRunInMode + 102
6 CFNetwork 0x222d178a +[NSURLConnection(Loader) _resourceLoadLoop:] + 482
7 Foundation 0x2351e996 __NSThread__main__ + 1114
8 libsystem_pthread.dylib 0x30b75e64 _pthread_body + 136
9 libsystem_pthread.dylib 0x30b75dd6 _pthread_start + 114
10 libsystem_pthread.dylib 0x30b73b80 thread_start + 4
我有完整的踪迹,但它太大了,所以如果有人需要一些信息,请告诉我。
谢谢
【问题讨论】:
你试过用断点跟踪它们吗? 嗨,问题是崩溃是随机的,也许我在 10 分钟后得到它......在 5 小时后......所以我无法用断点调试它。 【参考方案1】:这个问题很烦人,很难通过断点调试,我建议你在应用退出活动时尝试以下方法,以向系统申请更多时间:
__block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
backgroundTaskIdentifier = backgroundTaskIdentifier;
];
另外,看看苹果: http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
【讨论】:
以上是关于进程有超过允许时间 iOS 的活动断言的主要内容,如果未能解决你的问题,请参考以下文章
MyApp“有超出允许时间的活动断言”崩溃 - CoreLocationRegistration 和 CoreLocationBackgroundClient