spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.32k stars 1.61k forks source link

Spyder under WSL2 loss of mouse click ability (corruption of transient.ini file??) #20851

Closed clayjstanek closed 1 month ago

clayjstanek commented 1 year ago

Issue Report Checklist

Problem Description

I've just purchased a high end HP Omen with an RTX 4080 GPU and 32 GB RAM and 2 TB SSD with i9 CPU and am having a real problem debugging a Spyder issue when running it on the Ubuntu side of my installation. I am NOT trying to run a spyder kernel from Ubuntu in a Spyder instantiation on Windows, everything is straight-up on Ubuntu side.

Ultimately, the Spyder GUI does not allow me to click anywhere in the display. All the keyboard shortcuts do work and mouse movement works.

What steps reproduce the problem?

  1. Do a spyder --reset and start. Everything works properly.
  2. Set up preferences like changing to Spyder light display preferences and Spyder asks to restart.
  3. Upon next start, window comes up offset a bit down and to the right, making the 'x' on the top right of window not visible. At this point, one can click within the GUI, but the cursor click and what it activates are off a fixed number of pixels down and to the right. If I had to guess, the offset for this effect is equal to the amount the main window initially comes up offset in my laptop screen.
  4. CRTL-Q to kill Spyder, Ubuntu prompt shows Spyder exits with segmentation fault
  5. Restart Spyder, no mouse clicking capability at all, but window still comes up offset as in step 3.
  6. repeat step 1 to get a functioning console back

What is the expected output? What do you see instead?

I would expect spyder to open where it was closed in step 2 of setting preferences and the mouse clicking to activate on top of the item it is over, not offset by a set number of pixels down and to the right. And I certainly don't expect to lose all mouse clicking functionality when restarting a second time.

Paste Traceback/Error Below (if applicable)


PASTE TRACEBACK HERE
Got keys from plugin meta data ("webp")
QFactoryLoader::QFactoryLoader() checking directory path "/home/cstanek/anaconda3/envs/plotting/bin/imageformats" ...
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqgif.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqicns.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqico.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqjpeg.so"
fromIccProfile: failed minimal tag size sanity
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqpdf.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqsvg.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqtga.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqtiff.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqwbmp.so"
loaded library "/home/cstanek/anaconda3/envs/plotting/plugins/imageformats/libqwebp.so"
QFactoryLoader::QFactoryLoader() checking directory path "/home/cstanek/anaconda3/envs/plotting/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/home/cstanek/anaconda3/envs/plotting/bin/accessible" ...
QGLXContext: Failed to create dummy context

#####  CTRL-Q here ######
[1]+  Segmentation fault      spyder

Versions

Dependencies

