Error monitoring

Crashes, ANRs and app hangs

Capture native crashes, ANRs, app hangs and watchdog terminations on iOS, Android, Flutter and React Native, and minidumps from desktop and Electron apps.

Markdown

A crash ends the process, so it can't be sent while it happens. AppHelm's mobile SDKs write a small report to disk at the moment of the crash, using only work that is safe inside a signal handler, then let the app end as it would have. The next time the app starts, the report is sent as an unhandled, fatal issue with the crashed run's release, environment, tags, user hash and last 30 breadcrumbs, and the run's release-health session is marked crashed.

Hangs and ANRs are different: the app is still alive but its main thread is stuck. They are reported when the hang ends, or on the next launch if the app was killed during it, and they mark the session abnormal rather than crashed.

#What each platform captures

iOS / macOS Android Flutter (with apphelm_flutter_native) React Native
Uncaught language errors NSException Java and Kotlin exceptions Dart errors (in apphelm_flutter), plus native ones JavaScript errors and rejections
Fatal signals SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGSYS, SIGTRAP NDK crashes (Android 12+ by default; opt in below 12) Both No
Stack overflow Yes (see limits) NDK, through the signal handler Main thread on iOS No
App hangs / ANRs App hangs (2 s) ANRs (5 s watchdog, and the system's own ANR exits on Android 11+) Both No
Killed in the foreground Watchdog terminations (likely out of memory) No iOS only No
On by default No: call installCrashReporting() Yes, in Apphelm.setup When you add ApphelmNativeIntegration() JavaScript errors only

React Native captures JavaScript errors only. Native crashes, ANRs and hangs in a React Native app aren't captured by AppHelm's SDK.

#Turn it on

No example for this step; showing iOS (Swift).

App.swift
let apphelm = ApphelmClient(options: ApphelmOptions(
  apiKey: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…",
  release: "shop@2.4.1", environment: "production"))

try apphelm.installCrashReporting()              // signals, NSException, app hangs, watchdog terminations
Task { await apphelm.sendPendingCrashReports() } // send last run's reports
App.kt
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Apphelm.setup(this, ApphelmConfig(BuildConfig.APPHELM_API_KEY, "org_…", "prd_…").apply {
            environment = if (BuildConfig.DEBUG) "debug" else "production"
            // captureNativeCrashesBeforeAndroid12 = true  // opt in for NDK crashes on Android 11 and older
        })
    }
}
lib/main.dart
import 'package:apphelm_flutter/apphelm_flutter.dart';
import 'package:apphelm_flutter_native/apphelm_flutter_native.dart';

void main() => Apphelm.runGuarded(() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Apphelm.setup(ApphelmConfig(
        apiKey: const String.fromEnvironment('APPHELM_KEY'),
        workspaceId: 'org_…', productId: 'prd_…', release: 'shop@2.4.1',
        captureFlutterErrors: true,                 // Dart errors
        integrations: [ApphelmNativeIntegration()], // native crashes, ANRs, hangs
      ));
      runApp(const MyApp());
    });
const mobile = createReactNativeSdk({
  apiKey: "ahl_pub_…", workspaceId: "org_…", productId: "prd_…",
  release: "shop@2.4.1", storage: AsyncStorage, // storage keeps unsent fatal reports for the next launch
});
// captureUnhandled is on by default: ErrorUtils and promise rejections.
// Desktop or server JVM: write crashes to disk, send them on the next start.
val crashes = FileCrashReportStore(File(appDataDir, "apphelm-crashes"))
apphelm.installCrashReporting(crashes)
Executors.newSingleThreadExecutor().execute { apphelm.sendPendingCrashReports(crashes) }
// A stuck UI thread: implement MainThread for your toolkit, then
// apphelm.installAnrWatchdog(crashes, myMainThread, timeoutMs = 5_000)

For Flutter, add both packages from AppHelm's package host:

pubspec.yaml
dependencies:
  apphelm_flutter:
    hosted: https://apphelm.dev/packages/pub
    version: ^0.8.1
  apphelm_flutter_native:
    hosted: https://apphelm.dev/packages/pub
    version: ^0.8.1

