ftc265 icon indicating copy to clipboard operation
ftc265 copied to clipboard

Grant USB permissions in constructor

Open chop0 opened this issue 4 years ago • 3 comments

chop0 avatar Jan 11 '21 04:01 chop0

Hi. Thanks for the PR! grantUsbPermissionsIfNeeded is supposed to get called in the librealsense onDeviceAttach method. Is that not happening for you? Could you describe the specific bug that this fixes? It's very possible that my mental model of the current behavior is wrong and that this fixes a bug I haven't seen, but it would be nice to get some more context before I merge this.

pietroglyph avatar Jan 11 '21 04:01 pietroglyph

Hmm, I'm actually not sure. What I thought before is below, however I just noticed that ON_DEVICE_AVAILABLE is only broadcast after USB permissions are requested. The bug itself occurred when a T265 camera was plugged into the REV hub before the app started. This led to the camera's pointer being null and a "No camera found" exception being raised.

I found that sometimes the check for already connected devices is run before Enumerator's permission check, due to a race condition image It seems as though USB_CONTROL_PERMISSION is called after "Setting device callback" is printed, which means that the check for already connected devices likely was called before USB permission was acquired. queryDevices fails silently, returning no devices, and as a result, onDeviceAttach is not called.

chop0 avatar Jan 11 '21 07:01 chop0

Yep, that seems like the right analysis. I've been aware of the issue for a while, but I didn't have access to hardware to test with (and I was a bit busy.) An adaptor I need comes Tuesday, so I should be able to try and reproduce this and fix it around then. If I can't reproduce it on my hardware (I have a phone, not a Control Hub) then I'll go off of what I have here and try and fix it.

pietroglyph avatar Jan 11 '21 07:01 pietroglyph