``` PASTE DEPENDENCIES HERE _libgcc_mutex 0.1 main _openmp_mutex 5.1 1_gnu alabaster 0.7.12 pyhd3eb1b0_0 appdirs 1.4.4 pyhd3eb1b0_0 arrow 1.2.3 py39h06a4308_1 astroid 2.14.2 py39h06a4308_0 asttokens 2.0.5 pyhd3eb1b0_0 atomicwrites 1.4.0 py_0 attrs 22.1.0 py39h06a4308_0 autopep8 1.6.0 pyhd3eb1b0_1 babel 2.11.0 py39h06a4308_0 backcall 0.2.0 pyhd3eb1b0_0 beautifulsoup4 4.12.2 py39h06a4308_0 binaryornot 0.4.4 pyhd3eb1b0_1 black 22.3.0 pypi_0 pypi blas 1.0 mkl bleach 4.1.0 pyhd3eb1b0_0 bottleneck 1.3.5 py39h7deecbd_0 brotli 1.0.9 h5eee18b_7 brotli-bin 1.0.9 h5eee18b_7 brotlipy 0.7.0 py39h27cfd23_1003 ca-certificates 2023.01.10 h06a4308_0 certifi 2022.12.7 py39h06a4308_0 cffi 1.15.1 py39h5eee18b_3 chardet 4.0.0 py39h06a4308_1003 charset-normalizer 2.0.4 pyhd3eb1b0_0 click 8.0.4 py39h06a4308_0 cloudpickle 2.0.0 pyhd3eb1b0_0 colorama 0.4.6 py39h06a4308_0 comm 0.1.2 py39h06a4308_0 contourpy 1.0.5 py39hdb19cb5_0 cookiecutter 1.7.3 pyhd3eb1b0_0 cryptography 39.0.1 py39h9ce1e76_0 cycler 0.11.0 pyhd3eb1b0_0 dbus 1.13.18 hb2f20db_0 debugpy 1.5.1 py39h295c915_0 decorator 5.1.1 pyhd3eb1b0_0 defusedxml 0.7.1 pyhd3eb1b0_0 diff-match-patch 20200713 pyhd3eb1b0_0 dill 0.3.6 py39h06a4308_0 docstring-to-markdown 0.11 py39h06a4308_0 docutils 0.18.1 py39h06a4308_3 entrypoints 0.4 py39h06a4308_0 executing 0.8.3 pyhd3eb1b0_0 expat 2.4.9 h6a678d5_0 flake8 6.0.0 py39h06a4308_0 flit-core 3.8.0 py39h06a4308_0 fontconfig 2.14.1 h4c34cd2_2 fonttools 4.25.0 pyhd3eb1b0_0 freetype 2.12.1 h4a9f257_0 giflib 5.2.1 h5eee18b_3 glib 2.69.1 he621ea3_2 gmp 6.2.1 h295c915_3 gmpy2 2.1.2 py39heeb90bb_0 gst-plugins-base 1.14.1 h6a678d5_1 gstreamer 1.14.1 h5eee18b_1 icu 58.2 he6710b0_3 idna 3.4 py39h06a4308_0 imagesize 1.4.1 py39h06a4308_0 importlib-metadata 6.0.0 py39h06a4308_0 importlib_metadata 6.0.0 hd3eb1b0_0 importlib_resources 5.2.0 pyhd3eb1b0_1 inflection 0.5.1 py39h06a4308_0 intel-openmp 2021.4.0 h06a4308_3561 intervaltree 3.1.0 pyhd3eb1b0_0 ipykernel 6.19.2 py39hb070fc8_0 ipython 8.12.0 py39h06a4308_0 ipython_genutils 0.2.0 pyhd3eb1b0_1 isort 5.9.3 pyhd3eb1b0_0 jaraco.classes 3.2.1 pyhd3eb1b0_0 jedi 0.18.1 py39h06a4308_1 jeepney 0.7.1 pyhd3eb1b0_0 jellyfish 0.9.0 py39h7f8727e_0 jinja2 3.1.2 py39h06a4308_0 jinja2-time 0.2.0 pyhd3eb1b0_3 jpeg 9e h5eee18b_1 jsonschema 4.17.3 py39h06a4308_0 jupyter_client 8.1.0 py39h06a4308_0 jupyter_core 5.3.0 py39h06a4308_0 jupyterlab_pygments 0.1.2 py_0 keyring 23.13.1 py39h06a4308_0 kiwisolver 1.4.4 py39h6a678d5_0 krb5 1.19.4 h568e23c_0 lazy-object-proxy 1.6.0 py39h27cfd23_0 lcms2 2.12 h3be6417_0 ld_impl_linux-64 2.38 h1181459_1 lerc 3.0 h295c915_0 libbrotlicommon 1.0.9 h5eee18b_7 libbrotlidec 1.0.9 h5eee18b_7 libbrotlienc 1.0.9 h5eee18b_7 libclang 14.0.6 default_hc6dbbc7_1 libclang13 14.0.6 default_he11475f_1 libdeflate 1.17 h5eee18b_0 libedit 3.1.20221030 h5eee18b_0 libevent 2.1.12 h8f2d780_0 libffi 3.4.2 h6a678d5_6 libgcc-ng 11.2.0 h1234567_1 libgfortran-ng 11.2.0 h00389a5_1 libgfortran5 11.2.0 h1234567_1 libgomp 11.2.0 h1234567_1 libllvm14 14.0.6 hdb19cb5_2 libpng 1.6.39 h5eee18b_0 libpq 12.9 h16c4e8d_3 libsodium 1.0.18 h7b6447c_0 libspatialindex 1.9.3 h2531618_0 libstdcxx-ng 11.2.0 h1234567_1 libtiff 4.5.0 h6a678d5_2 libuuid 1.41.5 h5eee18b_0 libwebp 1.2.4 h11a3e52_1 libwebp-base 1.2.4 h5eee18b_1 libxcb 1.15 h7f8727e_0 libxkbcommon 1.0.1 h5eee18b_1 libxml2 2.10.3 hcbfbd50_0 libxslt 1.1.37 h2085143_0 lxml 4.9.2 py39h5eee18b_0 lz4-c 1.9.4 h6a678d5_0 markupsafe 2.1.1 py39h7f8727e_0 matplotlib 3.7.1 py39h06a4308_1 matplotlib-base 3.7.1 py39h417a72b_1 matplotlib-inline 0.1.6 py39h06a4308_0 matplotx 0.3.10 pypi_0 pypi mccabe 0.7.0 pyhd3eb1b0_0 mistune 0.8.4 py39h27cfd23_1000 mkl 2021.4.0 h06a4308_640 mkl-service 2.4.0 py39h7f8727e_0 mkl_fft 1.3.1 py39hd3c417c_0 mkl_random 1.2.2 py39h51133e4_0 more-itertools 8.12.0 pyhd3eb1b0_0 mpc 1.1.0 h10f8cd9_1 mpfr 4.0.2 hb69a4c5_1 mplcyberpunk 0.6.0 pypi_0 pypi mpmath 1.2.1 py39h06a4308_0 munkres 1.1.4 py_0 mypy_extensions 0.4.3 py39h06a4308_1 nbclient 0.5.13 py39h06a4308_0 nbconvert 6.5.4 py39h06a4308_0 nbformat 5.7.0 py39h06a4308_0 ncurses 6.4 h6a678d5_0 nest-asyncio 1.5.6 py39h06a4308_0 nspr 4.33 h295c915_0 nss 3.74 h0370c37_0 numexpr 2.8.4 py39he184ba9_0 numpy 1.23.5 py39h14f4228_0 numpy-base 1.23.5 py39h31eccc5_0 numpydoc 1.5.0 py39h06a4308_0 openssl 1.1.1t h7f8727e_0 packaging 23.0 py39h06a4308_0 pandas 1.5.3 py39h417a72b_0 pandocfilters 1.5.0 pyhd3eb1b0_0 parso 0.8.3 pyhd3eb1b0_0 pathspec 0.10.3 py39h06a4308_0 patsy 0.5.3 py39h06a4308_0 pcre 8.45 h295c915_0 pexpect 4.8.0 pyhd3eb1b0_3 pickleshare 0.7.5 pyhd3eb1b0_1003 pillow 9.4.0 py39h6a678d5_0 pip 23.0.1 py39h06a4308_0 platformdirs 2.5.2 py39h06a4308_0 pluggy 1.0.0 py39h06a4308_1 ply 3.11 py39h06a4308_0 pooch 1.4.0 pyhd3eb1b0_0 poyo 0.5.0 pyhd3eb1b0_0 prompt-toolkit 3.0.36 py39h06a4308_0 psutil 5.9.0 py39h5eee18b_0 ptyprocess 0.7.0 pyhd3eb1b0_2 pure_eval 0.2.2 pyhd3eb1b0_0 pycodestyle 2.10.0 py39h06a4308_0 pycparser 2.21 pyhd3eb1b0_0 pydocstyle 6.3.0 py39h06a4308_0 pyflakes 3.0.1 py39h06a4308_0 pygments 2.11.2 pyhd3eb1b0_0 pylint 2.16.2 py39h06a4308_0 pylint-venv 2.3.0 py39h06a4308_0 pyls-spyder 0.4.0 pyhd3eb1b0_0 pyopenssl 23.0.0 py39h06a4308_0 pyparsing 3.0.9 py39h06a4308_0 pyqt 5.15.7 py39h6a678d5_1 pyqt5-sip 12.11.0 py39h6a678d5_1 pyqtwebengine 5.15.7 py39h6a678d5_1 pyrsistent 0.18.0 py39heee7806_0 pysocks 1.7.1 py39h06a4308_0 python 3.9.16 h7a1cb2a_2 python-dateutil 2.8.2 pyhd3eb1b0_0 python-fastjsonschema 2.16.2 py39h06a4308_0 python-lsp-black 1.2.1 py39h06a4308_0 python-lsp-jsonrpc 1.0.0 pyhd3eb1b0_0 python-lsp-server 1.7.2 pypi_0 pypi python-slugify 5.0.2 pyhd3eb1b0_0 pytoolconfig 1.2.5 py39h06a4308_1 pytz 2022.7 py39h06a4308_0 pyxdg 0.27 pyhd3eb1b0_0 pyyaml 6.0 py39h5eee18b_1 pyzmq 23.2.0 py39h6a678d5_0 qbstyles 0.1.4 pypi_0 pypi qdarkstyle 3.0.2 pyhd3eb1b0_0 qstylizer 0.2.2 py39h06a4308_0 qt-main 5.15.2 h8373d8f_8 qt-webengine 5.15.9 hbbf29b9_6 qtawesome 1.2.2 py39h06a4308_0 qtconsole 5.4.2 py39h06a4308_0 qtpy 2.2.0 py39h06a4308_0 qtwebkit 5.212 h3fafdc1_5 readline 8.2 h5eee18b_0 requests 2.28.1 py39h06a4308_1 rope 1.7.0 py39h06a4308_0 rtree 1.0.1 py39h06a4308_0 scienceplots 2.0.1 pypi_0 pypi scipy 1.10.1 py39h14f4228_0 seaborn 0.12.2 py39h06a4308_0 secretstorage 3.3.1 py39h06a4308_1 setuptools 66.0.0 py39h06a4308_0 sip 6.6.2 py39h6a678d5_0 six 1.16.0 pyhd3eb1b0_1 snowballstemmer 2.2.0 pyhd3eb1b0_0 sortedcontainers 2.4.0 pyhd3eb1b0_0 soupsieve 2.4 py39h06a4308_0 sphinx 5.0.2 py39h06a4308_0 sphinxcontrib-applehelp 1.0.2 pyhd3eb1b0_0 sphinxcontrib-devhelp 1.0.2 pyhd3eb1b0_0 sphinxcontrib-htmlhelp 2.0.0 pyhd3eb1b0_0 sphinxcontrib-jsmath 1.0.1 pyhd3eb1b0_0 sphinxcontrib-qthelp 1.0.3 pyhd3eb1b0_0 sphinxcontrib-serializinghtml 1.1.5 pyhd3eb1b0_0 spyder 5.4.3 py39h06a4308_0 spyder-kernels 2.4.3 py39h06a4308_0 sqlite 3.41.2 h5eee18b_0 stack_data 0.2.0 pyhd3eb1b0_0 statsmodels 0.13.5 py39h7deecbd_1 sympy 1.11.1 py39h06a4308_0 text-unidecode 1.3 pyhd3eb1b0_0 textdistance 4.2.1 pyhd3eb1b0_0 three-merge 0.1.1 pyhd3eb1b0_0 tinycss2 1.2.1 py39h06a4308_0 tk 8.6.12 h1ccaba5_0 toml 0.10.2 pyhd3eb1b0_0 tomli 2.0.1 py39h06a4308_0 tomlkit 0.11.1 py39h06a4308_0 tornado 6.2 py39h5eee18b_0 traitlets 5.7.1 py39h06a4308_0 typing-extensions 4.4.0 py39h06a4308_0 typing_extensions 4.4.0 py39h06a4308_0 tzdata 2023c h04d1e81_0 ujson 5.4.0 py39h6a678d5_0 unidecode 1.2.0 pyhd3eb1b0_0 urllib3 1.26.15 py39h06a4308_0 watchdog 2.1.6 py39h06a4308_0 wcwidth 0.2.5 pyhd3eb1b0_0 webencodings 0.5.1 py39h06a4308_1 whatthepatch 1.0.2 py39h06a4308_0 wheel 0.38.4 py39h06a4308_0 wrapt 1.14.1 py39h5eee18b_0 wurlitzer 3.0.2 py39h06a4308_0 xz 5.2.10 h5eee18b_1 yaml 0.2.5 h7b6447c_0 yapf 0.31.0 pyhd3eb1b0_0 zeromq 4.3.4 h2531618_0 zipp 3.11.0 py39h06a4308_0 zlib 1.2.13 h5eee18b_0 zstd 1.5.5 hc292b87_0``` ```
dalthviz commented 1 year ago

Hi @clayjstanek thank you for the feedback! Could it be possible for you to check if running Spyder with the --no-web-widgets helps? Not totally sure what could be happening here but the QGLXContext message there points to some kind of issue with OpenGL and in the past I think some of those issue have been related with QtWebEngine based widgets.

Let us know if the info above helps!

aabdulaal commented 1 year ago

I have the exact same problem and no, --no-web-widgets doesn't help. Only --reset before each new start helps. I am also running spyder 5.4.3 on Ubunto 22.04 with WSL2.

dalthviz commented 1 year ago

Thank you for trying the flag @aabdulaal ! Could you then try to run spyder with the --safe-mode flag? That launches Spyder always with default non-persistent config. Maybe the problem comes from the code that loads the window state saved when closing Spyder? :thinking:

Could it be possible for you to change this part of the Spyder code:

https://github.com/spyder-ide/spyder/blob/11dee3c39b181e1a1b03f04b6fdee1777352db25/spyder/plugins/layout/plugin.py#L546-L549

To be something like:

hexstate_valid = False

Let us know if something of the above helps!

aabdulaal commented 1 year ago

@dalthviz I edited plugin.py as you suggested and it appears to have prevented the problem for me. I've started it multiple times since the edit without problems.

ccordoba12 commented 1 year ago

@dalthviz, what should we do about this one?

dalthviz commented 1 year ago

Not sure if there is a way to try the code without it ending in a segmentation fault. Maybe adding an option to prevent saving the hex state or using it could help this specific setup (Spyder + WSL2). Also, not sure why this is happening, maybe is a more general issue/incompatibility between the display system WSL2 uses and Qt? 🤔

ccordoba12 commented 1 year ago

Perhaps we can validate if the hex state is valid before trying to load it? I don't know if that's possible though.

JC-NH commented 11 months ago

I have a similar issue. I am running:

under WSL2:

WSL version: 2.0.9.0 Kernel version: 5.15.133.1-1 WSLg version: 1.0.59 MSRDC version: 1.2.4677 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22631.2715

When I initiate Spyder (Spyder --reset) everything works fine.

On a second start, just calling Spyder, I usually get mouse control but everything is shifted by a couple lines. (I have to click above the line and to the left of anything I want to highlight).

On subsequent startups I lose all mouse control and need to use keyboard shortcuts to function.

I have recently tried calling 'Spyder --no-web-widgets' and this seems to have corrected the issue for me (calling Spyder without qualifiers). However, I do get the warning:

QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700 fromIccProfile: failed minimal tag size sanity

but it does not seem to effect the usage of spyder.

ccordoba12 commented 11 months ago

I have recently tried calling 'Spyder --no-web-widgets' and this seems to have corrected the issue for me (calling Spyder without qualifiers).

That's great! Thanks for letting us know about it.

However, I do get the warning:

QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700 fromIccProfile: failed minimal tag size sanity

but it does not seem to effect the usage of spyder.

Don't worry, those are harmless warnings.

patoorio commented 7 months ago

Hello,

I am running

under WSL: Versión de WSL: 2.1.5.0 Versión de kernel: 5.15.146.1-2 Versión de WSLg: 1.0.60 Versión de MSRDC: 1.2.5105 Versión de Direct3D: 1.611.1-81528511 Versión DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Versión de Windows: 10.0.22631.3374

And I have the same problem reported by JC-NH: When I initiate Spyder (Spyder --reset) everything works fine. On a second start, just calling Spyder, I usually get mouse control but everything is shifted by a couple lines. (I have to click above the line and to the left of anything I want to highlight). On subsequent startups I lose all mouse control and need to use keyboard shortcuts to function. Only way to close it is Alt-F4

HOWEVER, in my case calling 'spyder --no-web-widgets' does not solve the problem. The only way is --reset (and lose all config)

UPDATE: Now even after doing "spyder --reset", the issue of the shifted cursor behavior appears at first run.

UPDATE2: The issue of the mouse control being shifted more or less two lines, only happens in the main spyder window. If I open another window such as Preferences or 'Open File', inside that one the mouse and cursor behave normally.

patoorio commented 7 months ago

I found what seems to be a good workaround. And maybe a clue? Once Spyder starts correctly (after a 'spyder --reset'; actually, deleting ~/.config/spyder-py3/config/transient.ini seems to be enough... sometimes) restore the main Spyder window (i.e. 'un-maximize' it). Don't work in a maximized window. Make it as big as you want (or can), but don't maximize it. For me, this prevented the issue. I can close and open again Spyder within WSL, without losing any setting nor file history. I don't have to --reset again.

I hope this is useful.

UPDATE:

Zybulon commented 1 month ago

Hello,

I have the same issue. Based on the solution of #12367 , I "fixed" it by adding the following alias to my .bashrc

alias spyder="sed -i '/window\/position = (.*)/c\window/position = (0,0)' ~/.config/spyder-py3/config/transient.ini ; spyder "
ccordoba12 commented 1 month ago

@Zybulon, thanks for the confirmation. Could you post the value (or values) of window/position in ~/.config/spyder-py3/config/transient.ini without that alias?

According to https://github.com/spyder-ide/spyder/issues/12367#issuecomment-1925283032, it seems the problem is we're trying to save negative values for that setting. And that should be an easy fix.

Zybulon commented 1 month ago

Without that alias the values were exactly the same negative values : (-32, -32). I have the issue on WSL2 with spyder 6.

ccordoba12 commented 1 month ago

Thanks for the extra info @Zybulon!

Could you apply the small patch I added in PR #22549 and let us know if it solves the problem for you? Thanks!

Zybulon commented 1 month ago

It works perfectly, thanks for you reactivity !

ccordoba12 commented 1 month ago

That's great! Thanks for your help too.

I'll include that in 6.0.1 then, to be released tomorrow.