background

Performance issues

Under normal circumstances, the performance of the App does not directly cause it to be unusable, but it will potentially affect the user experience. In the current "volume" of many apps, a bad experience can even lead to the loss of users. for example:
• Start-up speed is too slow
• High CPU occupancy rate caused by mobile phone heating, fast power consumption
• Unexplained crash
• …and many more

Prevention and inspection

Of course, as a developer, you must avoid some performance problems when writing code. for example:
• Optimize calculation complexity to reduce CPU usage
• Write unit tests
• ...and many more
Of course, making good use of tools can efficiently monitor App performance issues and help developers fix defects in product experience in a timely manner. There are many APM tools on the market, because the author has used U-App in the project to perform application information statistics. Here are some experience using U-Meng U-APM.

U-APM use medical examination

integrated

Refer to the integration instructions of the official platform, take iOS as an example, here is a brief description

  1. Create an application in U-APM and generate an Appkey
  2. It is recommended to use CocoaPods to connect to the SDK pod'UMCommon'
  3. pod 'UMDevice'
  4. pod ‘UMAPM’

In the AppDelegate.m file, add the following

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
[UMConfigure initWithAppkey:@"61276660870a7a610a4f67f5" channel:@""]; 
// Appkey在步骤1中生成 
// channel字段为自定义渠道区分,不填写则被默认为是"App store" return YES; 

}

Analysis result

1. Crash analysis

I just handwritten a crash bug that can be triggered automatically on the homepage of the project. The analysis results are illustrated as follows:

The graph of the collapse is an overall display for developers. The important thing is that in the error list at the bottom of the page, you can view the number of times a certain error has occurred, the type, and the number of users affected. This is very convenient as a developer can quickly and accurately determine the priority when modifying a bug. In addition, errors have a separate error detail page, and most of the bugs can be accurately located.

Later, inspired by the crash analysis of U-APM startup, I crash in the startup method of the project-(BOOL)application:(UIApplication 161a04db86925f )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions, that is, before and after configuring Appkey. Bug, and temporarily distinguished by channel name.
The result showed that the crash that occurred before the AppKey was configured could not be captured.
Some people may ask: Isn't this inevitable? You haven't configured it yet...

This is exactly what I want to talk about. Because in many cases, when we configure some third-party libraries, because the integration method is too simple, we will always add a line of code according to the official tutorial at will, and do not look at the best position in the project code. . Because this does not affect the operation of the project, this kind of detail can easily be overlooked. I hope that at any time, developers should develop the habit of trying to think before each line of code is typed.

2. Caton analysis


Caton’s list and details are the same as crashes, which can be queried and located. And it can mark 4 states (unprocessed, repaired, ignored, repaired).
I also added a stutter warning plan. As long as the number of stuttered users exceeds 5%, I will be notified by email. It successfully triggered an alarm message within an hour and reminded me in the email.

I used random numbers to randomly slow down the startup speed of the project. By default, the first start/cold start is more than 3 seconds as slow start, and the hot start is more than 1 second. Here is an example of cold start:

The analysis histogram also shows the proportion of normal start and slow start

4. Memory Analysis

In the analysis of OOM, it seems that the support for Android is even better than iOS. Due to the Jetsam mechanism of iOS, only a special crash caused by the program memory exceeding the limit is analyzed here. Including the capture of exceptions is not all detectable.

5. Distribution analysis

The platform can provide distribution status in the analysis of the above four modules (crash, freeze, slow start, OOM abnormality), including device distribution, system distribution, operator distribution, version distribution, page distribution, channel distribution, and geographic distribution.

6. Custom configuration module

U-APM also provides a collection switch, which needs to be configured in the code before initialization.

The above is all the functions of U-APM I experienced.
There are also some functions that I have no time to experience waiting for more developers to use, such as "cloud real machine", "API upload symbol table page overall loading speed rendering" and so on.

Some suggestions to share

An analysis error occurred in the operator module of Caton Analysis and Crash Analysis ❌. I am using a telecom broadband and telecom card, but the analysis results show that I am using a China Mobile operator. Of course, for this kind of problem, the platform has another customer service ticket that can be raised, and I won't repeat it here. (From the perspective of using other Umeng products in the past, the feedback efficiency of customer service work orders is still quite good)
It is also worth mentioning that because the author has completely transitioned the development language to Swift in the project, but when integrating, the official reminder that Swift currently only supports U-App statistics, and other businesses do not currently support Swift. I also created an OC project overnight to experience it, and did not try to access it in the Swift project. Now, Swift has become the mainstream language for iOS development. I hope U-APM can fully support Swift in the future and make it more convenient for developers.
Of course, this does not prevent it from being able to meet the basic needs of developers for performance monitoring in OC projects:
• The integration method is simple and fast
• Track detailed information about crashes and freezes, and easily locate the root cause
• The analysis diagram is clear and easy to manage with multiple states
• Identify the device type (iPhone/iPad/iPod, operating system version, operator type), classify device performance
Finally, I still hope that the appropriate use of tools can improve development efficiency, but please don't forget to think too much.

Author: Cai Danxia


性能优化实践者
11 声望220 粉丝