fresco icon indicating copy to clipboard operation
fresco copied to clipboard

For infinitely animated webp, the AnimationListener is not correct.

Open duxxz opened this issue 8 years ago • 3 comments

We use GitHub Issues for bugs.

If you have a non-bug question, please ask on Stack Overflow: http://stackoverflow.com/questions/tagged/fresco

--- Please use this template, and delete everything above this line before submitting your issue ---

Description

I use a infinitely animated webp with fresco, I add a listener to check when it repeat. I found that onAnimationStart() and onAnimationRepeat() was bean called more than once in the beginning. like log below ↓ 10-20 16:41:15.916 25214-25214/xx E/webp: onAnimationStart -- 10-20 16:41:15.932 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.934 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:15.966 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.967 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:15.980 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.983 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:15.993 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.995 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:16.010 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.030 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.043 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.059 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.080 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.111 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:16.129 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:16.149 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:16.181 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.206 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.212 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.230 25214-25214/xx E/webp: onAnimationFrame -- 3

Reproduction use a infinitely animated webp in fresco. and add a AnimationListener.

Solution

Additional Information

Fresco version: [1.5.0 ] Platform version: [All Android device]

-----------code---------- `DraweeController webpController = Fresco.newDraweeControllerBuilder() .setUri(animatedWebpUri) .setOldController(image.getController()) .setControllerListener(new BaseControllerListener<ImageInfo>() { @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable anim) { if (anim != null && anim instanceof AnimatedDrawable2) { ((AnimatedDrawable2) anim).setAnimationListener(new AnimatedWebpListener() { @Override public void onAnimationStart(AnimatedDrawable2 drawable) { SLog.e("webp","onAnimationStart -- "); }

@Override
public void onAnimationStop(AnimatedDrawable2 drawable) {
    SLog.e("webp","onAnimationStop -- ");
}

@Override
public void onAnimationReset(AnimatedDrawable2 drawable) {
    SLog.e("webp","onAnimationReset -- ");
}

@Override
public void onAnimationRepeat(AnimatedDrawable2 drawable) {
    SLog.e("webp","onAnimationRepeat -- ");
}

@Override
public void onAnimationFrame(AnimatedDrawable2 drawable, int frameNumber) {
    SLog.e("webp","onAnimationFrame -- " + frameNumber);
}
                            });
                            anim.start();
                        }
                    }
                })
                .build();`

