MetricKit Overview: iOS Performance and Diagnostic Monitoring
MetricKit, introduced in iOS 13 and expanded in iOS 14, provides a low‑overhead, system‑driven way to collect app performance, power, and crash diagnostics over the last 24 hours, enabling developers to upload, analyze, and optimize their iOS applications without third‑party SDKs.
MetricKit is an Apple‑provided framework introduced in iOS 13 that automatically gathers a variety of performance, power, and stability metrics for the previous 24 hours and delivers them to the app for further processing.
Unlike many third‑party SDKs, MetricKit operates with near‑zero intrusion, does not require custom instrumentation, and can capture system‑level crashes such as watchdog, OOM, and CPU exceptions that ordinary SDKs cannot see.
To use MetricKit, implement the MXMetricManagerSubscriber protocol, handling didReceiveMetricPayloads: (iOS 13+) for metric data and didReceiveDiagnosticPayloads: (iOS 14+) for diagnostic reports, then register the subscriber with [[MXMetricManager sharedManager] addSubscriber:mySubscriber]; .
The system sends at most one report per day, typically between 16:00 CST and 15:59 CST the next day; on iOS 15 diagnostic reports are delivered immediately after an exception, though the exact timing for development builds may differ.
Internally, MXMetricManager uses private methods _checkAndDeliverMetricReports and _checkAndDeliverDiagnosticReports to read serialized files from /Library/Caches/MetricKit and invoke the subscriber callbacks.
Developers often upload the raw JSON payloads to a backend for aggregation and visualization, as the Xcode Organizer view is limited.
MetricKit provides many metric types, for example:
Cellular condition ( MXCellularConditionMetric ) – percentage of time spent under each signal strength.
CPU usage ( MXCPUMetric ) – cumulative CPU time and instruction count.
Display luminance ( MXDisplayMetric ).
GPU time ( MXGPUMetric ).
Location activity, network transfer, app exit, run‑time, memory, launch time, animation hitch, responsiveness, disk I/O, and custom signpost metrics.
Diagnostic payloads include crash reports ( MXCrashDiagnostic ), CPU exceptions ( MXCPUExceptionDiagnostic ), hangs ( MXHangDiagnostic ), and disk‑write exceptions, each containing call‑stack trees and meta‑data such as OS version, device type, and termination reason.
Because some apps use segment migration to shrink binary size, MetricKit may lose binaryUUID and offset information; the solution is to record version‑specific UUIDs locally and compute the offset of the main function to reconstruct missing data.
Since its adoption, MetricKit has revealed many crashes and hangs that were missed by internal SDKs, leading to concrete fixes such as avoiding excessive concurrent dispatches during launch and removing notification observers that block the main thread.
MetricKit is now integrated into the Volcano Engine APMPlus product, providing developers with richer performance and stability insights for iOS applications.
ByteDance Terminal Technology
Official account of ByteDance Terminal Technology, sharing technical insights and team updates.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.