Android.animation cts fail(2)

博客分析了Android.animation cts测试中遇到的问题,主要集中在消息队列中其他消息导致的延迟和animationFrame()函数的性能。对于testCurrentPlayTime,发现消息从发送到处理存在66ms的延迟,而testSetCurrentPlayTime中animationFrame()的执行时间超过1ms导致失败。博主寻求解决方案,特别是关于如何避免消息队列阻塞和优化animationFrame()的方法。
摘要由CSDN通过智能技术生成

接上篇Android.animation cts fail

1.针对第二项testCurrentPlayTime:耗时是在sendMessage和handleMessage之间,

我在sendMessage后面加了如下的log,打印出当前的消息队列中有哪些消息:

Log.d(TAG, "animationHandler.sendEmptyMessage(ANIMATION_START),currenttime is"+AnimationUtils.currentAnimationTimeMillis());

       animationHandler.sendEmptyMessage(ANIMATION_START);

                 animationHandler.dump(newPrinter() {

                                                     @Override

                                            publicvoid println(String x) {

                                                  Log.d("sendmessage",x);

                                               }

                                           },"");

                          }

发现有别的消息阻塞在那里,导致我们的超时,log如下:

D/ValueAnimator( 2353):  animationHandler.sendEmptyMessage(ANIMATION_START),currenttimeis 441442

D/sendmessage( 2353): Handler(android.animation.ValueAnimator$AnimationHandler) {41470bf0} @ 441444

D/sendmessage( 2353):   Looper{41436d40}

D/sendmessage( 2353):   mRun=true

D/sendmessage( 2353):  mThread=Thread[main,5,main]

D/sendmessage( 2353):   mQueue=android.os.MessageQueue@41436d60

D/sendmessage( 2353):     Message 0:{ what=1000 when=-19ms }

D/sendmessage( 2353):     Message 1:{ what=0 when=-19ms }

D/sendmessage( 2353):     Message 2:{ what=0 when=-5ms }

D/sendmessage( 2353):   (Total messages: 3)

I/ActivityManager( 1327): Displayedcom.android.cts.animation/android.animation.cts.AnimationActivity: +311ms

D/OpenGLRenderer( 1827): Flushing caches (mode 0)

D/ValueAnimator( 2353): handleMessage:ANIMATION_START 441510

 

log中可以看出发送消息到Handler处理中间只有2ms,但是到处理handleMessage:ANIMATION_START却是441510-441444=66ms

问题是:怎么能够不让消息队列里的别的消息阻塞我们的时间呢??

   2.  针对第三项testSetCurrentPlayTime

setCurrentPlayTime()函数中的animationFrame()消耗了时间,调用这个函数用了超过1ms,所以导致fail

 

 

D/ValueAnimator( 2356): setCurrentPlayTime!!!currentTime is460959

D/ValueAnimator( 2356): beforeanimationFrame-----------mStartTime is 450959currentTime is 460959

D/ValueAnimator( 2356): animationFrame come in come in----------- 460959

D/ValueAnimator( 2356): fraction is is is  33.333332mStartTime=450959 currentTime=460959

D/ValueAnimator( 2356): start call animateValue

D/ValueAnimator( 2356): animateValue come in come in come in

D/ValueAnimator( 2356): afteranimationFrame-----------currentTime is 460960


问题是:如何改进animationFrame()呢?JB中去掉了这个测试用例,不知道是不是因为测试用例本身写的不对,而animationFrame()不好改进呢?


期待高手解答!!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值