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

我做了自定义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 

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

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

可能是什么原因?

PS今天检查控制台:

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

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

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

解决。 原因是为背景模式准备不正确的tcp连接。

对我来说正确的方式:

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

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