现状:apk热启动比对比机差
经过高速相机拍摄的图片发现apk启动的动画不一致。
有两种优化方向:
1修改动画的显示方式-暂时没有跟进
2.修改动画的速度,但是涉及到所有动画,感觉有风险比较大。
今天咨询了framework的同事,修改了Activity_open的动画
分析如下:
Hot start analysis:
From systrace:
1.dailer warm start:from deliverInputEvent to second doFrame 306ms
2.Launcher from deliverInputEvent to animator finish :507(animator 443ms)
So dailer warm start is about 507ms
Cold start analysis:
1.dailer cold start:from deliverInputEvent to second doFrame 815ms
2.Launcher from deliverInputEvent to animator finish :557ms(animator 434ms)
So dailer cold start is about 815ms
apk hot start | 306ms | ||||
Launcher Animation | 507ms | ||||
apk cold start | 815ms | ||||
apk hot start < Launcher Animation < apk cold start |
summary:
The animation and apk launch are parallel.
apk hot start. The hot start is completed and the animation is not yet completed. After the animation is completed, the hot start stops timing, so the time of the hot start is affected by the animation time.
apk cold start. The animation is complete and the cold start is not yet complete. After the cold start is completed, the cold start stops timing, so the cold start is not affected by the animation.
以上是某项目的分析,可以看到受到Launcher的动画影响,apk的热启动变慢了。
修改文件:Activity_open_enter.xml Activity_open_exit.xml 这两个文件是Launcher的apk启动的动画。修改duration=400.修改为200
从systrace看到动画的时间从430ms变为350ms,不同的apk优化的时间不同。
增加一种修改方法,在Launcher中直接修改动画参数:
packages/apps/Launcher3/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
private void composeIconLaunchAnimator(…)
anim.play(windowAnimator);
此动画可以客制化时间:
例如:
private static final long APP_LAUNCH_DURATION = 500;