Instana U

 View Only

Mobile crash analytics for iOS App with Instana

By LU XIAO posted Thu December 28, 2023 11:51 AM

  

Mobile developers might often suffer from app crashes. Instana provides a crash collection and analytics process for them to detect, understand and resolve app crashes promptly. This crash analytics feature minimizes the number of affected users, reduces the negative impact of crashes and ultimately improves the user experience.

Symbolication

When an app crashes, the operating system collects diagnostic information about the app at the time of the crash. One of the most important parts of the crash report are the thread backtraces, which are reported as hexadecimal addresses. Instana translates these addresses into readable function names and line numbers in source code through a process called symbolication. Symbolication is achieved by using debug symbols.

dSYM(debug Symbol) file

When Xcode compiles your source code into machine code, it generates a list of symbols in your iOS app — class names, global variables, and method and function names. Debug symbols associate these symbols with file and line numbers where they’re defined. All debug symbols are stored in a dSYM file for each binary file in an app. With the dSYM files, the crash report can be symbolicated to show function names and line numbers instead of memory addresses. 

Analyzing iOS app crashes

To collect and analyze iOS app crashes with dSYM files, complete the following steps:

  1. Create a mobile app in the Instana UI:

a. Go to Websites & Mobile Apps > Mobile Apps.

b. On the Mobile Apps tab, click Add Mobile App.

c. Enter a mobile app name.

Add Mobile App 
Get started with mobile app monitoring to better understand how your mobile app 
performance impacts user experience. Configuration is simple! 
Mobile App Name 
Add Mobile App

 

         d. Record the values for Reporting Url and Key.

  2. Add the Instana iOS agent as a dependency to your iOS app by using one of the following tools:

  • Swift Package Manager (through Xcode)
  • CocoaPods

      For more information, see iOS agent installation.

  3. Set up the Instana iOS agent with crash collection enabled: 

a. Initialize the Instana iOS agent by calling the setup() function in your app code.

b. Set the enableCrashReporting property to true.

import UIKit
import InstanaAgent

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        Instana.setup(
            key: "pUGWKa8aRq6RnyJWibf-MQ",
            reportingURL: URL(string: "https://instana.rocks/mobile"),
            enableCrashReporting: true
        )
        return true
    }
}

 

  4. Build your iOS application with symbol information in Xcode:

a. Configure the Debug Information Format build setting to DWARF with dSYM File.

b. Set the Generate Debug Symbols option to Yes.

By configuring these settings, Xcode generates the related dSYM files for your app during building.

  5. Release your iOS app and install the app on your iOS device.

  6. Upload your compressed dSYM files to the Instana backend:

a. In the Instana UI, create a configuration to upload the dSYM file:

b. Compress your dSYM files into a .tgz file.

c. Upload the file by using the Instana web REST API.

EUM iOS Crash 
Edit Symbol File Upload Configuration 
Description 
An upload configuration will help you to better organize your uploaded files. 
Description 
exampleApp 
Uploading Symbol Files 
x 
Filters 
Summary 
Platfor 
HTTP Re 
CONFIGURATION 
Options 
Privacy 
Stack Trace Translatior 
Custom Geographic D 
Upload your symbol files by calling Instana's Web REST API. This could be integrated into your pipeline process for automated deployment. 
The explanation and usage of our Web REST API is defined within our documentation. 
Upload Symbol File API 
https://release-instana.instana.rocks/api/mobile-app-monitoring/config/pUGWKa8aRq6RnyJWibf-MQ/sourcemap-upload/97c2a68e590e6ed/form 
Commit Symbol File API 
https://release-instana.instana.rocks/api/mobile-app-monitoring/config/pUGWKa8aRq6RnyJWibf-MQ/sourcemap-upload/97c2a68e590e6ed/commit 
Remove All Files API 
https://release-instana.instana.rocks/api/mobile-app-monitoring/config/pUGWKa8aRq6RnyJWibf-MQ/sourcemap-upload/97c2a68e590e6ed/clear 
Examples 
Prepare iOS app symbolication file or Android java mapping file 
Compress the IOS app's dSYM folder or Android java mapping file into one tgz file. 
To compress the app's dSYM folder, run following command 'tar czf your _ app. dSYM. tgz your_app.dSYM_folder' . 
If the compressed file is larger than 101B, split the file into multiple blobs. 
To split the tgz file, run following command 'split —b 9m your_dSYM_fite.tgz tgz_blob_ 
Upload IOS app symbolication file or Android java mapping file blob by blob 
curl 
—location 
—request PUT \ 
' https : / / release—instana. instana. rocks/api/mobi 
Copy 
Copy 
Copy 
Dec 27 
10 minutes 
files. Adding an upload 
sights into Mobile App crash 
onfiguration 
d 
27, 10:48:12

 

For more information, see Uploading dSYM files

  7. Simulate an iOS app crash

a. Trigger a crash of your iOS app, such as memory access error or no disk storage. 

b. Start your app again.

  8. Analyze crashes in the Instana UI:

a. Go to Websites & Mobile Apps > Mobile Apps.

b. Click your mobile app.

c. On the Crashes tab, click an error message group. You can view all crash details. The details include the number of crashes, number of affected users, error messages, stack trace, and other information.

The pretty stack trace provides a symbolicated result of the crash log with following information, which helps you diagnose issues in your app more easily.

    • Image class
    • File name
    • Function name
    • Line number of the code in the file
    • Memory address

 

 

Summary

 

Instana crash analytics provides deep insight into the stability and performance of mobile apps, which helps mobile developers to provide more stable products with better user experiences.

 

Co-Authors: 

Xiao Lu (xiaolu@cn.ibm.com) - Developer for Instana End User Monitoring
Li Shao Rong (lsrlibj@cn.ibm.com) - Dev lead for Instana End User Monitoring
Helen Jiang (helen.hongyan.jiang@ibm.com) - Mobile developer for Instana End User Monitoring

Permalink