Fix App Hangs in Kotlin Multiplatform Apps (iOS)

App hangs in KMP apps (iOS and iPadOS)
An app hang happens when an iOS or iPadOS app stops responding to user input for 250 milliseconds or more. In a Kotlin Multiplatform (KMP) app, the iOS UI, whether SwiftUI, UIKit or Compose Multiplatform, runs on the main thread together with any shared Kotlin code called from it.
During a hang the interface freezes and taps, scrolls and gestures are ignored. Short hangs make the app feel sluggish; long ones lead users to force-quit the app.
App hangs are the iOS counterpart of ANRs on Android, and in KMP apps they often come from the same shared code, which means a fix in commonMain can improve both platforms.
Why does this happen?
App hangs in KMP iOS builds usually come from:
Blocking calls from Swift into shared code: Calling a Kotlin function synchronously from Swift on the main thread when that function does heavy work, file access or parsing.
runBlocking and main-dispatcher work: Shared code that uses runBlocking or runs expensive work on Dispatchers.Main blocks the iOS main thread.
Slow I/O: Database queries, file reads or synchronous network calls triggered from the UI.
Heavy Compose Multiplatform recomposition: Expensive calculations inside composables that run on every recomposition.
Deadlocks and lock contention: The main thread waiting on a lock or mutex held by a background coroutine or thread.
How to fix it using Appxiom
- Analyze stack trace: The issue report provides the stack trace of the main thread, pointing to the code that likely caused the hang.
- Trace activity trail: The activity trail, a chronologically ordered list of events before the issue, helps you retrace how the user was interacting with the app.
- No extra code needed: App hangs are tracked automatically once
Ax.startIOSis called on iOS. See Crash & Error Reporting for KMP.
Stop guessing. Start fixing.
Get real-time alerts, exact stack traces, and complete activity trails before these issues impact your revenue.
Related Issues & Failure Guides
Fix Crashes in Kotlin Multiplatform Apps
Detect crashes from shared Kotlin code on Android and iOS, including uncaught coroutine exceptions and Kotlin/Native crashes, with full stack traces and trails.
Fix ANR in Kotlin Multiplatform Apps (Android)
Detect ANRs in the Android build of KMP apps. Find runBlocking calls, main-dispatcher work and slow I/O in shared code that freeze the UI thread.
Fix High Memory Usage in Kotlin Multiplatform Apps
Monitor abnormal memory growth in KMP apps on Android and iOS. Find unbounded caches and long-lived scopes in shared code before out-of-memory crashes.
We use cookies to improve your experience.