Skip to content
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

pyplot show() opens functioning window only outside of rewalt, otherwise creates a non-responsive window #1

Open
logicsoup opened this issue Aug 31, 2022 · 1 comment

Comments

@logicsoup
Copy link
Collaborator

logicsoup commented Aug 31, 2022

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

  1. 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.
  2. Could be a WM issue, depending on which OS and WM the other contributors use. It would be helpful to compare.
  3. It would be helpful to find out which matplotlib backend the other contributors use as well.
  4. 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.
@logicsoup
Copy link
Collaborator Author

logicsoup commented Aug 31, 2022

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

  1. Create a script that switches between matplotlib GUI backends, opening, closing, and drawing plots from Rewalt.
  2. Use the pdb debugger on the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant