App crash while app in the background - after devi

2019-08-14 15:42发布

问题:

I'm constantly seeing this crash when our app (Voip App)is in the background, after device goes to sleep mode.

Exception Type:  00000020

Exception Codes: 0xbad22222

Highlighted Thread:  3



Application Specific Information:

SBUnsuspendLimit ooVoo[360] exceeded 15 wakes in 300 sec



Thread 3 name:  com.apple.NSURLConnectionLoader

Thread 3:

0   libsystem_kernel.dylib          0x307fc010 mach_msg_trap + 20

1   libsystem_kernel.dylib          0x307fc206 mach_msg + 50

2   CoreFoundation                  0x3569b41c __CFRunLoopServiceMachPort + 120

3   CoreFoundation                  0x3569a154 __CFRunLoopRun + 876

4   CoreFoundation                  0x3561d4d6 CFRunLoopRunSpecific + 294

5   CoreFoundation                  0x3561d39e CFRunLoopRunInMode + 98

6   Foundation                      0x3167abc2 +[NSURLConnection(Loader) _resourceLoadLoop:] + 302

7   Foundation                      0x3167aa8a -[NSThread main] + 66

8   Foundation                      0x3170e59a __NSThread__main__ + 1042

9   libsystem_c.dylib               0x30b68c16 _pthread_start + 314

10  libsystem_c.dylib               0x30b68ad0 thread_start + 0

What's the cause of this crash ? Anything I should do to prevent it ?

回答1:

It appears you are talking to a URL when you are going to background. If so, then add some shared cache to your NSURL implementation and if you are using NSURLRequest then increase the timeoutInterval value.

If none is the case, then deal it as a background task. For, background task : you may refer to Background Task Handling.

Regards,

Reno Jones



回答2:

NSURLConnectionLoader probably has nothing to do with it.

Most likely, your app is woken up by traffic on its TCP signaling socket. Typically, a VoIP (SIP?) server sends keep-alive messages every once in a while. An overly aggressive server can unwillingly kill the client by unsuspending it up like this too often.

Either make sure the server isn't sending (SIP) keep-alives too often, or use the BackgroundTask API to prevent the app from suspending so soon after every unsuspend. This way, you can keep the number of unsuspends down (at the cost of battery consumption).

Regards

Jonas Salling



回答3:

Not exactly sure how/why but updating to a newer version of AsiHttp solved the issue.