Ticket #1482 (closed defect: fixed)
iPhone: Solution for application getting killed by iOS 5 due to too many wakeups
|Reported by:||bennylp||Owned by:||bennylp|
|Backport to 1.x milestone:||Backported:||no|
Description (last modified by ming) (diff)
As has been reported in http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-November/013692.html, iOS 5 will kill an application if it wakes up more than 15 times in 300 seconds. Below is a typical stack trace for the "crash" event:
Exception Type: 00000020 Exception Codes: 0xbad22222 Highlighted Thread: 1 Application Specific Information: SBUnsuspendLimit myapp exceeded 15 wakes in 300 sec
There are several other discussions on the Apple's developer forum:
This ticket provides several tips that may help avoiding the situation.
- Use a background task to ensure that the app doesn't suspend immediately after being waken up. App most likely will need to send something when it is waken up, for example some requests or TCP keep-alive data. Chances are these data will be responded by the server. If the app immediately gets suspended after sending them, it will be waken up again when the response arrives, hence adding to the wake up count. The app should delay as much as iOS allows before it goes to suspended state again, to take care the fact that some requests do take a while to complete, for example due to authentication.
- Fixing spurious wakeups problem. It has been reported that iOS may wake up the application every 10 seconds even when there is no activity in the network. This has been correlated to TCP transport disconnection, i.e. once the TCP transport is disconnected the app starts to get waken up every 10 seconds even when Wireshark shows no activity at all. This issue seemed to have been fixed by #1465 and #1481, which now immediately close (or to close sooner) the TCP socket when it gets disconnected. If the app also holds a reference to the TCP transport, it should also release this reference once it gets the TCP disconnection notification (on the on_transport_state() callback), because the transport will only be destroyed once it's reference goes to zero.
- Status changed from new to closed
- Resolution set to fixed
- Summary changed from Info: Solution for application is getting killed by iOS 5 due to too many wakeups to Info: Solution for application getting killed by iOS 5 due to too many wakeups
- Summary changed from Info: Solution for application getting killed by iOS 5 due to too many wakeups to iPhone: Solution for application getting killed by iOS 5 due to too many wakeups