rewalt
rewalt copied to clipboard
pyplot show() opens functioning window only outside of rewalt, otherwise creates a non-responsive window
Problem description
Using matplotlib.pyplot outside of rewalt with pyplot.show() opens a functioning window.
However, rewalt creates an unresponsive window without showing the plot, giving a prompt of " "" is not responding". It can only be killed by using xkill.
Saving the image without opening a window, and then opening the saved image works, however.
System details
Python version: Python 3.10.4
Matplotlib backend:
matplotlib.get_backend()
'GTK4Agg'
Rewalt version:
import rewalt
rewalt.__version__
'0.1.0'
OS: Pop_OS! Window manager: GNOME Display Manager
Working with the latest changes as per the current date.
Problem reproduction
The following works:
import matplotlib.pyplot as plt
fig, axes = plt.subplots()
plt.show()
But the following produces an unresponsive window:
import rewalt
test = rewalt.drawing.MatBackend()
test.output()
Trying this saves the image:
import rewalt
test = rewalt.drawing.MatBackend()
test.output(path="test.png",show=False)
Opening the image from the terminal works as well, opening a window showcasing the image.
Disabling the WM doesn't change anything.
Ideas
- It seems that showing the image specifically from Rewalt is one of the issues. The next step would be to let the process "wait" with drawing.
- Could be a WM issue, depending on which OS and WM the other contributors use. It would be helpful to compare.
- It would be helpful to find out which matplotlib backend the other contributors use as well.
- Could be an internal process in my computer that's causing some kind of race condition with the matplotlib backend, since we've previously thought the issue was solved after I restarted my computer.
Previously, I decided to switch backends to TkAgg, since
TkAgg, TkCairo, GTK3Agg, GTK3Cairo backends have been confirmed to work by @ahadziha.
However, despite having tk installed, it didn't work, so I found out that I could also install python3.10-tk.
Switching backends to TkAgg made it possible to display the image through Rewalt as well:
image = rewalt.drawing.MatBackend()
image.output()
Opens the pyplot window.
But that doesn't explain why matplotlib.pyplot produced the pyplot window on its own outside of Rewalt, simultaneously in the same session of the Python interpreter, when I used the GTK4Agg backend.
So I decided to switch back to the GTK4Agg backend and surprisingly, creating plots in Rewalt works without issues.
To reproduce the bug, I tried it with my WM on and off, just in case, without luck.
I've introduced logging in my branch and would like to close the issue only when I've successfully reproduced and fixed the bug.
Catching the bug if it's reproduced
- Create a script that switches between matplotlib GUI backends, opening, closing, and drawing plots from Rewalt.
- Use the
pdbdebugger on the script.