fix(viz): potential deadlock in extrusion tool
Description
Follow-up on the discussion below (!916 (merged)).
-
@eduhamel started a discussion: (+3 comments) Since this is more related to the implementation, I'll comment here rather than on the issue.
Currently, spamming "Remove last extrusion" button makes the app freeze when there are "too" many ones. On my computer, the threshold is 8 for a
512
x512
122
volume.I suspect we had the same behaviour before. This looks like a deadlock occurring due to the computations not being done fast enough:
- First click, ask for re-computation of the mask.
- Lock the data.
- Compute (takes some time)...
- Second click.
- Data cannot be locked. Deadlock.
- First click, ask for re-computation of the mask.
Amendment: this is sometimes much more than 8. This depends on the size of the extrusion.
Here's a small video of what happens (not very interesting).
Note: commit SHA 44a9dfbc
Steps to reproduce
- Launch Sight Viewer.
- Load a volume.
- Make many extrusions of various sizes (big ones if possible).
- Spam the "Cancel last extrusion button".
- If you're (un)lucky enough, you will get a deadlock.
Proposal
As stated in the description, I suspect this is due to the computations taking too much time, causing a lock on the data when it is still locked by something else.
So maybe we should add a bool m_computing;
in the service, and don't proceed to recompute the volume when it is true
?
Functional specifications
No deadlock possible.
Technical specifications
Details of the implementation of the fix
Test plan
Describe how you will verify that the implementation fulfils the specifications