【发布时间】:2022-11-10 00:56:19
【问题描述】:
我正在尝试实施基线资料(official documentation) 为我的应用程序。如果我使用DebugBuildVariant我能够创建基线-prof.txt文件以提高启动时间。但是当我尝试为发布创建baseline-prof文件时,我遇到了这个异常:
./gradlew :macrobenchmark:pixel2Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.class=com.example.BaselineProfileGenerator
com.example.BaselineProfileGenerator > generate[pixel2Api31] FAILED
java.lang.IllegalStateException: Unable to confirm activity launch completion [] Please report a bug with the output of `adb shell dumpsys gfxinfo com.leinardi.forlago framestats`
at androidx.benchmark.macro.MacrobenchmarkScope.startActivityImpl(MacrobenchmarkScope.kt:179)
Tests on pixel2Api31 failed: There was 1 failure(s).
这就是我们的样子基线轮廓生成器:
@OptIn(ExperimentalBaselineProfilesApi::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class BaselineProfileGenerator {
@get:Rule
val rule = BaselineProfileRule()
@Test
fun generate() {
rule.collectBaselineProfile("com.leinardi.forlago") {
pressHome()
startActivityAndWait()
}
}
}
如果我将基准配置为调试它运作良好:
benchmark {
initWith buildTypes.debug
signingConfig signingConfigs.debug
matchingFallbacks = ['debug']
debuggable false
proguardFiles('benchmark-rules.pro')
}
但是将其配置为发布, 当您尝试生成它时,基准测试会引发上一个异常。
benchmark {
initWith buildTypes.release
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
debuggable false
proguardFiles('benchmark-rules.pro')
}
使用的组件:基线配置文件
使用的版本:AGP=7.3.0-rc01, uiautomator=2.2.0 & benchmark-macro-junit4=1.1.0
设备/Android 版本转载于:
testOptions {
managedDevices {
devices {
pixel2Api31(com.android.build.api.dsl.ManagedVirtualDevice) {
device = "Pixel 2"
apiLevel = 31
systemImageSource = "aosp"
}
}
}
}
在 Google 问题跟踪器上报告:issue
触发问题的示例项目:https://github.com/leinardi/Forlago/tree/baseline-profiles
【问题讨论】:
标签: android performance baseline-profile