Ticket #139 (closed defect: fixed)
Opened 11 months ago
Last modified 5 weeks ago
libusb 1.0.9 on Mac OS X keyboard and mouse blocked
| Reported by: | karthiga | Owned by: | hjelmn |
|---|---|---|---|
| Milestone: | libusb/libusbx 1.2.0 | Component: | libusb-1.0 Darwin backend |
| Keywords: | Cc: | ||
| Blocked By: | Blocks: |
Description
Hello,
I am a new bee as MAC OS X developer.
Currently, i use libusb-1.0.9.
When my application is launched, it looks for devices attached. Until i found my device, a thread periodically, call usb_find_devices() and check if our device is in the device list found.
When my device is not plugged and the application is working, after a while the MAC OS X (version 10.6.8) keyboard and mouse does not working. and Sometimes it crashes libusb_unref_device at usbi_mutex_lock(&dev->ctx->usb_devs_lock) with EXC_BAD_ACCESS.
Could you please help me to understand why this happens?Have you got any idea?
Change History
comment:1 Changed 11 months ago by xiaofan
comment:2 Changed 11 months ago by xiaofan
This may have something to do with this discussion.
http://libusb.6.n5.nabble.com/OSX-critical-bug-td4576409.html
comment:3 Changed 11 months ago by karthiga
Hello,
Thanks for your reply. I already see this discussion at this link http://libusb.6.n5.nabble.com/OSX-critical-bug-td4576409.html here but i do not understand how solves this problem?
By the way, i manage to solve the crash issue. It was due to the usb_init() et usb_deinit() several times. So now i change my code to call init() only one time at beginning (just after libusb loading) and to deinit just before libusb unloding.
But the keyborad and mouse issue is still unsolved.
Here my code:
My function called periodically (every 1 s) to look for devices:
{
struct usb_bus *_usb_bus;
struct usb_device *_dev;
struct usb_endpoint_descriptor * _endpoint;
struct usb_dev_handle *_usb_handle;
/* find all usb busses */
usb_find_busses();
/* get all devices attached to busses */
usb_find_devices();
for (_usb_bus = usb_busses; _usb_bus; _usb_bus = _usb_bus->next)
{
for (_dev = _usb_bus->devices; _dev; _dev=_dev->next)
{
Stop on RVG6 device
if ((_dev->descriptor.idProduct == RVG6USB_DRIVER_VID) &&
(_dev->descriptor.idVendor == RVGUSB_PID))
{
_usb_handle = usb_open(_dev);
if (_usb_handle == NULL)
continue;
else
{
usb_close(_usb_handle);
}
LogFileTxtMessage("RVG6: CRvgUsbDevice::FindDevice? rvg6 device found\n" );
return _dev;
}
}
}
return NULL;
}
Thanks in advance.
comment:4 Changed 11 months ago by karthiga
When my device is attached, i have no problem. The issue is only when my device is not attached.
comment:5 Changed 8 months ago by hjelmn
- Owner set to hjelmn
- Status changed from new to assigned
Taking this ticket. I don't know what is causing this problem but I have a potential fix that will be submitted as a separate ticket.
comment:6 Changed 8 months ago by karthiga
hello,
i solve my problem as suggested previously by using the following fix:
Desactivated the following code in the darwin_usb.c
#if 0
if (kIOReturnSuccess != ret && is_open && try_unsuspend) {
/* device may be suspended. unsuspend it and try again */
#if DeviceVersion? >= 320
@@ -640,7 +643,7 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct li
try_unsuspend = 0;
}
}
#endif
Though the suspended device is IR Receiver and not the mouse or keyboard, it seems that removal of this suspend/unsuspend mechanism on the IR Receiver causes mouse and keyboard blocked for unknown reason.
Thanks again for all your help.
comment:7 Changed 8 months ago by hjelmn
- Milestone set to 1.0.10
Great. Not sure why unsuspending the ir receiver causes problems but its good to hear that not unsuspending it fixes the problem. I will close this ticket when 1.0.10 is released.
comment:8 Changed 8 months ago by xiaofan
- Component changed from libusb-1.0 to libusb-1.0 Darwin backend
comment:9 Changed 4 months ago by hjelmn
- Milestone changed from 1.0.10 to 1.0.16
comment:10 Changed 6 weeks ago by hjelmn
- Resolution set to fixed
- Status changed from assigned to closed
I think this is fixed in 1.0.16. Please re-open the ticket if this behavior reappears.
comment:11 Changed 5 weeks ago by hjelmn
One more note. This is likely caused not by unsuspending Apple devices but rather the use of IODestroyPlugInInterface which can cause IOServices to stop. This has been observed with IOBDServices.
Please post your code snippets and the debug log.
How to enable the debug log? Please refer to the comment here.
http://libusb.org/ticket/132#comment:2