apphelm_flutter_native needs iOS 12 or Android 5 (API 21), and the Android NDK and CMake 3.22.1 to build its small C library. On the web and desktop it does nothing.

#iOS and macOS

#Crashes

installCrashReporting(directory:) installs handlers for the fatal signals above and for uncaught NSExceptions. Reports go to Caches/Apphelm unless you pass a directory. Handlers installed before AppHelm's are kept and called after AppHelm writes its report, so other crash reporters still work. Installing twice does nothing, and nothing is installed when the client is disabled.

  • A signal crash is named after the signal (SIGSEGV), with the message The app crashed with SIGSEGV and the tag mechanism: signal.
  • An NSException is reported once, by its name and reason (mechanism: nsexception); the SIGABRT that follows it is skipped.
  • Swift's fatalError and precondition messages are read from the Swift runtime and become the message. In -O builds, a force-unwrapped nil or a failed precondition carries no message.
  • C++ exceptions arrive as the SIGABRT of std::terminate, without their type or message.
  • Stack overflow: the thread that installs crash reporting gets a 64 KB alternate signal stack, and every thread started afterwards gets its own 128 KB one, so a crash on an overflowed stack can still be written. Threads already running at install time, other than the installing one, are not covered: install early.

#App hangs

App hang tracking starts with installCrashReporting(). A background thread watches the main thread while the app is active and no debugger is attached.

Option Default What it does
enableAppHangTracking true Turns hang detection on or off
appHangTimeoutInterval 2 seconds How long the main thread must be blocked
enableReportNonFullyBlockingAppHangs true Also reports hangs where some frames still render
enableFramesTracking true Uses the display link to measure frames; without it (macOS, or off) a hang is a main-queue ping that hasn't run in time
  • A hang the app comes out of is reported when it ends, at level error, as App Hang Fully Blocked or App Hang Non Fully Blocked, with the main thread's stack and a message such as App hanging between 2.4 and 2.8 seconds. It counts as handled.
  • If the app is killed during a hang (by the person or the system), the next launch reports Fatal App Hang Fully Blocked at level fatal, unhandled, and marks the session abnormal (anr_foreground).
  • Pause tracking around work you know blocks, such as a system dialog, with pauseAppHangTracking() and resumeAppHangTracking().

#Watchdog terminations

When iOS kills an app in the foreground, usually for using too much memory, nothing runs in the app. AppHelm infers it on the next launch: if the last run was active, didn't crash, hang, exit normally or call close(), and neither the app, the OS version nor the boot time changed, and no debugger was attached, it reports a WatchdogTermination (The OS watchdog terminated your app, possibly because it overused RAM.) at level fatal, without a stack.

Option Default Notes
enableWatchdogTerminationTracking true UIKit only (iOS, tvOS, visionOS); never on a simulator or macOS

Call installCrashReporting() on the main thread: the check reads the vendor id there, and skips that launch otherwise. Kills in the background aren't reported.

#Android

#Options

Apphelm.setup turns on crash and ANR capture with these defaults:

Option Default What it captures
captureCrashes true Uncaught Java and Kotlin exceptions, on any thread
captureAnrs true The main thread stuck for anrTimeoutMs, and on Android 11+ the ANRs the system recorded
anrTimeoutMs 5000 The watchdog's threshold
captureNativeCrashes true NDK crashes on Android 12+ (API 31), from the system's tombstones
captureNativeCrashesBeforeAndroid12 false NDK crashes on Android 11 and older, with AppHelm's own signal handler

Reports wait in noBackupFilesDir/apphelm-crashes/<productId>. The newest 20 are kept; they are sent oldest first in the background at the next start, and sending stops at the first failure so nothing is lost.

#Uncaught exceptions

The default uncaught-exception handler writes the report on the crashing thread (to a temporary file, synced and renamed), then hands over to the previous handler. The report carries the full exception class, up to 40 frames and up to four Caused by sections, and the tags mechanism: uncaught_exception and thread: main or background.

