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
Stuck figure window after plt.close() in ipython with Qt5 #17109
Comments
|
If you create another new figure do the existing ones become responsive again? Alternatively dose My suspicion is that with all the windows closed, we are no longer spinning the QT event loop so while the window exists in the display manager side, nothing in handling the input. |
|
@tacaswell
Unfortunately no, the "closed" figure stays there and still does not respond.
I also had this suspicion, I tried many combinations but what I see is that anytime I created more than one figure, this problem happens some way or the other and it's impossible do close those stuck figures. |
|
I realized that I was not running the latest stable version, which is 3.2.1. I installed it from conda-forge and I experience the same bug. |
|
Throwing a This is also a very old bug, which reproduced back to 2.2.5. Possibly it's something to do with IPython versions and its Qt integration. |
|
This is also not macOS-specific. |
|
I suspect that there is some race going on between IPython and Matplotlib trying to start up the global QApplication instance (but that is more of a hunch than anything solid). |
|
I think I found a workaround. I manually connected the qt window destroy function to the figures' close events. My first tests seem to work, either using the pyplot close function, or the window close button (both cases had problems). Maybe it could serve as a direction to solve this bug in the real code. |
|
Interestingly, the workaround doesn't work anymore as soon as there's a plt.pause while the figures are shown. Works: Doesn't work: There seems to effectively has something with the event loop (I messed a bit with MPL's code and it's the start_event_loop from plt.pause that seems to cause this difference). |
|
I want to add that I encounter what seems to be a related issue when creating many figures in a script that is run from the command line. While the script does not hang on figures when
Increasing or removing the limit on the number of open files allowed is not an adequate solution for me since this would cause extreme CPU slowdowns from the large number of figures I am creating. VersionsOperating system: macOS 10.15.7 Code for ReproductionRunning as a script from command line. Adding Current WorkaroundUsing |
|
@tfetherolf, this seems somewhat different since its from the command line and never uses an interactive backend, can you open a new issue for this? |
|
@tfetherolf If you do |
|
In both cases my new suspicion is that for various reasons we defer setting up the logic to tear down the GUI windows until after the GUI window is shown, however if you close the figure before it is shown we end up in a state where on one hand we have asked a GUI to be shown, then tear down the Python side logic, then the window shows and we get a zombie window (with no Python side way to get a hold of it!) and no logic of when to close it. |
|
@tacaswell Adding |
|
doing a This is connected to #18609 (comment) in the sense that we are not sure if "close" means "hide" or "destroy". |
|
Hello @tacaswell |
|
Interesting, still suspect it is a fussy reference counting issue, but apparently a platform dependent one... |


felixchenier commentedApr 12, 2020
•
edited by tacaswell
Bug report
Bug summary
When more than one figure is shown, then clicking on the last figure's close button or running plt.close() or plt.close('all') leaves a zombie figure behind. At first, figure windows are properly closed, but when switching back to the matplotlib python application, the last figure resuscitates and is not clickable nor closable anymore.
Doing the samething another time leaves an additional zombie figure window, and so on. The only way to close those non-responding windows is to quit ipython.
Code for reproduction
Running in ipython:
Actual outcome
No output, and the figures close. But then if we press alt-tab, the last figure resuscitates and does not respond to user input.
Expected outcome
The last figure should not resuscitate.
Matplotlib version
Qt5Agg):Installation under conda, default conda channel:
[TAC edited to remove comments in example code to make copy-pasting easier]
The text was updated successfully, but these errors were encountered: