Skip to content

Commit

Permalink
Merge pull request #721 from Tencent/feature/ios
Browse files Browse the repository at this point in the history
Matrix iOS Feb 2022 Update
  • Loading branch information
chzhij5 authored Feb 18, 2022
2 parents c7c07b1 + 5608a20 commit 6144583
Show file tree
Hide file tree
Showing 125 changed files with 6,210 additions and 1,908 deletions.
56 changes: 24 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
[Matrix for iOS/macOS 中文版](#matrix_ios_cn)
[Matrix for android 中文版](#matrix_android_cn)
[Matrix for iOS/macOS](#matrix_ios_en)
[Matrix for android ](#matrix_android_en)
[Matrix for android](#matrix_android_en)

**Matrix** is an APM (Application Performance Manage) used in Wechat to monitor, locate and analyse performance problems. It is a **plugin style**, **non-invasive** solution and is currently available on iOS, macOS and Android.

# <a name='matrix_ios_en'> Matrix for iOS/macOS </a>

The monitoring scope of the current tool includes: crash, lag, and out-of-memory, which includes the following two plugins:
The monitoring scope of the current tool includes: crash, lag, and memory, which includes the following three plugins:

* **WCCrashBlockMonitorPlugin:** Based on [KSCrash](https://github.com/kstenerud/KSCrash) framework, it features cutting-edge lag stack capture capabilities with crash capture.

* **WCMemoryStatPlugin:** A performance-optimized out-of-memory monitoring tool that captures memory allocation and the callstack of an application's out-of-memory event.
* **WCMemoryStatPlugin:** A memory monitoring tool that captures memory allocation and the callstack of an application's memory event.

* **WCFPSMonitorPlugin:** A fps monitoring tool that captures main thread's callstack while user scrolling.

## Features

Expand All @@ -32,18 +34,10 @@ The monitoring scope of the current tool includes: crash, lag, and out-of-memory
#### WCMemoryStatPlugin

* Live recording every object's creating and the corresponding callstack of its creation, and report it when the application out-of-memory is detected.
* Use a balanced binary tree to store living objects and a hash table to store the callstack to optimize performance to the extreme

## Getting Started
#### Install

* **Install via Cocoapods**
1. Install [CocoaPods](https://guides.cocoapods.org/using/getting-started.html);
2. Run `pod repo update` to make CocoaPods aware of the latest available `matrix` versions;
3. In your Podfile, add `pod 'matrix-wechat'` to your app target, from the command line, run `pod install`;
4. Use the .xcworkspace file generated by CocoaPods to work on your project;
5. Add `#import <Matrix/Matrix.h>` , then you can use the performance probe tool of WeChat.

* **Install with static framework**
1. Get source code of Matrix;
2. Open terminal, execute `make` in the `matrix/matrix-iOS` directory to compile and generate static library. After compiling, the iOS platform library is in the `matrix/matrix-iOS/build_ios` directory, and the macOS platform library is in the `matrix/matrix-iOS/build_macos` directory.
Expand Down Expand Up @@ -73,15 +67,16 @@ WCCrashBlockMonitorPlugin *crashBlockPlugin = [[WCCrashBlockMonitorPlugin alloc]
[curBuilder addPlugin:crashBlockPlugin]; // add lag and crash monitor.

WCMemoryStatPlugin *memoryStatPlugin = [[WCMemoryStatPlugin alloc] init];
[curBuilder addPlugin:memoryStatPlugin]; // add out-of-memory monitor.
[curBuilder addPlugin:memoryStatPlugin]; // add memory monitor.

WCFPSMonitorPlugin *fpsMonitorPlugin = [[WCFPSMonitorPlugin alloc] init];
[curBuilder addPlugin:fpsMonitorPlugin]; // add fps monitor.

[matrix addMatrixBuilder:curBuilder];

[crashBlockPlugin start]; // start the lag and crash monitor.
// [memoryStatPlugin start];
// start out-of-memory monitor
// Be careful, WCMemoryStatPlugin has a large performance loss after it is turned on. It is recommended to turn it on as needed.

[memoryStatPlugin start]; // start memory monitor
[fpsMonitorPlugin start]; // start fps monitor
```
#### Receive callbacks to obtain monitoring data
Expand Down Expand Up @@ -109,7 +104,7 @@ Each plugin added to `MatrixBuilder` will call back the corresponding event via

## Tutorials

At this point, Matrix has been integrated into the app and is beginning to collect crash, lag, and out-of-memory data. If you still have questions, check out the example: `samples/sample-apple/MatrixDemo`.
At this point, Matrix has been integrated into the app and is beginning to collect crash, lag, and memory data. If you still have questions, check out the example: `samples/sample-iOS/MatrixDemo`.



Expand Down Expand Up @@ -439,11 +434,13 @@ Matrix 通过接入各种性能监控方案,对性能监控项的异常数据
# <a name='matrix_ios_cn'>Matrix for iOS/macOS </a>
当前工具监控范围包括:崩溃、卡顿和爆内存,包含以下两款插件
Matrix-iOS 当前工具监控范围包括:崩溃、卡顿和内存,包含以下三款插件
* **WCCrashBlockMonitorPlugin:** 基于 [KSCrash](https://github.com/kstenerud/KSCrash) 框架开发,具有业界领先的卡顿堆栈捕获能力,同时兼备崩溃捕获能力
* **WCCrashBlockMonitorPlugin:** 基于 [KSCrash](https://github.com/kstenerud/KSCrash) 框架开发,具有业界领先的卡顿堆栈捕获能力,同时兼备崩溃捕获能力
* **WCMemoryStatPlugin:** 一款性能优化到极致的爆内存监控工具,能够全面捕获应用爆内存时的内存分配以及调用堆栈情况。
* **WCMemoryStatPlugin:** 一款性能极致的内存监控工具,能够全面捕获应用 OOM 时的内存分配以及调用堆栈情况
* **WCFPSMonitorPlugin:** 一款 FPS 监控工具,当用户滑动界面时,记录主线程调用栈
## 特性
Expand All @@ -455,18 +452,11 @@ Matrix 通过接入各种性能监控方案,对性能监控项的异常数据
#### WCMemoryStatPlugin
* 在应用运行期间获取对象存活以及相应的堆栈信息,在检测到应用爆内存时进行上报
* 使用平衡二叉树存储存活对象,使用 Hash Table 存储堆栈,将性能优化到极致
* 在应用运行期间获取对象存活以及相应的堆栈信息,在检测到应用 OOM 时进行上报
## 使用方法
#### 安装
* **通过 Cocoapods 安装**
1. 先安装 [CocoaPods](https://guides.cocoapods.org/using/getting-started.html);
2. 通过 pod repo update 更新 matrix 的 Cocoapods 版本;
3. 在 Podfile 对应的 target 中,添加 pod 'matrix-wechat',并执行 pod install;
4. 在项目中使用 Cocoapods 生成的 .xcworkspace运行工程;
5. 在你的代码文件头引入头文件 #import <Matrix/Matrix.h>,就可以接入微信的性能探针工具了!
* **通过静态库安装**
1. 获取 Matrix 源码;
Expand Down Expand Up @@ -499,13 +489,15 @@ WCCrashBlockMonitorPlugin *crashBlockPlugin = [[WCCrashBlockMonitorPlugin alloc]
WCMemoryStatPlugin *memoryStatPlugin = [[WCMemoryStatPlugin alloc] init];
[curBuilder addPlugin:memoryStatPlugin]; // 添加内存监控功能
WCFPSMonitorPlugin *fpsMonitorPlugin = [[WCFPSMonitorPlugin alloc] init];
[curBuilder addPlugin:fpsMonitorPlugin]; // 添加 fps 监控功能
[matrix addMatrixBuilder:curBuilder];
[crashBlockPlugin start]; // 开启卡顿和崩溃监控
// [memoryStatPlugin start];
// 开启内存监控,注意 memoryStatPlugin 开启之后对性能损耗较大,建议按需开启
[memoryStatPlugin start]; // 开启内存监控
[fpsMonitorPlugin start]; // 开启 fps 监控
```

#### 接收回调获得监控数据
Expand Down Expand Up @@ -533,7 +525,7 @@ curBuilder.pluginListener = <一个遵循 MatrixPluginListenerDelegate 的对象

## Demo

至此,Matrix 已经集成到应用中并且开始收集崩溃、ANR、卡顿和爆内存数据,如仍有疑问,请查看示例:`samples/sample-apple/MatrixDemo`
至此,Matrix 已经集成到应用中并且开始收集崩溃、卡顿和爆内存数据,如仍有疑问,请查看示例:`samples/sample-iOS/MatrixDemo`


# <a name='matrix_android_cn'>Matrix for Android </a>
Expand Down
Loading

0 comments on commit 6144583

Please sign in to comment.