{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/fresco/issues/2081","repository_url":"https://api.github.com/repos/facebook/fresco","labels_url":"https://api.github.com/repos/facebook/fresco/issues/2081/labels{/name}","comments_url":"https://api.github.com/repos/facebook/fresco/issues/2081/comments","events_url":"https://api.github.com/repos/facebook/fresco/issues/2081/events","html_url":"https://github.com/facebook/fresco/issues/2081","id":309333200,"number":2081,"title":"Animation stopped without onAnimationStop getting called","user":{"login":"PalDhv","id":28922865,"avatar_url":"https://avatars1.githubusercontent.com/u/28922865?v=4","gravatar_id":"","url":"https://api.github.com/users/PalDhv","html_url":"https://github.com/PalDhv","followers_url":"https://api.github.com/users/PalDhv/followers","following_url":"https://api.github.com/users/PalDhv/following{/other_user}","gists_url":"https://api.github.com/users/PalDhv/gists{/gist_id}","starred_url":"https://api.github.com/users/PalDhv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PalDhv/subscriptions","organizations_url":"https://api.github.com/users/PalDhv/orgs","repos_url":"https://api.github.com/users/PalDhv/repos","events_url":"https://api.github.com/users/PalDhv/events{/privacy}","received_events_url":"https://api.github.com/users/PalDhv/received_events","type":"User","site_admin":false},"labels":[{"id":182304115,"url":"https://api.github.com/repos/facebook/fresco/labels/bug","name":"bug","color":"fc2929","default":true},{"id":806599053,"url":"https://api.github.com/repos/facebook/fresco/labels/help%20wanted","name":"help wanted","color":"ea2add","default":true},{"id":247769200,"url":"https://api.github.com/repos/facebook/fresco/labels/starter-task","name":"starter-task","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"oprisnik","id":2699634,"avatar_url":"https://avatars1.githubusercontent.com/u/2699634?v=4","gravatar_id":"","url":"https://api.github.com/users/oprisnik","html_url":"https://github.com/oprisnik","followers_url":"https://api.github.com/users/oprisnik/followers","following_url":"https://api.github.com/users/oprisnik/following{/other_user}","gists_url":"https://api.github.com/users/oprisnik/gists{/gist_id}","starred_url":"https://api.github.com/users/oprisnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oprisnik/subscriptions","organizations_url":"https://api.github.com/users/oprisnik/orgs","repos_url":"https://api.github.com/users/oprisnik/repos","events_url":"https://api.github.com/users/oprisnik/events{/privacy}","received_events_url":"https://api.github.com/users/oprisnik/received_events","type":"User","site_admin":false},"assignees":[{"login":"oprisnik","id":2699634,"avatar_url":"https://avatars1.githubusercontent.com/u/2699634?v=4","gravatar_id":"","url":"https://api.github.com/users/oprisnik","html_url":"https://github.com/oprisnik","followers_url":"https://api.github.com/users/oprisnik/followers","following_url":"https://api.github.com/users/oprisnik/following{/other_user}","gists_url":"https://api.github.com/users/oprisnik/gists{/gist_id}","starred_url":"https://api.github.com/users/oprisnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oprisnik/subscriptions","organizations_url":"https://api.github.com/users/oprisnik/orgs","repos_url":"https://api.github.com/users/oprisnik/repos","events_url":"https://api.github.com/users/oprisnik/events{/privacy}","received_events_url":"https://api.github.com/users/oprisnik/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-03-28T11:48:50Z","updated_at":"2018-05-19T10:20:20Z","closed_at":null,"author_association":"NONE","body":"### Description\r\nI want to hide simpleDraweeView after gif animation completion. So I have added AnimationListener and hide my controller onAnimationStop. But half of the time it does not call the onAnimationStop method. \r\nLet me know if I am doing something wrong.\r\n\r\n```\r\n new BaseControllerListener() {\r\n        @Override\r\n        public void onFinalImageSet(\r\n          String id,\r\n          @Nullable Object imageInfo,\r\n          @Nullable final Animatable animatable) {\r\n          if (animatable != null) {\r\n            AnimatedDrawable2 animatedDrawable = (AnimatedDrawable2) animatable;\r\n            animatedDrawable.setAnimationListener(new AnimationListener() {\r\n              @Override\r\n              public void onAnimationStart(AnimatedDrawable2 drawable) {\r\n\r\n                Log.i(TAG, \"onAnimationStart: \");\r\n              }\r\n\r\n              @Override\r\n              public void onAnimationStop(AnimatedDrawable2 drawable) {\r\n                .setVisibility(View.GONE);\r\n                Log.i(TAG, \"onAnimationStop: \");\r\n              }\r\n\r\n              @Override\r\n              public void onAnimationReset(AnimatedDrawable2 drawable) {\r\n                Log.i(TAG, \"onAnimationReset: \");\r\n              }\r\n\r\n              @Override\r\n              public void onAnimationRepeat(AnimatedDrawable2 drawable) {\r\n                Log.i(TAG, \"onAnimationRepeat: \");\r\n              }\r\n\r\n              @Override\r\n              public void onAnimationFrame(AnimatedDrawable2 drawable, int frameNumber) {\r\n                Log.i(TAG, \"onAnimationFrame: \"+frameNumber);\r\n              }\r\n            });\r\n            Log.i(TAG, \"animatable.start();: \");\r\n            animatable.start();\r\n          }\r\n        }\r\n      })\r\n```\r\n\r\n### Additional Information\r\n\r\n* Fresco version:1.8.1\r\n* Platform version: Android 7.1.1\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/fresco/issues/comments/390395328","html_url":"https://github.com/facebook/fresco/issues/2081#issuecomment-390395328","issue_url":"https://api.github.com/repos/facebook/fresco/issues/2081","id":390395328,"user":{"login":"test01wrk","id":7474761,"avatar_url":"https://avatars2.githubusercontent.com/u/7474761?v=4","gravatar_id":"","url":"https://api.github.com/users/test01wrk","html_url":"https://github.com/test01wrk","followers_url":"https://api.github.com/users/test01wrk/followers","following_url":"https://api.github.com/users/test01wrk/following{/other_user}","gists_url":"https://api.github.com/users/test01wrk/gists{/gist_id}","starred_url":"https://api.github.com/users/test01wrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/test01wrk/subscriptions","organizations_url":"https://api.github.com/users/test01wrk/orgs","repos_url":"https://api.github.com/users/test01wrk/repos","events_url":"https://api.github.com/users/test01wrk/events{/privacy}","received_events_url":"https://api.github.com/users/test01wrk/received_events","type":"User","site_admin":false},"created_at":"2018-05-19T10:20:20Z","updated_at":"2018-05-19T10:20:20Z","author_association":"NONE","body":"@defHLT \r\n[gif file and logcat](https://www.dropbox.com/sh/mwdal85kr84xg0d/AAC1LMIW1X9IrOPH-6tTVAyBa?dl=0)\r\n\r\nI have 2 gif images, when the first one stopped, the other one shall start. But sometimes onAnimationStop isn't getting called, thus I can't start the next animator.\r\n\r\nThis is how I setup.\r\n```\r\nAbstractDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder();\r\nImageRequest[] imageRequests = new ImageRequest[] { ImageRequestBuilder.newBuilderWithSource(uri).build()};\r\ncontrollerBuilder.setFirstAvailableImageRequests(imageRequests, true);\r\ncontrollerBuilder.setControllerListener(new BaseControllerListener() {\r\n    @Override\r\n    public void onFinalImageSet(String id, Object imageInfo, Animatable animatable) {\r\n        AnimatedDrawable2 animator = (AnimatedDrawable2) animatable;\r\n        animator.setAnimationListener(new BaseAnimationListener() {\r\n            @Override\r\n            public void onAnimationStop(AnimatedDrawable2 animatedDrawable2) {\r\n                startNextAnim();\r\n            }\r\n        });\r\n        AnimationBackend animationBackend = animator.getAnimationBackend();\r\n        animator.setAnimationBackend(new AnimationBackendDelegate<AnimationBackend>(animationBackend) {\r\n            @Override\r\n            public int getLoopCount() {\r\n                return 1; // only play once\r\n            }\r\n        });\r\n        startFirstAnim();\r\n    }\r\n});\r\n```\r\n\r\nThe log of DrawListener shows that when the last draw finished, the animator was still running, somehow `(frameNumberToDraw == FrameScheduler.FRAME_NUMBER_DONE)`  returned false.\r\n\r\n```\r\n05-19 17:37:54.504 onFinalImageSet: animatedDrawable=237593914, getFrameCount=89, getLoopCount=1, getLoopDurationMs=2670\r\n05-19 17:37:54.510 onFinalImageSet: animatedDrawable=208633672, getFrameCount=25, getLoopCount=1, getLoopDurationMs=3000\r\n...\r\n05-19 17:38:45.769 onDraw: animatedDrawable=237593914, frameNumberToDraw=87, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1496533, animationTimeMs=2613, lastFrameAnimationTimeMs=2595, actualRenderTimeStartMs=1499146, actualRenderTimeEndMs=1499147, startRenderTimeForNextFrameMs=2640, scheduledRenderTimeForNextFrameMs=2648\r\n05-19 17:38:45.803 onDraw: animatedDrawable=237593914, frameNumberToDraw=88, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1496533, animationTimeMs=2648, lastFrameAnimationTimeMs=2613, actualRenderTimeStartMs=1499181, actualRenderTimeEndMs=1499182, startRenderTimeForNextFrameMs=2670, scheduledRenderTimeForNextFrameMs=2678\r\n05-19 17:38:45.836 onDraw: animatedDrawable=237593914, frameNumberToDraw=88, frameDrawn=true, isAnimationRunning=false, animationStartTimeMs=1496533, animationTimeMs=2681, lastFrameAnimationTimeMs=2648, actualRenderTimeStartMs=1499214, actualRenderTimeEndMs=1499215, startRenderTimeForNextFrameMs=-1, scheduledRenderTimeForNextFrameMs=-1\r\n0...\r\n05-19 17:38:48.623 onDraw: animatedDrawable=208633672, frameNumberToDraw=23, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1499227, animationTimeMs=2774, lastFrameAnimationTimeMs=2656, actualRenderTimeStartMs=1502001, actualRenderTimeEndMs=1502001, startRenderTimeForNextFrameMs=2880, scheduledRenderTimeForNextFrameMs=2888\r\n05-19 17:38:48.741 onDraw: animatedDrawable=208633672, frameNumberToDraw=24, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1499227, animationTimeMs=2892, lastFrameAnimationTimeMs=2774, actualRenderTimeStartMs=1502119, actualRenderTimeEndMs=1502120, startRenderTimeForNextFrameMs=3000, scheduledRenderTimeForNextFrameMs=3008\r\n05-19 17:38:48.860 onDraw: animatedDrawable=208633672, frameNumberToDraw=24, frameDrawn=true, isAnimationRunning=false, animationStartTimeMs=1499227, animationTimeMs=3011, lastFrameAnimationTimeMs=2892, actualRenderTimeStartMs=1502238, actualRenderTimeEndMs=1502239, startRenderTimeForNextFrameMs=-1, scheduledRenderTimeForNextFrameMs=-1\r\n...\r\n05-19 17:38:51.482 onDraw: animatedDrawable=237593914, frameNumberToDraw=87, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1502243, animationTimeMs=2616, lastFrameAnimationTimeMs=2582, actualRenderTimeStartMs=1504859, actualRenderTimeEndMs=1504861, startRenderTimeForNextFrameMs=2640, scheduledRenderTimeForNextFrameMs=2648\r\n05-19 17:38:51.516 onDraw: animatedDrawable=237593914, frameNumberToDraw=88, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1502243, animationTimeMs=2650, lastFrameAnimationTimeMs=2616, actualRenderTimeStartMs=1504893, actualRenderTimeEndMs=1504895, startRenderTimeForNextFrameMs=2670, scheduledRenderTimeForNextFrameMs=2678\r\n05-19 17:38:51.536 onDraw: animatedDrawable=237593914, frameNumberToDraw=88, frameDrawn=true, isAnimationRunning=true, animationStartTimeMs=1502243, animationTimeMs=2669, lastFrameAnimationTimeMs=2650, actualRenderTimeStartMs=1504912, actualRenderTimeEndMs=1504914, startRenderTimeForNextFrameMs=-1, scheduledRenderTimeForNextFrameMs=-1\r\n// the log stopped here,  isAnimationRunning=true, onAnimationStop not called\r\n```\r\n"}}
{"actor":{"display_login":"test01wrk"}}