iOS application runs after end of background task

匆匆过客 提交于 2019-12-22 01:20:04

问题


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...


回答1:


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.



来源:https://stackoverflow.com/questions/13690077/ios-application-runs-after-end-of-background-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!