ani icon indicating copy to clipboard operation
ani copied to clipboard

研究 APP 启动时间

Open Him188 opened this issue 1 year ago • 1 comments

之前有收到一些反馈说启动时间变慢了, 这是因为必须在启动时读取配置文件来决定显示什么主题

需要 profile 一下看看启动时是不是有初始化不必要的 class 等

AS profile Android 比较简单, 它的 profiler 应该有专门针对启动速度场景的功能

Him188 avatar Sep 17 '24 08:09 Him188

我们需要知道启动时间占比, 主要花在哪

PC 和安卓的应用代码是一样的, 但底层不一样, 也值的看一看

Him188 avatar Sep 17 '24 08:09 Him188

看起来很好. 骁龙8Elite 上, Kotlin 部分只花了 80ms 左右时间. Compose measure 和安卓系统 native 部分占了不少时间.

最大的问题是 me.him188.ani.android.AndroidModulesKt#getAndroidModules 里面有个 runBlocking 读配置会导致启动被阻塞 35ms 读文件, 把它放后台就没问题了

值得一提的是, AniAppContentImpltypeOf (Kotlin 反射) 也占了可以被观测到的时间. 但这个可能没办法...

Him188 avatar Jan 01 '25 15:01 Him188