现象 点击桌面icon后2s才打开首页
trace
问题 1. 怎么确定首帧展示时间 onResume?(这是只是window添加时间非首帧展示时间)
确认uc浏览器首页Window com.UCMobile/com.uc.browser.InnerUCMobile
总览图
方式一
怎么确认5是首帧的绘制,startingWindow算不算首帧?
1 launcher 点击
2,3,4都是在ActivityThread中执行,首帧有没有可能不通过RenderThread合成,就可能在doFrame前进行合成
renderThread启动, AttachCurrentThread 初始化JNIenv ,建立native java通讯
方式二
过滤wm_日志
03-07 16:19:40.172 1000 1874 6684 I wm_create_activity: [0,192420576,20,com.UCMobile/com.uc.browser.InnerUCMobile,NULL,NULL,NULL,268435456]
03-07 16:19:40.176 1000 1874 6684 I wm_pause_activity: [0,94051834,com.UCMobile/.main.UCMobile,userLeaving=true,resumeTopActivity]
03-07 16:19:40.191 1000 1874 6684 I wm_finish_activity: [0,94051834,20,com.UCMobile/.main.UCMobile,app-request]
03-07 16:19:40.194 10245 13316 13316 I wm_on_create_called: [0,94051834,com.UCMobile.main.UCMobile,performCreate,171]
03-07 16:19:40.266 1000 1874 3389 I wm_add_to_stopping: [0,94051834,com.UCMobile/.main.UCMobile,completeFinishing]
03-07 16:19:40.269 1000 1874 3389 I wm_add_to_stopping: [0,36426290,com.miui.home/.launcher.Launcher,makeInvisible]
03-07 16:19:40.273 1000 1874 3389 I wm_restart_activity: [0,192420576,20,com.UCMobile/com.uc.browser.InnerUCMobile]
03-07 16:19:40.276 1000 1874 3389 I wm_set_resumed_activity: [0,com.UCMobile/com.uc.browser.InnerUCMobile,minimalResumeActivityLocked - onActivityStateChanged]
03-07 16:19:40.283 1000 1874 1988 I wm_destroy_activity: [0,94051834,20,com.UCMobile/.main.UCMobile,finish-imm:idle]
03-07 16:19:40.305 1000 1874 3389 I wm_requested_orientation: [1,com.UCMobile]
03-07 16:19:40.373 10245 13316 13316 I wm_on_create_called: [0,192420576,com.uc.browser.InnerUCMobile,performCreate,79]
03-07 16:19:40.398 10245 13316 13316 I wm_on_start_called: [0,192420576,com.uc.browser.InnerUCMobile,handleStartActivity,18]
03-07 16:19:40.414 10245 13316 13316 I wm_on_resume_called: [0,192420576,com.uc.browser.InnerUCMobile,RESUME_ACTIVITY,14]
03-07 16:19:40.502 10245 13316 13316 I wm_on_top_resumed_gained_called: [192420576,com.uc.browser.InnerUCMobile,topStateChangedWhenResumed]
03-07 16:19:40.508 10245 13316 13316 I wm_on_destroy_called: [0,94051834,com.UCMobile.main.UCMobile,performDestroy,6]
03-07 16:19:40.663 1000 1874 1985 I wm_activity_launch_time: [0,192420576,com.UCMobile/com.uc.browser.InnerUCMobile,1042]
wm_activity_launch_time 看到了一个时间,怎么确定这个时间是首页展示的时间。
int calculateDelay(long timestampNs) {
// Shouldn't take more than 25 days to launch an app, so int is fine here.return (int) TimeUnit.NANOSECONDS.toMillis(timestampNs - mTransitionStartTimeNs);
}
//mTransitionStartTimeNs 在activitystarter.startResolvedActivity中赋值,即点击桌面图标的时候 (表示图标动画开启)?
//这里可以确定
在notifyWindowDrawn->done中的trace,可以侧面印证在 5:doFrame中绘制的UC首帧, 并且跟evets[ wm_activity_launch_time]统计的时间只差6ms
方式三
参考文档:
1. https://developer.android.com/topic/performance/vitals/launch-time?hl=zh-cn