我们的Message Queue里面有:D/ValueAnimator( 2356): animationHandler.sendEmptyMessage(ANIMATION_START),currenttime is 1692638
D/sendmessage,( 2356): Handler (android.animation.ValueAnimator$AnimationHandler) {4146d948} @ 1692639
D/sendmessage,( 2356): Looper{41433de0}
D/sendmessage,( 2356): mRun=true
D/sendmessage( 2356): mThread=Thread[main,5,main]
D/sendmessage,( 2356): mQueue=android.os.MessageQueue@41433e00
D/sendmessage,( 2356): Message 0: { what=1000 when=-7ms }
D/sendmessage,( 2356): Message 1: { what=0 when=-7ms }
D/sendmessage,( 2356): (Total messages: 2)
D/sendmessage,( 2356): Handler (android.animation.ValueAnimator$AnimationHandler) {4146d948} @ 1692639
D/sendmessage,( 2356): Looper{41433de0}
D/sendmessage,( 2356): mRun=true
D/sendmessage( 2356): mThread=Thread[main,5,main]
D/sendmessage,( 2356): mQueue=android.os.MessageQueue@41433e00
D/sendmessage,( 2356): Message 0: { what=1000 when=-7ms }
D/sendmessage,( 2356): Message 1: { what=0 when=-7ms }
D/sendmessage,( 2356): (Total messages: 2)
Message what=1000
,这个消息,就算我们不发消息,这些消息都存在。
这个消息据说是重画UI界面时的消息,正常都是有的
13:31M哥
handleMessage 要收的是 what=1000 這種訊息 ?
13:31小梓
但是这个消息处理的慢的话,就会把我们发的what=0的消息阻塞
我有试着把what=0的先处理,就不会fail,但是会有别的fail产生
13:52小梓
D/ValueAnimator( 2403): animationHandler.sendEmptyMessage(ANIMATION_START),currenttime is 213237
D/sendmessage( 2403): Handler (android.animation.ValueAnimator$AnimationHandler) {41450698} @ 213239
D/sendmessage( 2403): Looper{41417980}
D/sendmessage( 2403): mRun=true
D/sendmessage( 2403): mThread=Thread[main,5,main]
D/sendmessage( 2403): mQueue=android.os.MessageQueue@414179a0
D/sendmessage( 2403): Message 0: { what=1000 when=-21ms }
D/sendmessage( 2403): Message 1: { what=0 when=-20ms }
D/sendmessage( 2403): Message 2: { what=0 when=-4ms }
D/sendmessage( 2403): (Total messages: 3)
I/ActivityManager( 1339): Displayed com.android.cts.animation/android.animation.cts.AnimationActivity: +280ms
D/OpenGLRenderer( 1846): Flushing caches (mode 0)
D/ValueAnimator( 2403): handleMessage:ANIMATION_START 213323
D/sendmessage( 2403): Handler (android.animation.ValueAnimator$AnimationHandler) {41450698} @ 213239
D/sendmessage( 2403): Looper{41417980}
D/sendmessage( 2403): mRun=true
D/sendmessage( 2403): mThread=Thread[main,5,main]
D/sendmessage( 2403): mQueue=android.os.MessageQueue@414179a0
D/sendmessage( 2403): Message 0: { what=1000 when=-21ms }
D/sendmessage( 2403): Message 1: { what=0 when=-20ms }
D/sendmessage( 2403): Message 2: { what=0 when=-4ms }
D/sendmessage( 2403): (Total messages: 3)
I/ActivityManager( 1339): Displayed com.android.cts.animation/android.animation.cts.AnimationActivity: +280ms
D/OpenGLRenderer( 1846): Flushing caches (mode 0)
D/ValueAnimator( 2403): handleMessage:ANIMATION_START 213323
13:55小梓
单独跑一次函数的时候,也会有what=1000
13:56M哥
確定單次跑 what=1000 也有出現 ?
13:56小梓
是的
13:56M哥
嗯....結果 pass 了
?
13:57小梓
是
13:57M哥
嗯.. 原因就是差在 what=1000 處理的快慢 ?
13:57小梓
我觉得是
14:03M哥
先查一下哪種測法是慢在哪
what=1000 是哪個 module 變慢了
15:17小梓
ok时100ms时间分配:sendEmptyMessage(ANIMATION_START),currenttime is 213237
D/ValueAnimator( 2403): handleMessage:ANIMATION_START 213323
animationFrame come in come in --------mPlayingState == STOPPED 213328
send--handle:323-237=86ms,handle开始到真正改变状态时间为:328-323=5ms,总共为91ms
所以就是sendMessage和handleMessage之间太慢了
15:27M哥
嗯... 但是 send message & handle message 中間的過程是什麼?
15:40小梓
sendMessage 会send到一个messageQueue里面
framework/base/core/jni/android_os_messageQueue.cpp
去处理message,一般是来一个处理一个,触发相应的handler去处理
message=1000,是在ViewRootImpl.java中的DO_TRAVERSAL消息,有PerformTraverals()函数处理
这个函数会遍历一颗类似树的层次的各个view,调用各个view的onDraw函数,然后把UI界面画出来
所以,这个时间就是很长。。。