cleanup: ComposeTrace 仅在 debug 构建中启用

- core/build.gradle.kts: 启用 buildConfig 生成
- ComposeTrace: 添加 BuildConfig.DEBUG 条件,release 构建中空操作
  避免 R8 full mode 下 Trace 调用的生产环境开销

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-25 15:15:29 +08:00
parent dead12fdf4
commit e934d33cfa
2 changed files with 5 additions and 1 deletions

View File

@ -16,6 +16,7 @@ android {
buildFeatures {
compose = true
buildConfig = true
}
compileOptions {

View File

@ -1,12 +1,14 @@
package plus.rua.project
import android.os.Trace
import plus.rua.project.shared.BuildConfig
/**
* Systrace 包装用于录制 Compose 性能 trace
* Android 实际调用 android.os.Trace
* 仅在 debug 构建中启用release 构建中为空操作
*/
fun composeTraceBeginSection(name: String) {
if (!BuildConfig.DEBUG) return
try {
Trace.beginSection(name)
} catch (_: RuntimeException) {
@ -15,6 +17,7 @@ fun composeTraceBeginSection(name: String) {
}
fun composeTraceEndSection() {
if (!BuildConfig.DEBUG) return
try {
Trace.endSection()
} catch (_: RuntimeException) {