driver_vive: fix infinite loop when closing HIDAPI devices - #369
Closed
m-va wants to merge 1 commit into
Closed
Conversation
survive_vive_close() waits for every device to raise request_close, but the HIDAPI backend only ever sets that flag from HAPIReceiver() when hid_read() fails. survive_close_usb_device() closes the HID handles without setting it, so the wait loop never terminates. The libusb backend does not hit this because libusb_handle_events() drives the transfer-completion callbacks that raise the flag, and that call is compiled out under HIDAPI. Set the flag when the device is closed. This also lets survive_close() reach config_save(), so lighthouse calibration is persisted again instead of being lost on every run. Tested on Windows 11 x64 (MSVC, USE_HIDAPI=ON) with two Vive Trackers (2018) over USB and SteamVR 2.0 base stations: survive_simple_close() goes from never returning to completing immediately, and config.json gets its lighthouse0/1 entries so calibration survives a restart. Fixes #312
Collaborator
|
Why was this closed @m-va ? |
Author
|
Sorry for the confusion — this was my mistake. I deleted my fork because I Since the head repository is gone this PR can't be reopened, so I've re-forked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #312.
Problem
On Windows,
USE_HIDAPIdefaults toON, andsurvive_vive_close()neverreturns:
survive_handle_close_request_flag()only acts whenusbInfo->request_closeis set. In the HIDAPI backend that flag is raised only in
HAPIReceiver()whenhid_read()returns a negative value;survive_close_usb_device()closes theHID handles without setting it. The libusb backend is unaffected because
libusb_handle_events()drives the completion callbacks that raise the flag,and that call is
#ifndef HIDAPI.Besides hanging the process, this also means
config_save()— which runs laterinside
survive_close()— is never reached, so lighthouse calibration is neverwritten to
config.jsonand has to be redone on every launch.Fix
Raise the flag (and mark the interfaces shut down, mirroring the libusb path)
when the device is actually closed. Freeing the handle there is safe because
survive_usb_handle_close()is a no-op in this backend.Testing
Windows 11 x64, MSVC, master,
USE_HIDAPI=ON, two Vive Trackers (2018) overUSB with SteamVR 2.0 base stations:
survive_simple_close()did not return after 60 s;config.jsonnever contained
lighthouse0/lighthouse1config.jsongets the lighthouse entries,so a second launch starts tracking without recalibrating