#ANRs

Two sources work together:

  • The watchdog posts to the main thread and reports ANR (The main thread did not respond for 5000 ms, mechanism: anr) once per stall. It skips stalls while a debugger is connected, and doesn't count time the whole process was frozen. The report is sent on the next launch.
  • The system's record, on Android 11+ (API 30): at start-up AppHelm reads ApplicationExitInfo entries with REASON_ANR since the last run, including the main thread from the system's trace. If the watchdog already reported the same process, that report gains exit_reason: anr instead of a second report; otherwise a new ANR (Android reported the app not responding, mechanism: anr_exit_info) is sent with the stalled run's release and session. On the first launch with AppHelm only the newest exit is recorded, so old ANRs aren't reported.

Both mark the session abnormal, with anr_foreground or anr_background, which feeds the ANR rate.

#NDK crashes

  • Android 12 and later (captureNativeCrashes): at start-up AppHelm reads the REASON_CRASH_NATIVE exits since the last run (up to 8 a launch), trims each tombstone on the device to the signal, the cause and the crashed thread, and uploads it. No native code is added to your app.
  • Android 11 and older (captureNativeCrashesBeforeAndroid12 = true): loads a small C library (libapphelm-native.so, four ABIs) whose signal handler records SIGSEGV, SIGBUS, SIGFPE, SIGILL, SIGABRT, SIGTRAP and SIGSYS: the signal, fault address, thread name and up to 64 frames with each library's build id. It then hands the signal on, so Android's own tombstone and other reporters still run. The newest 4 records are kept and sent on the next launch. It is never installed on Android 12 or later. It has been tested on an Android 11 emulator, not on physical devices.

Upload Breakpad .sym files for your .so libraries to see function names (NDK libraries).

#Flutter

#Dart errors

captureFlutterErrors: true (off by default; Apphelm.init turns it on) installs:

  • FlutterError.onError for framework errors (errors marked silent are skipped),
  • PlatformDispatcher.instance.onError for uncaught asynchronous errors,
  • an Isolate error listener (not on the web).

Apphelm.runGuarded(…) or Apphelm.init(config, appRunner: …) also runs your app in a guarded zone. Every one of these reports is unhandled.

#Native crashes, ANRs and hangs

ApphelmNativeIntegration() adds what the iOS and Android SDKs capture, with sentry_flutter's option names:

Option Default Covers
enableNativeCrashHandling true iOS signals and NSException; Android's Java handler. false also turns Android ANRs off
anrEnabled, anrTimeout true, 5 s Android ANRs: the system's record on Android 11+, a watchdog on 10 and older
enableAppHangTracking, appHangTimeout true, 2 s iOS app hangs (fully blocking only)
enableWatchdogTerminationTracking true iOS watchdog terminations
enableTombstone true Android 12+ NDK crashes
enableNativeCrashHandlerBeforeAndroid12 false Android 11 and older NDK crashes
enableNativeAppStart true The native app start span (needs a trace sample rate)
integrations: [ApphelmNativeIntegration(anrTimeout: const Duration(seconds: 8), enableNativeCrashHandlerBeforeAndroid12: true)],

Reports wait in Caches/apphelm_flutter_native (iOS) or noBackupFilesDir/apphelm_flutter_native (Android), newest 20 kept, and are sent by the Dart client on the next launch, so ignoreErrors, sampleRate, scrubbing and beforeSend apply. Each carries the crashed run's session, tags, contexts, user hash and last 30 breadcrumbs. Dart frames inside a native stack stay as addresses in App.framework or libapp.so.

#Desktop and Electron minidumps

Crashpad, Breakpad and Electron write a minidump (.dmp) when a native process crashes. AppHelm has no desktop crash handler of its own; it accepts the dumps these tools write, unwinds their threads and symbolicates them with your Breakpad symbols.

#Send a minidump file

