Repository navigation
Conversation
set_val drew the canvas before processing the 'changed' callback, so a callback that updates other artists paid two renders per event and the first showed the previous data. Notify observers first, then draw once; a callback that draws itself still sees exactly one render of the final state.
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
After looking at the author's other PRs and lack of following templates, I believe that the PR summary and PR itself were written by AI and are in violation of our AI policy. AgentScan currently categorizes the account as I am marking this PR as Autoclose. |
|
⏰ This pull request might be automatically closed in two weeks from now. Thank you for your contribution to Matplotlib and for the effort you have put into this PR. This pull request does not yet meet the quality and clarity standards needed for an effective review. Project maintainers have limited time for code reviews, and our goal is to prioritize well-prepared contributions to keep Matplotlib maintainable. Matplotlib maintainers cannot provide one-to-one guidance on this PR. However, if you ask focused, well-researched questions, a community member may be willing to help. 💬 To increase the chance of a productive review:
As the author, you are responsible for driving this PR, which entails doing necessary background research as well as presenting its context and your thought process. If you are a new contributor, or do not know how to fulfill these requirements, we recommend that you familiarize yourself with Matplotlib's development conventions or engage with the community via our Discourse or one of our meetings before submitting code. If you substantially improve this PR within two weeks, leave a comment and a team member may remove the |
PR summary
Fixes #32526.
Slider.set_valandRangeSlider.set_valcalledcanvas.draw_idle()before processing the'changed'observers, so an app whose callback updates other artists paid two renders per event — and the first render showed the previous data. On the reporting app this halved the interactive frame rate (49 ms of a 97 ms event was the wasted render).This reorders both methods to notify observers first and draw once afterwards. A callback that calls
draw_idle()itself still gets exactly one render of the final state; a callback that doesn't draw keeps the widget's own draw. There is no case where the old ordering produced output the new ordering loses — the old first render was stale by construction.The repro from the issue now reports zero draws before the callback:
Both
SliderandRangeSliderare covered; the otherdraw_idlecall sites inwidgets.py(Cursor, MultiCursor) draw in event handlers, not before callbacks, and are untouched.AI Disclosure
The reproduction and diagnosis were assisted by an AI coding agent, verified independently by me (matching the issue reporter's workflow). The ordering change is two three-line moves reviewed against the observer contracts in
CallbackRegistry.PR quality check
Closes #32526.