open-ephys / Bonsai.ONIX

Bonsai library for Open Neuro Interface Compliant hardware with a focus on the ONIX System
https://open-ephys.github.io/onix-docs/index.html#
MIT License
1 stars 3 forks source link

Stopping Bonsai workflow sometimes leaves hardware in bad state #11

Open jonnew opened 2 years ago

jonnew commented 2 years ago

Occasionally, when a workflow with ONIX hardware is stopped, it leaves hardware in a deadlocked state. Trying to run the workflow again will not work. Any new hubs attached to the host will not be discovered. When the hardware is in this state running the simple C test program (https://github.com/open-ephys/liboni/blob/main/api/liboni/liboni-test/host.c) will return the hardware to normal.

aacuevas commented 2 years ago

Does closing bonsai and opening it again solve the issue as well? Context creation performs a hardware reset, which is true for both bonsai and the C program.

I have observed a similar issue in the past in which the Bonsai context got deadlocked at disposal time, usually due to some lock or race condition. Since the context was never disposed, any attempt to get a new context from the manager would just return the existing one which, being locked, wasn't able to perform any meaningful function.

I suspect this might be the case. I removed some conditions that led to this issue, but there might be more.

jonnew commented 2 years ago

RE: restarting bonsai: I need to encounter the full bug again to give an honest report. But, my recollection is that in some cases, no. There is something "magic" about the C program that really resets everything properly.