libsurvive icon indicating copy to clipboard operation
libsurvive copied to clipboard

Fix infinite loop in vive driver usb shutdown

Open Peaj opened this issue 1 year ago • 2 comments

Fixes infinite loop during vive driver shutdown. survive_handle_close_request_flag in drive_vive.c never shutdown the usb connection because usbInfo.requestClose was never true.

I updated survive_close_usb_device to set the requestClose flag to true so survive_handle_close_request_flag can react to it and close the connection.

I am not 100% sure where this flag is supposed to be set but from my understanding survive_close_usb_device should be reasonable and so far the plugin seems to shutdown gracefully.

Fixes #312

Peaj avatar Sep 12 '24 11:09 Peaj

i am getting into the libusb-side of the implementation, where there is a check for active_transfers before setting request_close. i am still trying to figure out how the whole ecosystem works, so maybe original contributors can give us a better insight on how this was planned...

in driver_vive.libusb.h in survive_close_usb_device at line 300 you'll find (for your considering)

	if (usbInfo->active_transfers == 0) {
		usbInfo->request_close = true;
		SV_VERBOSE(100, "Acking close for %s", survive_colorize_codename(usbInfo->so));
	}

throni3git avatar Sep 12 '24 17:09 throni3git

I did not look at libusb yet as I was building with the default setting of HIDAPI. The libusb implementation could bring insights into how it should be handled though. But dirver_vive.hidapi.h is not using active_transfers at all. I am not even sure when to user libusb over hidapi. Is hidapi a windows only thing?

Peaj avatar Sep 19 '24 15:09 Peaj