10000 Make animation blit cache robust against 3d viewpoint changes. by anntzer · Pull Request #16070 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Make animation blit cache robust against 3d viewpoint changes. #16070

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

Merged
merged 1 commit into from
Jan 4, 2020

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Jan 2, 2020

Instead of connecting to the xlim_changed/ylim_changed events to clear
the blit cache, use Axes._get_view(), which also works for 3d axes.

Closes #16069. No test because good luck with that, but one can repro with the example at that issue.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the view checking from notification to polling. We have to execute _get_view() every time we want to use the background. Have you evaluated the performance impact?

Can we introduce a generic view_changed callback instead.

@anntzer
Copy link
Contributor Author
anntzer commented Jan 2, 2020

_get_view returns the axes limits (plus the view angles in 3D), which is something that needs to be accessed anyways for drawing the artist. So yes it's a couple more attribute accesses but I doubt it matters (but I have not checked this).

In theory custom projections need to implement _get_view anyways to interact properly with the home/previous/next buttons, so it seems annoying to request that they additionally need to implement view_changed (_get_view and view_changed going out of sync would be yet another possible source of bugs, whereas if there's only one source of truth, it can't go out of sync with itself).

@tacaswell tacaswell added this to the v3.3.0 milestone Jan 4, 2020
pass
else:
if ax._get_view() == view:
ax.figure.canvas.restore_region(bg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well evict invalid backgrounds here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, good point.

@tacaswell
Copy link
Member

This seems to be simpler over all. While this is in the hot-loop of the animation loop so we should be concerned, but on my few year laptop, ax._get_view() takes ~9us. My (un-benchmarked) hunch as that we are getting back more than that with the other cleanups in this PR.

Copy link
Member
@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modulo pre-emptive cache eviction.

Instead of connecting to the xlim_changed/ylim_changed events to clear
the blit cache, use Axes._get_view(), which also works for 3d axes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

matplotlib glitch when rotating interactively a 3d animation
3 participants
0