ANP-Granular / ParticleTracking

Library and GUI for tracking (rod-like) particles on camera images in 2D and 3D
https://particletracking.readthedocs.io/en/latest/
GNU General Public License v3.0
2 stars 2 forks source link

Crashes on Windows when updating plots #98

Open dmitrypuzyrev opened 4 weeks ago

dmitrypuzyrev commented 4 weeks ago

Describe the bug The program always crashes when clicking 3D Reconstruct -> Update plots button, if any 3D data is present (i.e. data with 3D coordinates loaded from .csv, or new 3D reconstruction performed). Seems to be a problem with 2D plots, the 3D-view works fine.

To Reproduce Steps to reproduce the behavior:

  1. Fresh install (on new conda/venv environment, Python 3.10,3.11, 3.12 tested)
  2. Load example images
  3. Load example data
  4. 3D Reconstruct -> Update plots - Crash without any error message

Expected behavior Should show/update 2D plots.

Screenshots

Desktop (please complete the following information):

Logs No error messages / entries in logfile are produced

a-niem commented 4 weeks ago

I've attempted to recreate the issue described by you @dmitrypuzyrev with Windows 11, NVIDIA graphics hardware and all three python versions. However, the issue does not occur for me at all. All plots are generated correctly. Maybe an important feature of your system description or a step necessary for reproduction is missing.

dmitrypuzyrev commented 3 weeks ago

I have checked it on the laptop with Win11/Intel internal graphics too, same problem. No problem on a Linux PC though.

Some debugging leads to a fact that it always crashes during the first call of fig = plt.figure() in \ParticleDetection\reconstruct_3D\visualization.py (so it does not depend on the data passed to the plotting functions). No exceptions are produced, only the warning message:

[08/18 18:02:50] py.warnings WARNING: C:\prog\Anaconda3\envs\rodtracker2\lib\site-packages\ParticleDetection\reconstruct_3D\visualization.py:238: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail. fig = plt.figure()

which is disabled by default. My vague idea is: I tried to search something about similar error and only undestood that in general interactive plotting is not supposed to be done directly outside of main thread while QtAgg is not thread-safe. I guess there is already a workaround implemented when "Plotter" thread just generates figure and passes it as a signal, but does not actually show the plot. However, "plt.figure()" might not behave as intended here (tries to show something immediately even in non-interactive mode or something like that?) and produces crashes. It also works without problem on Linux and @a-niem Windows PC for some reason.