Search code examples
ioscrash-reportsterminate

If your app is terminated by the iOS system does it generate a crash report?


While running on the device (iOS 8) I think the system may be terminating my app while it is suspended either do to memory or running a background task too long. I suspect this because when I resume the app it has returned to the root view controller, which shouldn't be possible unless the app started fresh.

I never see a crash report for it when viewing the Device Logs however.

If the system terminates your app will it always generate a crash report?


Solution

  • If the app is killed by low memory usually generates a low memory report:

    When a low-memory condition is detected, the virtual memory system in iOS relies on the cooperation of applications to release memory. Low-memory notifications are sent to all running applications and processes as a request to free up memory, hoping to reduce the amount of memory in use. If memory pressure still exists, the system may terminate background processes to ease memory pressure. If enough memory can be freed up, your application will continue to run and no crash report will be generated. If not, your application will be terminated by iOS because there isn't enough memory to satisfy the application's demands, and a low memory report will be generated and stored on the device.

    The format of a low memory report differs from other crash reports in that there are no stack traces for the application threads. Memory usage of each process is reported in terms of number of memory pages, which as of this writing are 4KB each. You will see "(jettisoned)" next to the name of any process terminated by iOS to free up memory. If you see it next to your application's name, that confirms the application was terminated for using too much memory.

    This report can be seen usually in the crash logs, but, for my experience, this log is not guaranteed.

    An example of a memory report:

    Incident Identifier: 30E46451-53FD-4965-896A-457FC11AD05F
    CrashReporter Key:   5a56599d836c4f867f6eec76afee451bf9ae5f31
    OS Version:          iPhone OS 3.1.3 (7E18)
    Date/Time:           2012-10-17 21:39:06.967 -0400
    
    Free pages:        96
    Wired pages:       10558
    Purgeable pages:   0
    Largest process:   Rage Masters
    
    Processes
         Name                 UUID                    Count resident pages
    Rage Masters <cc527ca9b51937c5adbe035fe27a7b12>    9320 (jettisoned) (active)
    mediaserverd <3d3800d6acfff050e4d0ed91cbe2467e>     255
     dataaccessd <13d80b2e707acc91f9aa3ec4c715b9cc>     505
         syslogd <8eddddc00294d5615afded36ee3f1b62>      71
            apsd <32070d91b216d806973c8f1b1d8077a4>     171
       securityd <b9e51062610d27f727c5119b8f80dcdf>     243
         notifyd <591dd4dd804b4b8741f52335ea1fa4ab>    2027
      CommCenter <b4b87526ae086bb62c982f1078f43f81>     189
     SpringBoard <324939a437d1cca1fa4af72d9f5d0eba>    2158 (active)
      accessoryd <8f21c8b376d16e2ccb95ed6d21d8317a>      91
         configd <85efd41aceac34ccc0019df76623c7a9>     371
       fairplayd <a2eaf736b3e07c7c9a2c82e9eb893555>      93
    mDNSResponder <df1cd275e4ad434e0575990e8e1da4cb>     292
       lockdownd <80d2bd44c0bcca273d48ce52010f7e65>    1204
         launchd <a5988245aade809bf77576f1d9de42c5>      72
    

    Actually, this is one of the problems that crashlytics's team is trying to solve:

    These are tricky, as these events are actually separate events from crashes. Low-memory events are complex to capture as there is no known way to capture a low-memory exit with public API.

    However, we are working on a system that will produce a record of these events. Stay tuned!

    Regarding background crashing usually you get a crash log with something like this message:

    Application Specific Information:
    MyMapApp[1234] has active assertions beyond permitted time: 
    {(
        <SBProcessAssertion: 0x63a07a0> identifier: CoreLocationRegistration process: MyMapApp[1234] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:1234 preventSuspend  preventIdleSleep ,
    <SBProcessAssertion: 0xa095050> identifier: CoreLocationBackgroundClient process: MyMapApp[1234] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:1234 preventSuspend  preventIdleSleep 
    )}