6 Crashes and exits
A process cannot reliably send its own crash. The report is written to disk when the crash happens and sent by the next launch. Some terminations leave no report at all, so the profile uses three sources: the crash handler, the platform’s own exit records, and inference on the next launch.
6.1 Crashes
Section titled “6.1 Crashes”- MUST report a crash as a log record with event name
app.crash, sent on the next launch. - MUST carry the crashed instance’s
app.build_id,service.version,os.name,os.versionandsession.idas record attributes (section 2.5). - MUST set
app.crash.id, the same on every attempt to report that crash (section 4.3). - MUST set the record’s
timeUnixNanoto the time of the crash, not the time of the report. - SHOULD set
exception.type(the exception class, or the signal and Mach exception, for exampleEXC_BAD_ACCESS (SIGSEGV)) andexception.message. - MUST put the crashing thread’s raw stack in
exception.stacktrace. Symbolication happens on the backend. - For a native crash, the stack has one frame per line, with the binary image name and the
instruction address, and the SDK MUST include the binary images the stack refers to
(name, UUID or build id, load address, architecture) in the attribute
apsio.crash.images, a JSON string, so the backend can symbolicate. Each image SHOULD also say whether it belongs to the app, inin_app(section 6.5). - For an uncaught exception in a managed runtime (the JVM or ART), the stack is the
runtime’s own stack text, with its causes, as the runtime prints it. There are no binary
images, so
apsio.crash.imagesMUST be[]. The backend deobfuscates the stack with the R8 mapping thatapp.build_idnames (section 2.1). - MAY attach the full native report (all threads, registers) as a separate upload
referenced by
apsio.attachment.id. - SHOULD record the termination category when the platform gives one, in
apsio.crash.termination_category(for examplebadAccess,abnormal,watchdog,taskTimeoutfrom MetricKit on iOS 27).
6.2 Handled errors
Section titled “6.2 Handled errors”- A handled, non-fatal error is a log record with
exception.type,exception.messageand, when available,exception.stacktrace, at severityERROR. - MAY carry
apsio.error.fingerprint, a string set by the app that replaces the backend’s default grouping for that error, scoped per app: two apps that send the same value get two groups. It does not apply to crashes.
6.3 Hangs and ANRs
Section titled “6.3 Hangs and ANRs”- An Android ANR is reported as the
device.anrevent of opentelemetry-android, or fromApplicationExitInfoon the next launch (6.4). - An iOS hang (the main thread blocked past the SDK’s threshold, or a MetricKit hang
diagnostic) is a log record with event name
apsio.hang, the main thread’s stack inexception.stacktraceand its duration inapsio.hang.duration(milliseconds). - An
apsio.hangrecord MUST carryapsio.hang.source:live: the SDK saw the hang while the app ran, in the session it belongs to. The record carries that session’ssession.id, and its time is the moment the hang began.metrickit: read from a MetricKit hang diagnostic, which arrives up to a day later and can describe a hang the SDK also saw live.
- Android’s hangs are seen while the app runs, so they are
live: an Android SDK that addsapsio.hang.sourcetodevice.anrorapsio.hangsetslive. - A live detector on iOS SHOULD watch the main thread from another thread, only while the app is in the foreground and not under a debugger, with a threshold of 250 ms. It records one stack per hang, taken while the main thread is blocked, and the hang’s duration once the main thread runs again.
- Unfinished hangs. The process can be killed during a hang (the system’s watchdog, a
force quit), so the hang never ends. A live detector SHOULD write the hang to disk
once its stack is taken, with the binary images it refers to, and update its duration
while it lasts. The next launch sends it as
apsio.hangwithapsio.hang.source = live,apsio.hang.unfinished = true,apsio.hang.durationthe time seen until the last update (a lower bound), the record’s time when the hang began, and the session and release of the process that hung as record attributes (2.5). It counts in hang rates like anylivehang; a backend MUST NOT read its duration as exact. - Launch hangs. A live hang that begins before the process first becomes active is a
launch hang: the main thread is still starting the app, which
app.startmeasures (8.1). On iOS the first activation is the process’s first app-levelUIApplication.didBecomeActiveNotification, which scene-based apps also post. A liveapsio.hangrecord of a launch hang MUST carryapsio.hang.phase = launch; other hangs carry noapsio.hang.phase.- A hang’s phase is set by the time it begins, the record’s time. A live hang cannot span the first activation, since its notification is posted on the main thread that the hang blocks.
- The detector reads the app’s state when it installs. If the app is already active (the SDK started after the first activation), no hang it sees is a launch hang. Otherwise the hangs that begin before the first activation are, the first activation of a prewarmed or background launch included. A cross-platform SDK started from its JavaScript runtime usually installs after the first activation, so it reports no launch hangs.
- iOS tells whether it launched the process in the background
(
apsio.app.launch.reason = background, 8.1) only once the launch is done. A detector that watches until then MUST NOT send a hang from a launch that turns out to be in the background, and removes the unfinished hang it wrote for it. An unfinished hang from a process killed before the SDK knew is sent as a launch hang: the SDK cannot tell a user’s launch from a background one there. - Returns from the background, after the first activation, are not launch.
- An unfinished launch hang keeps its phase: the detector writes the phase to disk with the
hang, and the next launch sends it. A launch that the system’s watchdog ends is such a
hang, and its termination is a
watchdogexit (6.4). metrickitrecords carry no phase: a MetricKit diagnostic has no time per hang to compare with the first activation.device.anrcarries no phase: an ANR at launch is still an ANR. An Android SDK that adds a sub-second liveapsio.hangfollows this rule, with the first resumed activity as the first activation.- The function
hang.phase(B.2) pins the boundary.
- A backend MUST compute hang rates and join hangs to their session’s screens from
liverecords only, so that a hang seen both ways counts once, and MUST leave launch hangs (apsio.hang.phase = launch) out of both:app.startalready measures a slow launch, and the first screen is not shown yet, so a join would put the hang on it wrongly. Launch hangs feed launch diagnostics, with their stacks.metrickitrecords feed duration distributions and stacks. A record withoutapsio.hang.source, from an SDK older than this rule, ismetrickitwhen itsos.nameis iOS or iPadOS andliveotherwise.
6.4 Terminations without a crash report
Section titled “6.4 Terminations without a crash report”iOS kills apps without a crash report for memory (jetsam), watchdog timeouts, background task expiry and thermal pressure. Android has low-memory kills and ANR exits. Other terminations are not failures: the user quit the app, an update replaced it, or the system evicted it while it was in the background. The profile names every reason with one closed list, so both platforms report the same values.
Exit reasons
Section titled “Exit reasons”apsio.exit.reason is one of these values, and no other:
| Value | Kind | Meaning |
|---|---|---|
crash |
failure | The platform says the app crashed, but there is no crash report: iOS’s bad access, illegal instruction and abnormal exits, or Android’s REASON_CRASH_NATIVE with no tombstone |
memory |
failure | Killed for memory while the user could see the app, or over the platform’s per-app memory limit: iOS’s memory resource limit (jetsam), or Android’s REASON_LOW_MEMORY with an importance of visible or higher |
watchdog |
failure | The system’s watchdog ended an app that did not respond in time (iOS) |
background_ |
failure | A background task outlived its allowance (iOS) |
cpu |
failure | Over the platform’s CPU limit (iOS) |
locked_ |
failure | Suspended while holding a file lock (iOS) |
thermal |
failure | Ended for thermal pressure |
anr |
failure | Ended after an ANR (Android’s REASON_ANR) |
signal |
failure | Killed by a signal not identified as a crash (Android’s REASON_SIGNALED) |
unknown |
failure | Any other termination without a crash report, including platform reasons not listed here (for example Android’s REASON_EXCESSIVE_RESOURCE_USAGE) |
memory_ |
not a failure | Evicted for memory while in the background: iOS’s memory pressure exits, or Android’s REASON_LOW_MEMORY below visible importance |
user_ |
not a failure | The user ended the app: on Android every REASON_USER_REQUESTED (a force stop, a removal from Recents, a task killer the user installed) and REASON_USER_STOPPED; on iOS, inferred (below). A removal from Recents happens in the background, so its apsio.exit.foreground is false |
app_ |
not a failure | An update of the app replaced the process: Android’s REASON_PACKAGE_UPDATED, or inferred |
os_ |
not a failure | The device updated its operating system: inferred |
normal |
not a failure | The app exited normally, or the platform ended it for a reason that is not a failure: Android’s REASON_EXIT_SELF, REASON_PERMISSION_CHANGE, REASON_DEPENDENCY_DIED, REASON_FREEZER, REASON_PACKAGE_STATE_CHANGE and REASON_OTHER |
With the reason, the SDK sets:
apsio.exit.source:platformwhen read from the platform,inferredotherwise;apsio.exit.foreground: whether the app was in the foreground;apsio.exit.platform_reasonSHOULD, when the source isplatform: the platform’s own name for the reason, without free text: on Android theApplicationExitInfoconstant and, for a signal or an exit code, its status (REASON_SIGNALED/9); on iOS the MetricKit counter or case (cumulativeBadAccessExitCount). It keeps what the closed list folds together, for example Android’s low-memory kills that the platform reports asSIGKILL. An inferred exit has none;apsio.exit.memory.footprintMAY: the last memory footprint the SDK or the platform recorded for the process before it ended, in bytes. It can be minutes old. An unknown footprint is omitted, never sent as0.
Records
Section titled “Records”- SHOULD report a termination of kind failure as a log record with event name
app.abnormal_exit, sent on the next launch, with the attributes of 6.1’s second bullet and those above. Its session’s final summary has outcomeabnormal_exit(section 3.4). - MUST NOT send
app.abnormal_exitfor a reason of kind not a failure. The next launch instead sends the session’s final summary with outcomeexitedand the exit attributes above. - MUST NOT send
app.abnormal_exitfor a session that has anapp.crash, whatever its reason or source (a late platformmemoryrecord included); the crash report wins. A backend that gets one anyway leaves it out of its counts and issues. That session’s final summary, outcomecrashed, SHOULD carryapsio.exit.reason=crashand no other exit attribute. - Termination counts from MetricKit may carry any value (section 7.3).
Sources
Section titled “Sources”- SHOULD read the platform first:
- on iOS 27 and later, MetricKit’s
DiagnosticReport(amemoryExceptionis a first-party out-of-memory record) andForegroundTerminationMetric/BackgroundTerminationMetric; - on iOS 15 to 26,
MXCrashDiagnostic,MXHangDiagnosticandMXAppExitMetric; - on Android 11 and later,
ApplicationExitInfo(with ANR traces; native tombstones from Android 12).
- on iOS 27 and later, MetricKit’s
- MAY infer when the platform says nothing for the previous session, in this order:
app_updatewhen the app’s build (app.build_id) changed since the session;os_updatewhen the operating system’s version or build changed and the device restarted since the session. On iOS a change of the operating system’s version or build implies the restart, so an SDK may inferos_updatefrom that change alone, without reading the system boot time;user_quitwhen the session ended in the background after the platform announced the app’s termination (iOS’sapplicationWillTerminate). A process suspended in the background gets no such notice, so an inferreduser_quitundercounts;- otherwise, when the session ended in the foreground with no crash, no normal
termination and no debugger attached:
memoryif the platform’s low-memory signal was observed in the session (iOS’s memory warning or critical memory pressure; Android’sonTrimMemoryatTRIM_MEMORY_RUNNING_LOWor above, or, from Android 14, which no longer delivers it,ActivityManager.MemoryInfo.lowMemory), elseunknown.
- A platform record takes precedence over an inference for the same session.
- On iOS a platform record can arrive late: MetricKit delivers the diagnostic of an ended
process (a
MemoryExceptionDiagnostic, for example) on a later launch, possibly after that launch has already sent an inferredapp.abnormal_exitand the session’s final summary. The SDK then:- MUST still send the platform record, an
app.abnormal_exitof its own with sourceplatform, carrying the session’s id and the ended instance’s attributes (6.1’s second bullet), unless the session has anapp.crash(Records, above); - MUST send the session’s final summary again, with outcome
abnormal_exitand the platform record’s exit attributes, when it still holds that session’s saved state (the previous process’s session, the usual case) and the session has noapp.crash, whose report wins. For an older session it sends the platform record only; - MUST NOT hold back the inferred record or its summary to wait for a platform record.
- MUST still send the platform record, an
- MetricKit diagnostics join their session through their process id (
environment.pidin the Swift API), matched with the process id the SDK recorded with the session. A diagnostic with no process id, or with one that matches no session, is sent without a session. - A backend joins the two records on
session.idandapp.installation.idwithin the app, so a record naming another install’s session never changes it; it matches a session’s summaries bysession.idwithin the app (3.4). When it has both records, it MUST keep the platform record, leave the inferred one out of its counts, and take the session’s exit attributes from the platform summary when one comes: the session’s termination counts once, with the platform’s reason.
Example of a crash sent by the next launch (OTLP/JSON, trimmed):
{ "eventName": "app.crash", "timeUnixNano": "1759500000431000000", "severityNumber": 21, "attributes": [ { "key": "exception.type", "value": { "stringValue": "EXC_BAD_ACCESS (SIGSEGV)" } }, { "key": "app.crash.id", "value": { "stringValue": "4c1e8a52-0d2f-4f0b-9a8e-7f6d1c2b3a49" } }, { "key": "app.build_id", "value": { "stringValue": "8124C1A2-6E0B-3F51-9D57-1B2E7C4A9B07" } }, { "key": "service.version", "value": { "stringValue": "4.12.0" } }, { "key": "session.id", "value": { "stringValue": "7f3c9b02-5d1e-4a8b-9c0f-2e6a1d4be19a" } }, { "key": "log.record.uid", "value": { "stringValue": "01J9ZQ3W1V8M6K2T4R7N5C0B3D" } } ]}6.5 In-app images
Section titled “6.5 In-app images”An image is in-app when it ships inside the app: the app’s own code, and the frameworks and libraries bundled with it, whoever wrote them. A backend groups crashes by their in-app frames (section 6.1) and asks for symbols for in-app images, so the difference matters before any symbols are uploaded.
- Each entry of
apsio.crash.imagesSHOULD carryin_app, a boolean, decided on the device from the path the image was loaded from. Paths are compared by whole path components (Shop.app2/Shopis not insideShop.app). - On Apple platforms,
in_appistruefor an image inside the app’s bundle: the main executable, Xcode’s<App>.debug.dyliband__preview.dylibin debug builds, and the frameworks and libraries under the bundle. The bundle is the main bundle’s path up to and including its first component that ends in.app, so an app extension (Shop.app/PlugIns/Widget.appex,Shop.app/Extensions/Share.appex) uses its containing app, which it loads frameworks from, and macOS and Mac Catalyst bundles (Shop.app/Contents/Frameworks) work the same way. The executable’s path gives the same root (Shop.app/Contents/MacOS/Shop). Without a.appcomponent (a test bundle run byxctest, a command-line tool), the root is the bundle’s path itself, or the executable’s directory when only the executable’s path is known. - The bundle is that of the process the images were loaded in (for a crash, recorded with
the crash), not the reporting launch’s: an update or a reinstall moves the bundle to a new
container. Paths are compared as text,
not resolved (the crashed install may be gone, and resolving does I/O), after removing a
leading
/privatefollowed by/var/or/tmp/on both sides, since the loader and the bundle APIs can report the same directory with or without it. - On Android the decision uses the app’s package name, not the directories of the launch
that reports the crash: an update moves the install directory, and the crashed
process’s paths cannot be resolved afterwards. A trailing
(deleted)(a file replaced while the process ran) is removed first.in_appistruefor:- a shared library (
.so) or an APK (.apk) in the package’s install directory: under/data/app/or/mnt/expand/<volume>/app/, optionally inside one~~<random>==directory, a directory whose name starts with<package>-(/data/app/~~Qm9x==/com.example.shop-Zk4p==/lib/arm64/libshop.so); - a shared library loaded straight from one of those APKs, when native libraries are not
extracted (AGP’s default). Its image is the library, not the APK: its path is
<apk path>!<library>, as a tombstone’s frames show it (/data/app/~~Qm9x==/com.example.shop-Zk4p==/base.apk!libshop.so, or a split APK’ssplit_config.arm64_v8a.apk!libshop.so), and its name is the library’s file name, its build id and load address the library’s own. It is in-app when that APK is the package’s and the part after the!is a shared library; - a shared library under one of the package’s data directories:
/data/data/<package>,/data/user/<user>/<package>,/data/user_de/<user>/<package>, and the same two under/mnt/expand/<volume>/(libraries extracted at run time).
- a shared library (
- Every other image is
false: on Android the runtime’s compiled code (.odex,.vdex,.oat,.art), anonymous and memory-file mappings ([anon:…],/memfd:…), the system’s partitions (/system,/system_ext,/vendor,/product,/apex) and other packages, such as WebView’s. - On Apple platforms the path is used on the device only, and the SDK MUST NOT add it to the image: the bundle’s location holds a per-install identifier.
- A backend MUST use
in_appas sent when it is present, whether or not symbols were uploaded for the image. When it is absent, from an SDK older than this rule, the backend decides its own way; this profile does not define how. - The vector
crashes/image-in-appchecks the decision (appendix B.2).