Skip to content

Conversation

@SzabolcsGergely
Copy link
Contributor

This is a temporary workaround for crash on MacOS in Xlink, on deinit.
Let the OS take care of resource deallocation.

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.

Copy link
Contributor

@Luxonis-Brandon Luxonis-Brandon left a comment

Choose a reason for hiding this comment

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

Oh I meant to circle back that this works for me on Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants