Skip to content

Wait cursor may cause Tk to print _get_renderer.Done backtrace #18186

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

Closed
QuLogic opened this issue Aug 5, 2020 · 3 comments
Closed

Wait cursor may cause Tk to print _get_renderer.Done backtrace #18186

QuLogic opened this issue Aug 5, 2020 · 3 comments
Labels
Milestone

Comments

@QuLogic
Copy link
Member

QuLogic commented Aug 5, 2020

Bug report

Bug summary

I was looking at #11769, and apparently Gouraud shading was slow enough to trigger the wait cursor on the third figure. This printed out a backtrace, though the figures seems to be saved just fine.

Code for reproduction

See #11769.

Actual outcome

../mpl-tests/issue11769.py:23: MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3.  Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading'].  This will become an error two minor releases later.
  plt.pcolormesh(x,y,map2,cmap='viridis',vmin=np.nanmin(map2),vmax=np.nanmax(map2))

Exception in Tkinter callback
Traceback (most recent call last):
  File "/var/container/conda/envs/mpl37/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/var/container/conda/envs/mpl37/lib/python3.7/tkinter/__init__.py", line 749, in callit
    func(*args)
  File ".../matplotlib/lib/matplotlib/backends/_backend_tk.py", line 247, in idle_draw
    self.draw()
  File ".../matplotlib/lib/matplotlib/backends/backend_tkagg.py", line 9, in draw
    super().draw()
  File ".../matplotlib/lib/matplotlib/backends/backend_agg.py", line 409, in draw
    self.figure.draw(self.renderer)
  File ".../matplotlib/lib/matplotlib/backend_bases.py", line 1546, in _draw
    def _draw(renderer): raise Done(renderer)
matplotlib.backend_bases._get_renderer.<locals>.Done: <matplotlib.backends.backend_agg.RendererAgg object at 0x7f45c8946290>

Expected outcome

No backtrace printed.

Matplotlib version

  • Operating system: Fedora 31
  • Matplotlib version: master 52761de
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7.6
@QuLogic QuLogic added the GUI: tk label Aug 5, 2020
@QuLogic
Copy link
Member Author

QuLogic commented Aug 5, 2020

Since this is apparently caused by the window.update_idletasks() in NavigationToolbar2Tk.set_cursor, I guess this would be fixed by #17789.

Though I'm not sure how Tk manages to see this exception since it's supposed to be caught right there.

@richardsheridan
Copy link
Contributor

richardsheridan commented Aug 10, 2020

If any of the code between lines 1549-1557 calls window.update_idletasks(), and one of the idle tasks happens to be draw_idle(), then it will try to call canvas.draw() while cbook._setattr_cm(figure, draw=_draw) is still active, but it won't be affected by the try block! Another great reason never to use window.update() and friends in library code...

@anntzer
Copy link
Contributor

anntzer commented May 11, 2021

This has been fixed on master; I haven't bisected but did so for the similar #20204: likely this was indeed fixed by #17789.

@anntzer anntzer closed this as completed May 11, 2021
@anntzer anntzer added this to the v3.4.0 milestone May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants