Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when shutting down vive driver #312

Open
Peaj opened this issue Sep 6, 2024 · 0 comments · May be fixed by #313
Open

Infinite loop when shutting down vive driver #312

Peaj opened this issue Sep 6, 2024 · 0 comments · May be fixed by #313

Comments

@Peaj
Copy link

Peaj commented Sep 6, 2024

Describe the bug
When closing libsurvive by stopping Unitys playmode it freezes during survive_vive_close() call.

The survive_vive_close() function is stuck in an infinite loop as it is waiting for survive_handle_close_request_flag() to close the USB connection which it never does because usbInfo->request_close is never true.

Desktop (please complete the following information):

  • OS: Windows
  • Version 11

Additional context
I tried to figure out where the request_close is supposed to be set to true but I could not figure it out yet.
I guess it is supposed to be set from another thread?

int survive_vive_close(SurviveContext *ctx, void *driver) {
	SurviveViveData *sv = driver;
#ifndef HIDAPI
	libusb_hotplug_deregister_callback(sv->usbctx, sv->callback_handle);
#endif
	for (int i = 0; i < sv->udev_cnt; i++) {
		survive_close_usb_device(sv->udev[i]);
	}
	while (sv->udev_cnt) { // never gets to 0
#ifndef HIDAPI
		survive_release_ctx_lock(ctx);
		libusb_handle_events(sv->usbctx);
		survive_get_ctx_lock(ctx);
#endif
		for (int i = 0; i < sv->udev_cnt; i++) {
			struct SurviveUSBInfo *usbInfo = sv->udev[i];
			if (survive_handle_close_request_flag(usbInfo)) { //never returns true as 'usbInfo->request_close' is always false
				i--;
			}
		}
	}
	survive_vive_usb_close(sv);
	free(sv);
	return 0;
}
@Peaj Peaj linked a pull request Sep 12, 2024 that will close this issue
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 a pull request may close this issue.

1 participant