yuyashuai / FrameAnimation

High-Performance Frame Animation Library For Android
Apache License 2.0
307 stars 45 forks source link

帧动画在有时候不会展示 #21

Closed ghost closed 5 years ago

ghost commented 5 years ago
simpleDraweeView.setFrameInterval(60);
simpleDraweeView.setScaleType(FrameAnimation.ScaleType.FIT_XY);

if(simpleDraweeView.isPlaying()) {
     simpleDraweeView.stopAnimation();
 }

simpleDraweeView.playAnimationFromAssets("gift_level_5");

当我一直尝试重复播放一段帧动画时,有很大概率曝出以下异常并且动画不显示。也就是以上一段代码。

java.lang.InterruptedException
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2034)
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2068)
     at java.util.concurrent.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:492)
     at java.util.concurrent.LinkedBlockingDeque.take(LinkedBlockingDeque.java:680)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.take(DefaultBitmapPool.kt:203)
     at com.yuyashuai.frameanimation.FrameAnimation$draw$1.invoke(FrameAnimation.kt:245)
     at com.yuyashuai.frameanimation.FrameAnimation$draw$1.invoke(FrameAnimation.kt:24)
     at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
 java.util.concurrent.RejectedExecutionException: Task com.yuyashuai.frameanimation.io.DefaultBitmapPool$decodeBitmap$$inlined$repeat$lambda$1@ea3110c rejected from java.util.concurrent.ThreadPoolExecutor@5e81a55[Shutting down, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:121)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
     at java.lang.Thread.run(Thread.java:764)
 java.util.concurrent.RejectedExecutionException: Task com.yuyashuai.frameanimation.io.DefaultBitmapPool$decodeBitmap$$inlined$repeat$lambda$1@2f631f8 rejected from java.util.concurrent.ThreadPoolExecutor@5e81a55[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:121)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
     at java.lang.Thread.run(Thread.java:764)
 java.util.concurrent.RejectedExecutionException: Task com.yuyashuai.frameanimation.io.DefaultBitmapPool$decodeBitmap$$inlined$repeat$lambda$1@7b0fec2 rejected from java.util.concurrent.ThreadPoolExecutor@5e81a55[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:121)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
     at java.lang.Thread.run(Thread.java:764)
 java.util.concurrent.RejectedExecutionException: Task com.yuyashuai.frameanimation.io.DefaultBitmapPool$decodeBitmap$$inlined$repeat$lambda$1@f794810 rejected from java.util.concurrent.ThreadPoolExecutor@5e81a55[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
     at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2078)
     at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:843)
     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1389)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:121)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
     at java.lang.Thread.run(Thread.java:764)
 java.lang.InterruptedException
     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1326)
     at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:150)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
     at java.lang.Thread.run(Thread.java:764)
 java.lang.InterruptedException
     at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1022)
     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1328)
     at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:150)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
     at java.lang.Thread.run(Thread.java:764)
 java.lang.InterruptedException
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2034)
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2068)
     at java.util.concurrent.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:492)
     at java.util.concurrent.LinkedBlockingDeque.take(LinkedBlockingDeque.java:680)
     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.take(DefaultBitmapPool.kt:203)
     at com.yuyashuai.frameanimation.FrameAnimation$draw$1.invoke(FrameAnimation.kt:245)
     at com.yuyashuai.frameanimation.FrameAnimation$draw$1.invoke(FrameAnimation.kt:24)
     at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
yuyashuai commented 5 years ago
implementation 'com.yuyashuai.frameanimation:frameanimation:2.0.2'

升级到2.0.2, 去掉下面的代码,切换动画时不要调用停止播放试下

if(simpleDraweeView.isPlaying()) {
simpleDraweeView.stopAnimation();
}
ghost commented 5 years ago

有使用2.0.2,在所下载的Demo里面,我放入了自己的图片40张。在动画快要结束的时候点击start,帧动画有时显示不出。并报错

java.lang.InterruptedException
2019-05-30 15:43:38.433 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1022)
2019-05-30 15:43:38.433 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1328)
2019-05-30 15:43:38.433 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
2019-05-30 15:43:38.433 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:150)
2019-05-30 15:43:38.433 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:155)
2019-05-30 15:43:38.451 27319-27419/com.yuyashuai.silkyanimation I/chatty: uid=10161(com.yuyashuai.silkyanimation) Thread-14 identical 410 lines
2019-05-30 15:43:38.451 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:155)
2019-05-30 15:43:38.451 27319-27319/com.yuyashuai.silkyanimation I/Toast: Show toast from OpPackageName:com.yuyashuai.silkyanimation, PackageName:com.yuyashuai.silkyanimation
2019-05-30 15:43:38.451 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:155)
2019-05-30 15:43:38.472 27319-27419/com.yuyashuai.silkyanimation I/chatty: uid=10161(com.yuyashuai.silkyanimation) identical 492 lines
2019-05-30 15:43:38.472 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:155)
2019-05-30 15:43:38.472 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
2019-05-30 15:43:38.472 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
2019-05-30 15:43:38.472 27319-27419/com.yuyashuai.silkyanimation W/System.err:     at java.lang.Thread.run(Thread.java:764)
2019-05-30 15:43:38.800 27319-27427/com.yuyashuai.silkyanimation W/System.err: java.lang.InterruptedException
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1022)
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1328)
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.decodeBitmap(DefaultBitmapPool.kt:150)
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool.access$decodeBitmap(DefaultBitmapPool.kt:13)
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at com.yuyashuai.frameanimation.io.DefaultBitmapPool$start$2.run(DefaultBitmapPool.kt:86)
2019-05-30 15:43:38.801 27319-27427/com.yuyashuai.silkyanimation W/System.err:     at java.lang.Thread.run(Thread.java:764)
yuyashuai commented 5 years ago

已更新

implementation 'com.yuyashuai.frameanimation:frameanimation:2.0.3'