-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
animation fixes #4995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
animation fixes #4995
Conversation
Using draw was triggering infinite recursion, using draw_idle does not.
This was introduced by matplotlib#4800. We need to disconnect the initial draw callback in _start() before doing _init_draw(), otherwise, we end up back in _start() when the draw_event fires. Also go ahead and remove the call to _init_draw() in __init__(), since _start() will handle it.
I also cherry-picked @dopplershift 's infinite recursion commit onto this PR just to be safe. |
For blitted animations in is essential to return a list of the animated artists. However, is other cases you can get away with out returning such a list. In the case of blitting it is important to make sure that the animation flags on the animated artist are set correctly, t his commit makes sure that we check that we actually got an iterable before trying to iterate over it.
There are race conditions where _blit_clear may be called before the first draw (which is what will grab the backgrounds)
@WeatherGod I think I have fixed the source of the not iterable bugs. All of the animation examples run correctly on this branch. |
And all of my examples now run too. There is one example of mine that is still showing a weird off-by-one-frame error, but I haven't yet determined if that is a bug on my part or a bug in matplotlib. This brings everything back to a functional state. |
try: | ||
a.figure.canvas.restore_region(bg_cache[a]) | ||
except KeyError: | ||
# something has happened out of order? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to be swallowing this exception silently? Should we at least attach one of our logging stuff to it?
Only attempt to force `set_animated(True)` when blitting is enabled.
@WeatherGod I backed out the changes you commented on. I am still not happy with the iterable issue. The underlying issue is that if you are using blitting then the animated artists must have |
@WeatherGod What is the history of the animated property? |
Without blitting, the _post_draw method uses draw_idle; with blitting, _post_draw calls _blit_draw, which calls ax.figure.canvas.blit. This is odd; I would expect blitting to be done at idle time, just like regular drawing. |
@mdehoon I agree that is a bit odd, but I think it has to be this way so that the client code can manage the blitted artists + backgrounds. I agree it would be better if we could push the blitting logic onto the other side of the canvas interface, but that is a bigger project that we can do before 1.5. |
You'd have to ask others. It predates me.
|
@tacaswell Once the blitting is done on the other side of the canvas interface, I can fix the MacOSX backend to handle blitting. I'm OK with waiting until after 1.5. |
@WeatherGod If you are happy with this can you merge it? |
Things look good here. Merging... |
Using draw was triggering infinite recursion, using draw_idle does not.
This fixes the recursion depth reported in #4967
attn @WeatherGod