Bug 39218 - Unpause/resume on AnimationDrawable always started on the 0th frame
Summary: Unpause/resume on AnimationDrawable always started on the 0th frame
Alias: None
Product: Android
Classification: Xamarin
Component: Tools and Addins ()
Version: 4.4.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2016-02-29 19:27 UTC by mli
Modified: 2016-03-03 17:48 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Codes that reproduces the bug (42.37 KB, application/x-zip-compressed)
2016-02-29 21:54 UTC, mli

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description mli 2016-02-29 19:27:38 UTC
Steps to reproduce:

1. Calling AnimationDrawable.SetVisible(false, false) to pause the animation.
2. Calling AnimationDrawable.SetVisible(true, false) to unpause/resume the animation from where it was paused.

Problem experienced:

Unpause/resume of the animation started on the 0th frame, instead of continuing from where it was paused.
Comment 1 Jonathan Pryor 2016-02-29 20:55:52 UTC
Please provide a reproducible test case.
Comment 2 mli 2016-02-29 21:54:53 UTC
Created attachment 15196 [details]
Codes that reproduces the bug

I have attached a simple project that demonstrates the issue. Any suggestions for the fix would be greatly appreciated.

Thank you very much!
Comment 3 mli 2016-02-29 22:45:47 UTC
Sample codes is also available on 


Comment 4 mli 2016-03-01 14:29:29 UTC
Included test codes in the attachment and on GitHub.
Comment 5 Jonathan Pryor 2016-03-03 17:48:31 UTC
Thank you for Attachment #15196 [details]. I "ported" it to Java, and observed the same behavior, so this isn't a binding problem.

Investigating further...would you believe that the documentation is wrong? :-)


> If restart is false, the animation will resume from the most recent frame.

That's not what the *implementation* does:


Specifically line 123-124:

    boolean startFromZero = restart || !mRunning ||
        mCurFrame >= mAnimationState.getChildCount();

When you call SetVisible(true, false), `restart` is false, but `changed` (see github) will be true, causing us to evaluate line 123. mRunning will be `false` (see unscheduleSelf(), called by setVisible(), so startFromZero is:

    boolean startFromZero = false || !false || ...

which means startFromZero will be *true*, which is why we observe that the animation restarts at frame 0.

I'm currently unable to ascertain *how* this is *supposed* to work.

Guess: perhaps SetVisible(true, true) is for one-shot animations:


while SetVisible(true, false) is meaningless when done after a SetVisible(false,*)? I'm not sure, but that certainly *seems* to be the case.