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

Lineplot window doesn't open on Wayland #4135

Open
clemisch opened this issue Jun 13, 2024 · 9 comments
Open

Lineplot window doesn't open on Wayland #4135

clemisch opened this issue Jun 13, 2024 · 9 comments

Comments

@clemisch
Copy link

When I use silx view <file>, look at an 2D image and do any line profile, the extra window with the line plot does not appear. No error is reported.

When I use

QT_QPA_PLATFORM=wayland silx view <file>

the extra window does pop up.

What surprises me is that I'm used to ipython3 --gui=qt5 working without any issues on Wayland, while silx appears to require the explicit QT flag.

I'm on Fedora 40, Gnome on Wayland. silx is installed via pipx and running under Python 3.12.

@t20100
Copy link
Member

t20100 commented Jul 9, 2024

Hi,

I don't have access to a machine to try this.

To be sure, can you check which version of Qt and which binding silx view is loading? You can see it from the Help -> About menu.
It would also be good to check which rendering backend is used (OpenGL or matplotlib). You can see it in the Options -> Plot rendering backend: <backend> menu.

Also, can you run the following code from ipython3 --gui=qt5 and do a line profile as you do with silx view? This reproduces what you do in silx view, and would allow to check if the behavior is different.

from silx import sx; import numpy as np
w = sx.imshow(np.arange(100*100).reshape(100, 100))

To know which platform is used by default, you can run QT_DEBUG_PLUGINS=1 silx view.
It's quite verbose, but checking the loaded library ... lines allows to find which platform is used by default (xcb I guess).

@loichuder
Copy link
Member

I am also on Gnome on Wayland (Ubuntu 22.04) and I cannot reproduce this, whether it is with Python 3.9 or 3.12.

I think further information is needed then: see the instructions given by @t20100

@clemisch
Copy link
Author

Thanks for looking into this! Sorry for my delayed response.

can you check which version of Qt and which binding silx view is loading?

Qt version 5.15.2, Qt binding PyQt5

It would also be good to check which rendering backend is used

At the moment it's matplotlib. Behavior is unchanged for opengl (after restart and confirming it's using opengl).

Also, can you run the following code

The lineplot also doesn't show up here.

To know which platform is used by default, you can run QT_DEBUG_PLUGINS=1 silx view

It looks to me like that's also using qt5? Only in the first line it's PyQt5/.../libqxcb.so.

$ grep "loaded library" silx_log.txt 
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so"
loaded library "Xcursor"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/platformthemes/libqgtk3.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqgif.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqicns.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqico.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqjpeg.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqsvg.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqtga.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqtiff.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqwbmp.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/imageformats/libqwebp.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/iconengines/libqsvgicon.so"
loaded library "/home/clem/.local/share/pipx/venvs/silx/lib/python3.12/site-packages/PyQt5/Qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"

@t20100
Copy link
Member

t20100 commented Jul 23, 2024

Can you try to run this script? It reproduces what silx view profile does with regarding windows but without silx.
My guess is that there is an issue when opening a sub-window in an application, this would allow to check it.

from PyQt5 import QtCore, QtGui, QtWidgets

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        btn = QtWidgets.QPushButton("Press")
        self.setCentralWidget(btn)
        btn.clicked.connect(self._clicked)

    def _clicked(self):
        print("new window")
        new_window = QtWidgets.QMainWindow(self)
        new_window.show()

app = QtWidgets.QApplication([])

window = MainWindow()
window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
window.show()

app.exec()

You can also try with the latest version of PyQt5 (5.15.11) and with other Qt bindings: PyQt6 and/or PySide6 to see if it is better.
silx gives priority to PyQt5 if it is installed, so to try the other Qt bindings, you either need to set QT_API=PyQt6 (or PySide6) or to uninstall PyQt5.

@clemisch
Copy link
Author

Thanks!

When I click "Press" the script does open a new window. This works both with $ python script.py and inside $ ipython3 --gui=qt5.

It just occured to me that e.g. the histogram window inside $ silx view does open. It seems that only the line plot doesn't work.

@clemisch
Copy link
Author

...but to me the lineplot is by far the most used feature! 😃

I understand though that this is not high priority for you. The workaround with QT_QPA_PLATFORM=wayland is working for now. I mainly wanted to open an issue about it because I was confused at first and didn't know if the lineplot was working at all.

@t20100
Copy link
Member

t20100 commented Jul 31, 2024

Thanks for opening the issue! It's the first time we hear about this issue.

I currently don't have much time to work on this project, but we'll figure out what is going wrong (It might take some time since we cannot reproduce it though).

I would still bet on an issue with sub-windows in your particular set-up:
The histogram uses a QWidget with flags=QtCore.Qt.Window while the profile uses a QMainWindow with flags=QtCore.Qt.Dialog.

Did you try with the latest PyQt5 and with PyQt6 and PySide6? Do you have the same issue?

Could you try this code? It's almost the same as the previous one, except for flags=QtCore.Qt.Dialog which I missed the first time I checked the profile code:

from PyQt5 import QtCore, QtGui, QtWidgets

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        btn = QtWidgets.QPushButton("Press")
        self.setCentralWidget(btn)
        btn.clicked.connect(self._clicked)

    def _clicked(self):
        print("new window")
        new_window = QtWidgets.QMainWindow(self, flags=QtCore.Qt.Dialog)
        new_window.show()

app = QtWidgets.QApplication([])

window = MainWindow()
window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
window.show()

app.exec()

You can also try patching silx by removing flags=QtCore.Qt.Dialog here:

qt.QMainWindow.__init__(self, parent=parent, flags=qt.Qt.Dialog)

@clemisch
Copy link
Author

clemisch commented Aug 4, 2024

Thanks for coming back on this.

Did you try with the latest PyQt5 and with PyQt6 and PySide6? Do you have the same issue?

Ha! It seems to work with pyqt6. I can either force it with ipython3 --gui=qt6, or I uninstall pyqt5, install pyqt6, and then silx view file uses qt6 (reported in Help-About).

I see no downside of switching my overall workflow to --gui=qt6.

The default of silx seems to be qt5, though? Installed with pipx, it uses pyqt5 by default.

Could you try this code? It's almost the same as the previous one, except for flags=QtCore.Qt.Dialog which I missed the first time I checked the profile code:

This code opens a new window on click. The previous version of it also worked though.

You can also try patching silx by removing flags=QtCore.Qt.Dialog here:

Curiously, this does not change anything. Qt5 doesn't work, Qt6 works.

@t20100
Copy link
Member

t20100 commented Aug 30, 2024

I see no downside of switching my overall workflow to --gui=qt6.

+1

The default of silx seems to be qt5, though?

Yes, installing silx[full] installs pyqt5 and it's been the main Qt binding in use (and tested) in the last years...

Qt5 has reaching the end of regular support and only receives updates under extended commercial support, so it's timely to consider switching the default to Qt6.

I'm worried it will be tedious to find a workaround for this issue with pyqt5 since we are not able to reproduce it.
So, if you can live with it until we switch to use qt6 (probably pyside6) by default, that would be great.

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

3 participants