apphelm send-minidump crash.dmp --product prd_… --release 2.4.1 --env production
# Sent minidump crash.dmp as event 8c1f…. It appears under Errors in a few seconds.

It also takes an Android tombstone (.pb). It needs a key with events:write for the product.

#Point a crash reporter at AppHelm

Use POST https://apphelm.dev/api/v1/native-crashes as the reporter's upload URL. It accepts the crash reporters' multipart form: the dump in upload_file_minidump (or upload_file_tombstone), with other text fields kept as tags (up to 20, scrubbed) and ver or _version taken as the release.

main.js (Electron)
const { crashReporter } = require("electron");

crashReporter.start({
  submitURL: "https://apphelm.dev/api/v1/native-crashes?productId=prd_…",
  uploadToServer: true,
  globalExtra: { api_key: process.env.APPHELM_CRASH_KEY, environment: "production" },
});
  • The key is a server key with events:write, in Authorization: Bearer. Uploaders that can't set headers can send it as an api_key form field (preferred, because it isn't logged with the URL) or query parameter. Use a key with only events:write, limited to this product, because it ships inside the app.
  • productId can be left out when the key is limited to one product.
  • Optional distinct_id, session_hash and user_hash fields (16–64 hex characters) link the crash to a person and a release-health session.
  • Sentry's minidump endpoint also works: POST https://apphelm.dev/sentry/api/<project number>/minidump/?sentry_key=… with the same form. A dump sent with a browser (ahl_pub_) key is dropped. See Migrate from Sentry.

The answer is 202 { accepted, eventId, format }. A file AppHelm can't read still becomes a fatal event without a stack, and detail says why.

Answer Cause What to do
401 No key, or an unknown key Send a server key
403 scope_denied, product_scope_denied The key lacks events:write or this product Use a key with both
413 payload_too_large Over the size limit Capture stack-only minidumps, not full memory
422 product_required No product and the key covers several Add productId
422 crash_file_required, unknown_crash_format No dump field, or not a minidump or tombstone Send the file in upload_file_minidump
409 Collection is paused, or the product is archived or the demo Resume collection or restore the product
429 event_limit The monthly allowance is used up Raise the cap in billing

#What a minidump becomes

The crash is one fatal, unhandled $exception named after the crash reason (EXCEPTION_ACCESS_VIOLATION_WRITE, SIGSEGV, EXC_BAD_ACCESS, EXCEPTION_STACK_OVERFLOW, or Minidump when the dump records no exception), with the message <reason> at 0x… and tags mechanism: minidump, os and cpu. Threads are unwound on arrival for x86, x86-64, ARM and ARM64, using STACK CFI records from your uploaded .sym files, then frame pointers, then a bounded stack scan: 64 frames for the crashed thread and 32 for each of up to 31 other threads. The issue groups on the crashed thread.

Upload symbols before crashes arrive: a dump is unwound once, when it arrives. Without symbols, frames read module 0x… + offset and the issue lists the modules that need a .sym.

The raw minidump is kept for 30 days (or your capture retention, if shorter) for owners, admins and engineers to download from the issue. Tombstones aren't kept, because they hold the app's recent log lines.

#How crashes show up

Source Issue title mechanism tag Level Session
iOS signal SIGSEGV and others signal — crashed
iOS NSException The exception name nsexception — crashed
iOS app hang (recovered) App Hang Fully Blocked / Non Fully Blocked AppHang error errored
iOS fatal app hang Fatal App Hang Fully Blocked AppHang fatal abnormal
iOS watchdog termination WatchdogTermination watchdog_termination fatal crashed
Android exception The exception class uncaught_exception — crashed
Android ANR ANR anr, anr_exit_info (Flutter: AppExitInfo) — abnormal
NDK crash, minidump The crash reason, NativeCrash or Minidump tombstone, minidump fatal crashed (when the session is sent)
React Native fatal error The error name onerror, onunhandledrejection fatal crashed

All are unhandled except recovered app hangs. Filter for them with tag search, for example mechanism:AppHang or mechanism:anr in issue search.

#Symbols

