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

Error when closing InVesalius with Debug tracker approach #775

Open
vhosouza opened this issue May 22, 2024 · 3 comments
Open

Error when closing InVesalius with Debug tracker approach #775

vhosouza opened this issue May 22, 2024 · 3 comments
Assignees
Labels
bug neuronavigation Issues related to neuronavigation software

Comments

@vhosouza
Copy link
Member

The following error is raised when closing invesalius after Debug tracker approach is selected. To reproduce, follow the steps:

  1. Open a new instance of invesalius
  2. Open a NIFTI image
  3. Preferences > Tracker > Select Debug tracker approach
  4. Close invesalius without saving the state

Possible solution: It seems that the tracker connection is not closed before closing invesalius, which may cause the ReceiveCoordinates to expect coordinates. Fixing the closing of tracker might fix the problem.

The following error message appears:

Successfully deleted state file.
Exception in thread ReceiveCoordinates:
Traceback (most recent call last):
  File "/Users/***/anaconda3/envs/invesalius/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/Users/***/repository/invesalius3/invesalius/data/coordinates.py", line 628, in run
    success = self.TrackerCoordinates.SetCoordinates(coord_raw, marker_visibilities)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/repository/invesalius3/invesalius/data/coordinates.py", line 72, in SetCoordinates
    wx.CallAfter(Publisher.sendMessage, 'From Neuronavigation: Update tracker poses',
  File "/Users/***/anaconda3/envs/invesalius/lib/python3.11/site-packages/wx/core.py", line 3422, in CallAfter
    assert app is not None, 'No wx.App created yet'
           ^^^^^^^^^^^^^^^
AssertionError: No wx.App created yet
@vhosouza vhosouza added bug neuronavigation Issues related to neuronavigation software labels May 22, 2024
@Rakhesis
Copy link
Collaborator

  • Error is caused by attempting to call wx.CallAfter during the exiting process after the GUI has been destroyed.
  • Error appears whether one saves the state or not.
  • Error appeared recently, since previously invesalius crashed on exit due to memory leakage during GUI destruction, but this error could have been introduced to the codebase a while ago.

I also get this error on exit:
image

@okahilak
Copy link
Collaborator

Here's the result of git bisect, showing the offending commit:

db8b255ccd0b8981b9400ea5269b9cfa4e73321f is the first bad commit
commit db8b255ccd0b8981b9400ea5269b9cfa4e73321f
Author: Rakhesis <[email protected]>
Date:   Mon May 6 20:31:28 2024 +0300

    FIX: Crash on turning off navigation mode

    Same wx.ToolTip object was connected to multiple wx.TextCtrl objects in two places. This seems to cause a double free memory leak, as the program tries to free the wx.ToolTip alongside both of the wx.TextCtrl objects.

 invesalius/gui/task_efield.py    | 12 ++++++------
 invesalius/gui/task_navigator.py |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

@okahilak
Copy link
Collaborator

Never mind about my previous comment; it turns out that that change uncovered some previously existing problems, so that commit is not the original source of the issue - it might indeed be one of my previous commits. We decided that @Rakhesis will look into it with some priority. Thanks, @Rakhesis!

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

No branches or pull requests

3 participants