Matrix is a plugin style, non-invasive APM system developed by WeChat.
Matrix is a plugin style, non-invasive APM system developed by WeChat.
(中文版本请参看这里)
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.
Increase `DYLD_IMAGE_MACOUNT`
升级targetsdk37后,messagequeue行为变更,anr监听中,通过mMessage监听卡顿的方案失效,有替代方案吗?
如何判断OOM发生
iOS的out-of-memory日志如何翻译成堆栈信息
适配 Android 16KB 页面大小
android 16k page size support
gradle8.0以上无法使用本插件
最新AndroidStudio如何gradle如何配置matrix啊?
AGP 8.x+环境下出现的编译问题
请问,Matrix后续还会更新吗?集成的KSCrash1.15.19,但是KSCrash最新版本是2.4.0