iOS应用程序在后台任务结束后运行 [英] iOS application runs after end of background task

查看:147
本文介绍了iOS应用程序在后台任务结束后运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了自定义voip应用程序。几乎一切都很好;

 从崩溃日志:
异常类型:00000020
异常代码:0xbad22222
突出显示的线程:4

SBUnsuspendLimit CryptTalkDev [24820]在300秒内超过15次唤醒

突出显示的线程调用堆栈:
线程4名称: com.apple.NSURLConnectionLoader
线程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基础0x35094bb2 0x35084000 + 68530
7基础0x35094a7a 0x35084000 + 68218
8基础0x3512858a 0x35084000 + 673162
9 libsystem_c.dylib 0x329c872e 0x329ba000 + 59182
10 libsystem_c.dylib 0x329c85e8 0x329ba000 + 58856

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



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



可能是什么原因?



今天检查控制台:

  Dec 4 13:57:36未知SpringBoard [51]<警告>:无法传送SBApplicationNotificationStateChanged通知到端口com.apple.springboard.appstatechanged:(ipc / send)timed out 
Dec 4 13:57:36未知SpringBoard [51]<警告>:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard .appstatechanged:(ipc / send)timed out
Dec 4 13:57:46未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send )timed out
Dec 4 13:57:46未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:57:56未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传送到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:57:56未知的SpringBoard [51]<警告> ;:无法传递SBApplicationNotificationStateChanged通知到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:06 unknown SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传送到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:06未知SpringBoard [51]<警告>无法传送SBApplicationNotificationStateChanged通知到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:16未知SpringBoard [51]<警告>:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple。 springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:16未知SpringBoard [51]<警告>无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc /发送)超时
Dec 4 13:58:27未知SpringBoard [51]<警告>无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:27未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58: 37 unknown SpringBoard [51]< Warning> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:37未知SpringBoard [51] ;警告> ;:无法将SBApplicationNotificationStateChanged通知传送到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:47未知SpringBoard [51]<警告>:无法交付SBApplicationNotificationStateChanged通知到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:47未知SpringBoard [51]<警告>:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple .springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:58:57未知SpringBoard [51]<警告>:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged: / send)timed out
Dec 4 13:58:57未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:07未知SpringBoard [51]<警告>无法将端口com.apple.springboard.appstatechanged发送SBApplicationNotificationStateChanged通知:(ipc / send)timed out
Dec 4 13:59 :07 unknown SpringBoard [51]< Warning> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:17未知SpringBoard [51] < Warning> ;:无法将SBApplicationNotificationStateChanged通知传送到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:17未知SpringBoard [51]<警告> ;:无法传递SBApplicationNotificationStateChanged通知到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:27未知SpringBoard [51]<警告>:无法将SBApplicationNotificationStateChanged通知传递到端口com。 apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:27未知SpringBoard [51]<警告>无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged: ipc / send)timed out
Dec 4 13:59:37未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:37未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13: 59:47未知SpringBoard [51]<警告> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:47未知SpringBoard [51 ]< Warning> ;:无法将SBApplicationNotificationStateChanged通知传送到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:57未知SpringBoard [51]<警告>:Unable发送SBApplicationNotificationStateChanged通知到端口com.apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 13:59:58未知SpringBoard [51]<警告>:无法将SBApplicationNotificationStateChanged通知传递到端口com .apple.springboard.appstatechanged:(ipc / send)timed out
Dec 4 14:00:08 unknown SpringBoard [51]< Warning> ;:无法将SBApplicationNotificationStateChanged通知传递到端口com.apple.springboard.appstatechanged: (ipc / send)超时
12月4日14:00:08未知SpringBoard [51]< Warning> ;: SBUnsuspendLimit CryptTalkDev [3925]在300秒内超过15次唤醒
Dec 4 14:00:08未知的SpringBoard [51]<警告> ;:强制崩溃报告CryptTalkDev [3925] ...
Dec 4 14:00:09未知ReportCrash [3956]<注意: ]
Dec 4 14:00:09未知SpringBoard [51]<错误> ;: simulatecrash调用失败,状态为(-308)
Dec 4 14:00:09未知SpringBoard [51]< Warning> ;:完成崩溃报告。


今天在应用程序上运行I / O活动工具。
发现了两件事:
1)应用程序每10秒恢复一次,暂停100-200 ms,然后再次恢复
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)从服务器接收到第一个数据后运行。

I made custom voip application. Almost everything works nice; but time from time application is restarted.

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

There is no incoming traffic in this time - i checked from application logs.

Before in several minutes application receives the network change notification and starts reregistering on server. The background task starts to protect it. In one minute before crash background task finished. But application runs anyway - i see it in logs!

What can be cause?

P.S. Checked today console:

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.

P.P.S. Today runs I/O activity instrument on application. Discovered two things: 1) Application resumes every 10 seconds, suspends for 100-200 ms, and resumes again 2) There are socket I/O in iOS system calls; not SIP signalling socket. Looks it is similar to http://trac.pjsip.org/repos/ticket/1482

But hard part is to find disconnected tcp socket...

解决方案

Resolved. The cause was improper preparing of tcp connection for background mode.

The right way for me:

  1. Create pair of streams for BSD socket (i use bsd sockets)
  2. Set kCFStreamPropertyShouldCloseNativeSocket to kCFBooleanFalse for both streams
  3. Set kCFStreamNetworkServiceType to kCFStreamNetworkServiceTypeVoIP for both streams

Steps 1) - 3) runs after receiving of first data from server.

这篇关于iOS应用程序在后台任务结束后运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