------------log --------------- 10-20 16:41:15.916 25214-25214/xx E/webp: onAnimationStart -- 10-20 16:41:15.932 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.934 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:15.966 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.967 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:15.980 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.983 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:15.993 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:15.995 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:16.010 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.030 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.043 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.059 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.080 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:16.111 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:16.129 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:16.149 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:16.181 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.206 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.212 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.230 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:16.264 25214-25214/xx E/webp: onAnimationFrame -- 4 10-20 16:41:16.335 25214-25214/xx E/webp: onAnimationFrame -- 5 10-20 16:41:16.415 25214-25214/xx E/webp: onAnimationFrame -- 6 10-20 16:41:16.500 25214-25214/xx E/webp: onAnimationFrame -- 7 10-20 16:41:16.583 25214-25214/xx E/webp: onAnimationFrame -- 8 10-20 16:41:16.669 25214-25214/xx E/webp: onAnimationFrame -- 9 10-20 16:41:16.753 25214-25214/xx E/webp: onAnimationFrame -- 10 10-20 16:41:16.838 25214-25214/xx E/webp: onAnimationFrame -- 11 10-20 16:41:16.923 25214-25214/xx E/webp: onAnimationFrame -- 12 10-20 16:41:17.006 25214-25214/xx E/webp: onAnimationFrame -- 13 10-20 16:41:17.090 25214-25214/xx E/webp: onAnimationFrame -- 14 10-20 16:41:17.175 25214-25214/xx E/webp: onAnimationFrame -- 15 10-20 16:41:17.251 25214-25214/xx E/webp: onAnimationFrame -- 16 10-20 16:41:17.329 25214-25214/xx E/webp: onAnimationFrame -- 17 10-20 16:41:17.421 25214-25214/xx E/webp: onAnimationFrame -- 18 10-20 16:41:17.498 25214-25214/xx E/webp: onAnimationFrame -- 19 10-20 16:41:17.587 25214-25214/xx E/webp: onAnimationFrame -- 20 10-20 16:41:17.671 25214-25214/xx E/webp: onAnimationFrame -- 21 10-20 16:41:17.750 25214-25214/xx E/webp: onAnimationFrame -- 22 10-20 16:41:17.840 25214-25214/xx E/webp: onAnimationFrame -- 23 10-20 16:41:17.920 25214-25214/xx E/webp: onAnimationFrame -- 24 10-20 16:41:18.012 25214-25214/xx E/webp: onAnimationFrame -- 25 10-20 16:41:18.090 25214-25214/xx E/webp: onAnimationFrame -- 26 10-20 16:41:18.158 25214-25214/xx E/webp: onAnimationFrame -- 26 10-20 16:41:18.244 25214-25214/xx E/webp: onAnimationFrame -- 28 10-20 16:41:18.327 25214-25214/xx E/webp: onAnimationFrame -- 29 10-20 16:41:18.422 25214-25214/xx E/webp: onAnimationFrame -- 30 10-20 16:41:18.496 25214-25214/xx E/webp: onAnimationFrame -- 31 10-20 16:41:18.581 25214-25214/xx E/webp: onAnimationFrame -- 32 10-20 16:41:18.668 25214-25214/xx E/webp: onAnimationFrame -- 33 10-20 16:41:18.749 25214-25214/xx E/webp: onAnimationFrame -- 34 10-20 16:41:18.835 25214-25214/xx E/webp: onAnimationFrame -- 35 10-20 16:41:18.923 25214-25214/xx E/webp: onAnimationFrame -- 36 10-20 16:41:18.988 25214-25214/xx E/webp: onAnimationFrame -- 37 10-20 16:41:19.074 25214-25214/xx E/webp: onAnimationFrame -- 37 10-20 16:41:19.158 25214-25214/xx E/webp: onAnimationFrame -- 39 10-20 16:41:19.239 25214-25214/xx E/webp: onAnimationFrame -- 40 10-20 16:41:19.327 25214-25214/xx E/webp: onAnimationFrame -- 41 10-20 16:41:19.417 25214-25214/xx E/webp: onAnimationFrame -- 42 10-20 16:41:19.499 25214-25214/xx E/webp: onAnimationFrame -- 43 10-20 16:41:19.579 25214-25214/xx E/webp: onAnimationFrame -- 44 10-20 16:41:19.666 25214-25214/xx E/webp: onAnimationFrame -- 45 10-20 16:41:19.749 25214-25214/xx E/webp: onAnimationFrame -- 46 10-20 16:41:19.836 25214-25214/xx E/webp: onAnimationFrame -- 47 10-20 16:41:19.917 25214-25214/xx E/webp: onAnimationFrame -- 48 10-20 16:41:19.994 25214-25214/xx E/webp: onAnimationFrame -- 49 10-20 16:41:20.068 25214-25214/xx E/webp: onAnimationFrame -- 50 10-20 16:41:20.152 25214-25214/xx E/webp: onAnimationFrame -- 51 10-20 16:41:20.238 25214-25214/xx E/webp: onAnimationFrame -- 52 10-20 16:41:20.324 25214-25214/xx E/webp: onAnimationFrame -- 53 10-20 16:41:20.407 25214-25214/xx E/webp: onAnimationFrame -- 54 10-20 16:41:20.490 25214-25214/xx E/webp: onAnimationFrame -- 55 10-20 16:41:20.577 25214-25214/xx E/webp: onAnimationFrame -- 56 10-20 16:41:20.660 25214-25214/xx E/webp: onAnimationFrame -- 57 10-20 16:41:20.754 25214-25214/xx E/webp: onAnimationFrame -- 58 10-20 16:41:20.836 25214-25214/xx E/webp: onAnimationFrame -- 59 10-20 16:41:20.899 25214-25214/xx E/webp: onAnimationFrame -- 60 10-20 16:41:20.981 25214-25214/xx E/webp: onAnimationFrame -- 61 10-20 16:41:21.066 25214-25214/xx E/webp: onAnimationFrame -- 62 10-20 16:41:21.162 25214-25214/xx E/webp: onAnimationFrame -- 63 10-20 16:41:21.240 25214-25214/xx E/webp: onAnimationFrame -- 64 10-20 16:41:21.327 25214-25214/xx E/webp: onAnimationFrame -- 65 10-20 16:41:21.407 25214-25214/xx E/webp: onAnimationFrame -- 66 10-20 16:41:21.488 25214-25214/xx E/webp: onAnimationFrame -- 67 10-20 16:41:21.579 25214-25214/xx E/webp: onAnimationFrame -- 68 10-20 16:41:21.657 25214-25214/xx E/webp: onAnimationFrame -- 69 10-20 16:41:21.742 25214-25214/xx E/webp: onAnimationFrame -- 70 10-20 16:41:21.812 25214-25214/xx E/webp: onAnimationFrame -- 71 10-20 16:41:21.894 25214-25214/xx E/webp: onAnimationFrame -- 72 10-20 16:41:21.979 25214-25214/xx E/webp: onAnimationFrame -- 73 10-20 16:41:22.063 25214-25214/xx E/webp: onAnimationFrame -- 74 10-20 16:41:22.147 25214-25214/xx E/webp: onAnimationFrame -- 75 10-20 16:41:22.232 25214-25214/xx E/webp: onAnimationFrame -- 76 10-20 16:41:22.325 25214-25214/xx E/webp: onAnimationFrame -- 77 10-20 16:41:22.411 25214-25214/xx E/webp: onAnimationFrame -- 78 10-20 16:41:22.493 25214-25214/xx E/webp: onAnimationFrame -- 79 10-20 16:41:22.558 25214-25214/xx E/webp: onAnimationFrame -- 80 10-20 16:41:22.650 25214-25214/xx E/webp: onAnimationFrame -- 81 10-20 16:41:22.722 25214-25214/xx E/webp: onAnimationFrame -- 81 10-20 16:41:22.817 25214-25214/xx E/webp: onAnimationFrame -- 83 10-20 16:41:22.891 25214-25214/xx E/webp: onAnimationFrame -- 84 10-20 16:41:22.974 25214-25214/xx E/webp: onAnimationRepeat -- 10-20 16:41:22.977 25214-25214/xx E/webp: onAnimationFrame -- 0 10-20 16:41:23.069 25214-25214/xx E/webp: onAnimationFrame -- 1 10-20 16:41:23.152 25214-25214/xx E/webp: onAnimationFrame -- 2 10-20 16:41:23.234 25214-25214/xx E/webp: onAnimationFrame -- 3 10-20 16:41:23.323 25214-25214/xx E/webp: onAnimationFrame -- 4 10-20 16:41:23.390 25214-25214/xx E/webp: onAnimationFrame -- 5 10-20 16:41:23.491 25214-25214/xx E/webp: onAnimationFrame -- 6 10-20 16:41:23.568 25214-25214/xx E/webp: onAnimationFrame -- 7 10-20 16:41:23.638 25214-25214/xx E/webp: onAnimationFrame -- 7 10-20 16:41:23.722 25214-25214/xx E/webp: onAnimationFrame -- 9 10-20 16:41:23.804 25214-25214/xx E/webp: onAnimationFrame -- 10 10-20 16:41:23.897 25214-25214/xx E/webp: onAnimationFrame -- 11 10-20 16:41:23.979 25214-25214/xx E/webp: onAnimationFrame -- 12 10-20 16:41:24.057 25214-25214/xx E/webp: onAnimationFrame -- 13 10-20 16:41:24.143 25214-25214/xx E/webp: onAnimationFrame -- 14 10-20 16:41:24.227 25214-25214/xx E/webp: onAnimationFrame -- 15 10-20 16:41:24.318 25214-25214/xx E/webp: onAnimationFrame -- 16

duxxz avatar Oct 20 '17 08:10 duxxz

Hi @joslte115

Thanks for the detailed issue. We will try to look into it as soon as possible.

erikandre avatar Oct 25 '17 09:10 erikandre

Modification is needed for animated frames ControllerListener listernerObject = new BaseControllerListener<ImageInfo>() {

@Override public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) { //Action on final image load } @Override public void onFailure(String id, Throwable throwable) { //Action on failure } }; DraweeController controller = Fresco.newDraweeControllerBuilder() .setUri(uri) .setControllerListener( listernerObject) .build(); draweeView.setController(controller);

AikoKiko avatar Apr 15 '19 16:04 AikoKiko

Any updates?

yabee5566 avatar Feb 15 '22 10:02 yabee5566