Stacks from release builds need symbols to show function names and lines:

  • iOS: upload dSYMs with apphelm debug-files upload. Without them, frames show the image and offset, and the issue names the dSYM (image and UUID) to upload.
  • Android: upload the R8 mapping.txt for the release, and Breakpad .sym files for NDK libraries.
  • Minidumps: upload Breakpad .sym files with each build.

Source maps and debug symbols covers each one.

#Check it works

There is no built-in "test crash" call in the SDKs. Crash on purpose in a debug menu of a release build, run without a debugger (hang and watchdog detection skip debugged runs):

No example for this step; showing iOS (Swift).

Button("Crash") { fatalError("AppHelm test crash") }
Button(onClick = { throw RuntimeException("AppHelm test crash") }) { Text("Crash") }
ElevatedButton(onPressed: () => throw StateError('AppHelm test crash'), child: const Text('Crash'));
<Button title="Crash" onPress={() => { throw new Error("AppHelm test crash"); }} />
  1. Crash the app

    Install a release build, open it without a debugger, and press the button.

  2. Start it again

    Open the app again. The stored report is sent at start-up.

  3. Find the issue

    Open Reliability → Issues. The crash appears within seconds, unhandled and fatal, with the crashed run's release. Open it to check the frames are symbolicated.

#Limits and what isn't covered

What Limit
Stored reports iOS: no cap; Android and Flutter: newest 20; Android 11 NDK handler: newest 4
Stack sent 40 frames, 200 characters each, 4,000 characters in all; up to 16 debug images on iOS
Android ANR trace read 2 MB
Tombstone 4 MB
Minidump 10 MB; request body 12 MB as sent, 16 MB decompressed
Minidump kept for download 30 days, or your capture retention if shorter

Not covered today:

  • iOS: Mach exceptions (signals only); other threads than the crashed one (or the main thread for hangs); stack overflow on threads that were running before install; kills in the background; MetricKit reports.
  • Android: threads other than the crashed one in NDK crashes, and other than the main thread in ANRs; out-of-memory and other low-memory exits; a crash after which the app is never opened again.
  • Flutter: Dart frames in native stacks stay as addresses; no session replay of the crashed run.
  • React Native: native crashes, ANRs and hangs.
  • Desktop: no AppHelm crash handler; you need Crashpad, Breakpad or Electron to write the dump. Dumps that arrived before their .sym aren't unwound again.

#Best practices

  • Install crash reporting first, before other start-up work, so early crashes and new threads are covered.
  • Set release and environment, so crashes count toward the right release's crash-free rate.
  • Upload symbols in CI for every release build, before it reaches users.
  • Don't test with a debugger attached. Debuggers catch signals first, and hang detection is off while one is attached.
  • Keep the default ANR and hang thresholds unless you have a reason; they match Android's and Sentry's, so rates compare.

#Troubleshooting

Symptom Likely cause What to do
No iOS crashes arrive installCrashReporting() isn't called, or sendPendingCrashReports() never runs Call both at start-up
A crash appears only after the second launch Reports are sent on the next start, and the first send failed Expected when offline; it is kept and retried
No crashes while testing from Xcode or Android Studio The debugger catches the signal Run the build without a debugger
No app hangs reported A debugger is attached, the app isn't active, or tracking is paused Test without a debugger, in the foreground
No watchdog terminations Simulator, macOS, a changed release or OS, or installCrashReporting() called off the main thread Test on a device, and install on the main thread
No NDK crashes on Android 11 or older The handler is opt-in Set captureNativeCrashesBeforeAndroid12 = true
NDK crashes don't change the crash-free rate Kotlin-SDK NDK reports carry no session Expected today; see the warning above
Frames show addresses or a.b.c Symbols for that build weren't uploaded Upload dSYMs, mapping.txt or .sym files; see Source maps and debug symbols
413 payload_too_large for a minidump Full-memory dumps Configure the reporter for stack-only minidumps
React Native native crash missing The React Native SDK captures JavaScript only Expected today