[3.2.0][opt]集成Matrix的TraceCanary模块
This commit is contained in:
@@ -71,6 +71,19 @@ if (!isAndroidTestBuild()) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isReleaseBuild) {
|
||||
apply plugin: 'bytex.matrix'
|
||||
|
||||
matrix {
|
||||
trace {
|
||||
enable = true //if you don't want to use trace canary, set false
|
||||
baseMethodMapFile = "${project.buildDir}/matrix_output/customMethodMapping.txt"
|
||||
blackListFile = "${project.projectDir}/matrixTrace/blackMethodList.txt"
|
||||
}
|
||||
logLevel = "D"
|
||||
}
|
||||
}
|
||||
|
||||
//if (!isAndroidTestBuild()) {
|
||||
// /**
|
||||
// * 方便使用systrace工具,在工程侧打点,便于分析工程侧性能问题
|
||||
@@ -153,6 +166,7 @@ android {
|
||||
exclude 'META-INF/proguard/coroutines.pro'
|
||||
exclude 'META-INF/*'
|
||||
exclude "/lib/armeabi-v7a/*.so"
|
||||
pickFirst 'lib/arm64-v8a/libc++_shared.so'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -198,8 +212,8 @@ android {
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility 1.8
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
|
||||
16
app/matrixTrace/blackMethodList.txt
Normal file
16
app/matrixTrace/blackMethodList.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
-keeppackage com/mogo/thread/ext/
|
||||
-keeppackage com/mogo/launcher
|
||||
-keeppackage com/rousetime/android_startup/
|
||||
-keeppackage com/mogo/systrace/
|
||||
-keeppackage com/bytedance/boost_multidex/
|
||||
-keeppackage io/netty/
|
||||
-keeppackage com/elegant/log/
|
||||
-keeppackage org/slf4j/
|
||||
-keeppackage kotlin/
|
||||
-keepclass com.mogo.eagle.core.function.main.MainMoGoApplication
|
||||
-keepclass com.mogo.commons.AbsMogoApplication
|
||||
-keepclass com.bytedance.apm.agent.v2.instrumentation.AppAgent
|
||||
-keepclass androidx.core.app.CoreComponentFactory
|
||||
-keepclass com.mogo.eagle.core.utilcode.util.ProcessUtils
|
||||
-keepclass com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils
|
||||
@@ -36,8 +36,7 @@ buildscript {
|
||||
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
|
||||
classpath 'com.mogo.sticky:service:1.0.8'
|
||||
classpath 'io.github.knight-zxw:lancet-plugin:0.0.4.8_mogo'
|
||||
|
||||
// classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true }
|
||||
classpath 'com.mogo.cloud:matrix:1.0.0'
|
||||
}
|
||||
// 遇无法更新依赖情况(针对Snapshot无法刷新)然后sync project即可,刷新完成注释该代码
|
||||
// configurations.all {
|
||||
|
||||
@@ -90,6 +90,11 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidautoSize
|
||||
implementation rootProject.ext.dependencies.koomnative
|
||||
implementation rootProject.ext.dependencies.koomxhook
|
||||
implementation group: "com.tencent.matrix", name: "matrix-android-lib", version: MATRIX_VERSION, changing: true
|
||||
implementation group: "com.tencent.matrix", name: "matrix-android-commons", version: MATRIX_VERSION, changing: true
|
||||
implementation group: "com.tencent.matrix", name: "matrix-trace-canary", version: MATRIX_VERSION, changing: true
|
||||
implementation group: "com.tencent.matrix", name: "matrix-io-canary", version: MATRIX_VERSION, changing: true
|
||||
implementation group: "com.tencent.matrix", name: "matrix-hooks", version: MATRIX_VERSION, changing: true
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
|
||||
@@ -8,8 +8,9 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.EnvConfig
|
||||
import com.mogo.eagle.core.data.deva.bindingcar.ModifyBindingcarInfo
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.data.deva.bindingcar.ModifyBindingcarInfo
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainLogParam
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneModule
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneTAG
|
||||
@@ -19,6 +20,16 @@ import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.devatools.strict.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.tencent.matrix.Matrix
|
||||
import com.tencent.matrix.iocanary.IOCanaryPlugin
|
||||
import com.tencent.matrix.iocanary.config.IOConfig
|
||||
import com.tencent.matrix.plugin.Plugin
|
||||
import com.tencent.matrix.plugin.PluginListener
|
||||
import com.tencent.matrix.report.Issue
|
||||
import com.tencent.matrix.trace.TracePlugin
|
||||
import com.tencent.matrix.trace.config.SharePluginInfo
|
||||
import com.tencent.matrix.trace.config.TraceConfig
|
||||
import com.zhjt.mogo_core_function_devatools.apm.*
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
@@ -28,11 +39,11 @@ import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigCenter.Compani
|
||||
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigImpl
|
||||
import com.zhjt.mogo_core_function_devatools.koom.KoomInitTask
|
||||
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchManager
|
||||
import com.zhjt.mogo_core_function_devatools.matrix.DynamicConfigImpl
|
||||
import com.zhjt.mogo_core_function_devatools.mofang.MoFangManager.Companion.moFangManager
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.MonitorManager
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb.Companion.getDb
|
||||
import com.zhjt.mogo_core_function_devatools.report.IPCReportManager
|
||||
import com.zhjt.mogo_core_function_devatools.report.IPCReportManager.Companion.iPCReportManager
|
||||
import com.zhjt.mogo_core_function_devatools.scene.SceneManager.Companion.sceneManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.StatusManager
|
||||
@@ -40,6 +51,8 @@ import com.zhjt.mogo_core_function_devatools.strict.*
|
||||
import com.zhjt.mogo_core_function_devatools.trace.TraceManager.Companion.traceManager
|
||||
import com.zhjt.mogo_core_function_devatools.tts.TtsManager.Companion.ttsManager
|
||||
import com.zhjt.mogo_core_function_devatools.upgrade.UpgradeManager.Companion.upgradeManager
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_DEVA_TOOLS)
|
||||
class DevaToolsProvider : IDevaToolsProvider {
|
||||
@@ -62,12 +75,13 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
}
|
||||
|
||||
override fun initBiz() {
|
||||
if (DebugConfig.isDebug()) {
|
||||
KoomInitTask.init(AbsMogoApplication.getApp())
|
||||
}
|
||||
ttsManager.initTts(mContext!!) //todo
|
||||
//链路相关
|
||||
traceManager.init(mContext!!)
|
||||
if (DebugConfig.isDebug()) {
|
||||
KoomInitTask.init(AbsMogoApplication.getApp())
|
||||
initMatrix()
|
||||
}
|
||||
ttsManager.initTts(mContext!!) //todo
|
||||
bizConfigCenter.init(mContext!!)
|
||||
FuncConfigImpl.init()
|
||||
MogoLogCatchManager.init(mContext!!)
|
||||
@@ -103,6 +117,74 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private fun initMatrix() {
|
||||
val builder: Matrix.Builder = Matrix.Builder(AbsMogoApplication.getApp())
|
||||
builder.pluginListener(object : PluginListener {
|
||||
override fun onInit(plugin: Plugin?) {
|
||||
}
|
||||
|
||||
override fun onStart(plugin: Plugin?) {
|
||||
}
|
||||
|
||||
override fun onStop(plugin: Plugin?) {
|
||||
}
|
||||
|
||||
override fun onDestroy(plugin: Plugin?) {
|
||||
}
|
||||
|
||||
override fun onReportIssue(issue: Issue?) {
|
||||
var isEvil = false
|
||||
issue?.apply {
|
||||
if (plugin is TracePlugin) {
|
||||
if (tag == SharePluginInfo.TAG_PLUGIN_EVIL_METHOD) {
|
||||
isEvil = true
|
||||
printEvilMsg(issue.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isEvil) {
|
||||
w("TraceCanary", issue?.toString())
|
||||
}
|
||||
}
|
||||
})
|
||||
val config: TraceConfig = TraceConfig.Builder()
|
||||
.enableFPS(true) // 帧率
|
||||
.enableEvilMethodTrace(true) // 慢方法
|
||||
.enableAnrTrace(true) // anr
|
||||
.enableStartup(true) // app启动
|
||||
.isDebug(true) // debug包
|
||||
.isDevEnv(true) // dev环境
|
||||
.build()
|
||||
|
||||
// Trace Canary插件
|
||||
val tracePlugin = TracePlugin(config)
|
||||
builder.plugin(tracePlugin)
|
||||
|
||||
val ioCanaryPlugin = IOCanaryPlugin(
|
||||
IOConfig.Builder()
|
||||
.dynamicConfig(DynamicConfigImpl())
|
||||
.build())
|
||||
|
||||
builder.plugin(ioCanaryPlugin)
|
||||
|
||||
Matrix.init(builder.build())
|
||||
// 开启Trace Canary
|
||||
tracePlugin.start()
|
||||
ioCanaryPlugin.start()
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_LINK_LOG_ANR,
|
||||
linkCode = ChainConstant.CHAIN_LINK_ANR,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_RECORD_ANR,
|
||||
paramIndexes = [0],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
private fun printEvilMsg(evilMethod: String) {
|
||||
w("TraceCanary", evilMethod)
|
||||
}
|
||||
|
||||
override fun startLogCatch() {
|
||||
MogoLogCatchManager.startCatchLog()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.zhjt.mogo_core_function_devatools.matrix
|
||||
|
||||
import com.tencent.mrs.plugin.IDynamicConfig
|
||||
|
||||
class DynamicConfigImpl: IDynamicConfig {
|
||||
|
||||
fun isFPSEnable(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun isTraceEnable(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun isMatrixEnable(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun isDumpHprof(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun get(key: String?, defStr: String?): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun get(key: String?, defInt: Int): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun get(key: String?, defLong: Long): Long {
|
||||
return 0L
|
||||
}
|
||||
|
||||
override fun get(key: String?, defBool: Boolean): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun get(key: String?, defFloat: Float): Float {
|
||||
return 0f
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,6 +67,8 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_PLANNING_ACTIONS)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_NATIVE_LEAK] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_RECORD_NATIVE_LEAK)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_ANR] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_RECORD_ANR)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_CLOUD_V2N] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_CLOUD_WEB_SOCKET_V2N)
|
||||
|
||||
@@ -91,6 +93,8 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
|
||||
ChainLogParam(true, "ADAS PLANNING 决策行为")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_NATIVE_LEAK] =
|
||||
ChainLogParam(true, "Native Leak Record")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_ANR] =
|
||||
ChainLogParam(true, "ANR Record")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_CLOUD_V2N] =
|
||||
ChainLogParam(true, "Cloud WebSocket V2N")
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ class ChainConstant {
|
||||
const val CHAIN_LINK_INIT = 2
|
||||
// Native内存泄漏
|
||||
const val CHAIN_LINK_LEAK = 10
|
||||
// ANR
|
||||
const val CHAIN_LINK_ANR = 11
|
||||
|
||||
const val CHAIN_LINK_LOG_CONNECT_STATUS = 0
|
||||
const val CHAIN_LINK_LOG_WEB_SOCKET_GNSSINFO = 1
|
||||
@@ -24,6 +26,7 @@ class ChainConstant {
|
||||
const val CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS = 8
|
||||
const val CHAIN_LINK_LOG_NATIVE_LEAK = 100
|
||||
const val CHAIN_LINK_LOG_CLOUD_V2N = 200
|
||||
const val CHAIN_LINK_LOG_ANR = 300
|
||||
|
||||
const val CHAIN_LINK_LOG_ADAS_INIT = "-eagleInitStatus"
|
||||
const val CHAIN_LINK_LOG_ADAS_GNSS = "-adasWsGnssInfo"
|
||||
@@ -36,6 +39,7 @@ class ChainConstant {
|
||||
const val CHAIN_LINK_LOG_ADAS_PLANNING_ACTIONS = "-adasWsPlanningActions"
|
||||
const val CHAIN_LINK_LOG_RECORD_NATIVE_LEAK = "-eagleRecordNativeLeak"
|
||||
const val CHAIN_LINK_LOG_CLOUD_WEB_SOCKET_V2N = "-eagleCloudWSV2N"
|
||||
const val CHAIN_LINK_LOG_RECORD_ANR = "-eagleRecordANR"
|
||||
|
||||
const val CHAIN_ALIAS_CODE_MULTI_CONNECT = "CHAIN_ALIAS_CODE_MULTI_CONNECT"
|
||||
const val CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_CONFIG = "CHAIN_ALIAS_CODE_CAR_CONFIG"
|
||||
@@ -55,6 +59,7 @@ class ChainConstant {
|
||||
const val CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_WARN = "PAD_ADAS_MESSAGE_AUTOPILOT_WARN"
|
||||
|
||||
const val CHAIN_ALIAS_CODE_RECORD_NATIVE_LEAK = "CHAIN_ALIAS_CODE_RECORD_NATIVE_LEAK"
|
||||
const val CHAIN_ALIAS_CODE_RECORD_ANR = "CHAIN_ALIAS_CODE_RECORD_ANR"
|
||||
|
||||
const val CHAIN_ALIAS_CODE_INIT_ENV_RESTART = "CHAIN_ALIAS_CODE_INIT_ENV_RESTART"
|
||||
const val CHAIN_ALIAS_CODE_APP_INFO_CONFIG_UPDATE = "CHAIN_ALIAS_CODE_APP_INFO_CONFIG_UPDATE"
|
||||
|
||||
@@ -146,6 +146,8 @@ ADAS_DATA_LIB_CHILD_VERSION=.0
|
||||
|
||||
# 线程优化版本
|
||||
THREAD_OPT_VERSION=4.0.1
|
||||
# matrix版本
|
||||
MATRIX_VERSION=2.0.8
|
||||
|
||||
# 测试模式司机端版本号
|
||||
NOOP_DRIVER_VERSION=3.1.0
|
||||
|
||||
Reference in New Issue
Block a user