Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions host/py_module/py_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ bool soft_deinit_device()

bool deinit_device()
{
#ifdef __APPLE__
_exit(0); //workaround for Xlink nullptr error on deinit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One downside is that it terminates the python script at depthai.deinit_device(): https://github.com/luxonis/depthai/blob/cad13e5/depthai.py#L571
(not a big issue in our case, but if the user adds some additional python code at the end, it won't run).

Would not calling deinit_device() work? (Probably not, if the crash happens in the C++ destructors.)

if platform.system() != 'Darwin':
    depthai.deinit_device()

Or exiting from the py script instead, at its end?

if platform.system() == 'Darwin':
    os._exit(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deinit_device() is called on exit, it's added to :

    auto cleanup_callback = []() {
        deinit_device();
    };

So the only way is calling _exit either from python, or lib.
First I gave a workaround on slack, calling _exit from script, but wasn't merged, so I put in lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watchdog works, which calls the same destructor in Xlink, the difference is that when watchdog gets triggered, USB is disconnected (device reboots), we could try libusb_detach_kernel_driver before libusb_close, I just don't have the resources currently to debug this issue.

#endif
wdog_stop();
g_xlink = nullptr;
g_disparity_post_proc = nullptr;
Expand Down