Matrix是一种由WeChat所开发的插件样式,非入侵APM系统.
(中文版本请参看这里)
Matrix for iOS/macOS 中文版
Matrix for android 中文版
Matrix for iOS/macOS
Matrix for android
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.
The monitoring scope of the current tool includes: crash, lag, and memory, which includes the following three plugins:
WCCrashBlockMonitorPlugin: Based on KSCrash framework, it features cutting-edge lag stack capture capabilities with crash capture.
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.
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.Matrix.framework under the matrix/matrix-iOS/build_ios path, link Matrix.framework to the project as a static library;Matrix.framework under the matrix/matrix-iOS/build_macos path, link Matrix.framework to the project as a static library.#import <Matrix/Matrix.h>, then you can use the performance probe tool of WeChat.In the following places:
main function;application:didFinishLaunchingWithOptions: of AppDelegate;Add a code similar to the following to start the plugin:
…Set pluginListener of the MatrixBuilder object, implement the MatrixPluginListenerDelegate
// set delegate
MatrixBuilder *curBuilder = [[MatrixBuilder alloc] init];
curBuilder.pluginListener = <object conforms to MatrixPluginListenerDelegate>;
// MatrixPluginListenerDelegate
- (void)onInit:(id<MatrixPluginProtocol>)plugin;
- (void)onStart:(id<MatrixPluginProtocol>)plugin;
- (void)onStop:(id<MatrixPluginProtocol>)plugin;
- (void)onDestroy:(id<MatrixPluginProtocol>)plugin;
- (void)onReportIssue:(MatrixIssue *)issue;Each plugin added to MatrixBuilder will call back the corresponding event via pluginListener.
Important: Get the monitoring data of the Matrix via onReportIssue:, the data format info reference to Matrix for iOS/macOS Data Format Description
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.
APK Checker:
Analyse the APK package, give suggestions of reducing the APK's size; Compare two APK and find out the most significant increment on size
Resource Canary:
Detect the activity leak and bitmap duplication basing on WeakReference and Square Haha
Trace Canary:
FPS Monitor, Startup Performance, ANR, UI-Block / Slow Method Detection
SQLite Lint:
Evaluate the quality of SQLite statement automatically by using SQLite official tools
IO Canary:
Detect the file IO issues, including performance of file IO and closeable leak
Battery Canary:
App thread activities monitor (Background watch & foreground loop watch), Sonsor usage monitor (WakeLock/Alarm/Gps/Wifi/Bluetooth), Background network activities (Wifi/Mobile) monitor.
MemGuard
Detect heap memory overlap, use-after-free and double free issues.
A tool base on GWP-Asan to detect heap memory issues.
Non-invasive. It is based on PLT-hook(iqiyi/xHook), so we do NOT need to recompile the native libraries.
It's able to apply on specific libraries that needs to be detected by RegEx.
It detects heap memory accessing overlap, use-after-free and double free issues.
The JCenter repository will stop service on February 1, 2022. So we uploaded Matrix(since 0.8.0) to the MavenCentral repository.
MATRIX_VERSION in gradle.properties. MATRIX_VERSION=2.1.0matrix-gradle-plugin in your build.gradle: dependencies {
classpath ("com.tencent.matrix:matrix-gradle-plugin:${MATRIX_VERSION}") { changing = true }
}
…PluginListener to receive data processed by Matrix. public class TestPluginListener extends DefaultPluginListener {
public static final String TAG = "Matrix.TestPluginListener";
public TestPluginListener(Context context) {
super(context);
}
@Override
public void onReportIssue(Issue issue) {
super.onReportIssue(issue);
MatrixLog.e(TAG, issue.toString());
//add your code to process data
}
}Matrix gradle plugin could work with Android Gradle Plugin 3.5.0/4.0.0/4.1.0 currently.
DynamicConfig to change parameters of Matrix.…onCreate of your application.…For more Matrix configurations, look at the sample.
Note:
Init BatteryCanary as the following codes:
BatteryMonitorConfig config = new BatteryMonitorConfig.Builder()
.enable(JiffiesMonitorFeature.class)
.enableStatPidProc(true)
.greyJiffiesTime(30 * 1000L)
.setCallback(new BatteryMonitorCallback.BatteryPrinter())
.build();
BatteryMonitorPlugin plugin = new BatteryMonitorPlugin(config);For detail usage, please reference showcase tests at com.tencent.matrix.batterycanary.ApisTest or sample.tencent.matrix.battery.BatteryCanaryInitHelper.
How to init backtrace component:
WeChatBacktrace.instance().configure(getApplicationContext()).commit();Then other components in Matrix could use Quikcen Backtrace to unwind stacktrace. See more configuration comments in 'WeChatBacktrace.Configuration'.
APK Checker can run independently in Jar (matrix-apk-canary-2.1.0.jar) mode, usage:
…Learn more about Matrix-APKChecker
Any problem?
If you are interested in contributing, check out the CONTRIBUTING.md, also join our [Tencent OpenSource Plan](https://opensource.
增加 `DYLD_IMAGE_MACOUNT`
升级 targetSdk37 后,messagequeue 行为发生变化,anr 监听中,通过 mMessage 监听卡顿的方案失效,有替代方案吗?
如何判断 OOM 是否发生
iOS 的内存耗尽日志如何转换为堆栈信息
适配 Android 16KB 页面大小
支持 android 16k 页面大小
在 gradle 8.0 及以上版本中无法使用此插件
最新的AndroidStudio如何gradle如何配置matrix?
在 AGP 8.x+ 环境中出现的编译问题
请问, Matrix 后续是否会更新? 目前集成的 KSCrash 版本是 1.15.19, 但 KSCrash 最新版本是 2.4.0。