iOS crash “failed to resume in time”

We received a crash report that shows the following error message for an iOS app.

Application Specific Information:
com.#####.##### failed to resume in time

The key in the crash report is the “failed to resume in time” message that is being displayed.  This error basically states that some process is being performed that is taking too long.  Apple then shuts that process down.  Depending on your app that may cause you to crash (if you were relying on the thread that is closed).

How long then does a thread have to be running before it has a timeout?  Currently the timeout is set to 20 seconds.  WHICH IS A LONG TIME…  If you have a thread that is hanging for 20 seconds then something rather serious is going on.

Generally when a thread hangs for that long, the cause is simply a bad timeout or catch on an action you are trying to do.  There are a couple different approaches you can take.  Let’s assume that you are calling into a 3rd party API.  You need to plan for this 3rd party API to have dropped requests, failures and times when it is not reachable.

First is you can implement some sort of internal timeout.  If the thread is not successful after ~5 seconds then do something.  (the timeout value can be anything and this provides a much better UI).

Second is you can ensure that the process is being performed asynchronously.  Maybe this is a call that may legitimately take several seconds to perform.  Send it to the background, let it execute and then do something when the call is returned.

The second approach is the better design approach.  This allows you app and users to continue on doing whatever they want regardless of the status of a call.

Posted in , , and tagged .