objective-c - iOS 应用程序在后台任务结束后运行

标签 objective-c ios cocoa-touch uiapplication

我制作了自定义 VoIP 应用程序。几乎一切都运转良好;但应用程序重新启动的时间。

From crash log:
Exception Type:  00000020
Exception Codes: 0xbad22222
Highlighted Thread:  4

SBUnsuspendLimit CryptTalkDev[24820] exceeded 15 wakes in 300 sec

Highlighted thread call stack:
Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x35eab004 0x35eaa000 + 4100
1   libsystem_kernel.dylib          0x35eab1fa 0x35eaa000 + 4602
2   CoreFoundation                  0x355d93ec 0x3554c000 + 578540
3   CoreFoundation                  0x355d8124 0x3554c000 + 573732
4   CoreFoundation                  0x3555b49e 0x3554c000 + 62622
5   CoreFoundation                  0x3555b366 0x3554c000 + 62310
6   Foundation                      0x35094bb2 0x35084000 + 68530
7   Foundation                      0x35094a7a 0x35084000 + 68218
8   Foundation                      0x3512858a 0x35084000 + 673162
9   libsystem_c.dylib               0x329c872e 0x329ba000 + 59182
10  libsystem_c.dylib               0x329c85e8 0x329ba000 + 58856

此时没有传入流量 - 我从应用程序日志中检查过。

几分钟前,应用程序收到网络更改通知并开始在服务器上重新注册。后台任务开始保护它。在崩溃前一分钟后台任务完成。但应用程序无论如何都会运行 - 我在日志中看到它!

可能是什么原因?

附言今天检查控制台:

Dec  4 13:57:36 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:57:36 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:57:46 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:57:46 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:57:56 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:57:56 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:06 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:06 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:16 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:16 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:27 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:27 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:37 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:37 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:47 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:47 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:57 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:58:57 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:07 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:07 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:17 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:17 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:27 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:27 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:37 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:37 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:47 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:47 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:57 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 13:59:58 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 14:00:08 unknown SpringBoard[51] <Warning>: Unable to deliver SBApplicationNotificationStateChanged notification to port com.apple.springboard.appstatechanged: (ipc/send) timed out
Dec  4 14:00:08 unknown SpringBoard[51] <Warning>: SBUnsuspendLimit CryptTalkDev[3925] exceeded 15 wakes in 300 sec
Dec  4 14:00:08 unknown SpringBoard[51] <Warning>: Forcing crash report of CryptTalkDev[3925]...
Dec  4 14:00:09 unknown ReportCrash[3956] <Notice>: Formulating crash report for process ReportCrash[3955]
Dec  4 14:00:09 unknown SpringBoard[51] <Error>: simulatecrash call failed with status (-308)
Dec  4 14:00:09 unknown SpringBoard[51] <Warning>: Finished crash reporting.

附言 今天在应用程序上运行 I/O 事件工具。 发现两件事: 1) 应用程序每 10 秒恢复一次,暂停 100-200 毫秒,然后再次恢复 2)iOS系统调用中有socket I/O;不是 SIP 信令套接字。 看起来它类似于 http://trac.pjsip.org/repos/ticket/1482

但困难的部分是找到断开连接的 tcp 套接字...

最佳答案

已解决。 原因是后台模式的 tcp 连接准备不当。

对我来说正确的方法:

  1. 为 BSD 套接字创建一对流(我使用 bsd 套接字)
  2. 将两个流的 kCFStreamPropertyShouldCloseNativeSocket 设置为 kCFBooleanFalse
  3. 将两个流的 kCFStreamNetworkServiceType 设置为 kCFStreamNetworkServiceTypeVoIP

步骤 1) - 3) 在从服务器接收到第一个数据后运行。

关于objective-c - iOS 应用程序在后台任务结束后运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13690077/

相关文章:

objective-c - 如何使用 NSTableView 的 selectedRowIndexes?

ios - 超过 256 个顶点的 OpenGL ES2 网格断开

ios - 使用 AFNetworking 的多部分 PUT 请求

objective-c - Objective-C 字符串文字的预处理器宏值

objective-c - Mac OSX : Determing whether user account is an Active Directory user vs. 本地用户使用objective-c

objective-c - Cocoa (Mac Os X) 打印多页,为什么预览窗口显示 2 页而不是 1 页?

objective-c - NSTable 和 NSMutableArray 排序

iphone - 从两个分组的 UITableView 单元格中删除内部分隔符

iphone - `wait_fences`错误消息到底是什么意思

iphone - 从 UIBarButtonItem 获取 UIBarButtonSystemItem