-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Per hidapi, macOS HID API calls MUST be executed on the same thread to be safe:
- Documentation: add multi-threading notes libusb/hidapi#45
- Potential solution to MacOS hid_init/hid_exit issue libusb/hidapi#666
- Crash when calling enumerate from different threads (not simultaneously) trezor/cython-hidapi#148
Currently, separate threads interacting with a HID devices on macOS, the entire JVM will crash. This can actually be caused by same-thread execution due to this automatic shutdown hook.
hid4java/src/main/java/org/hid4java/HidServices.java
Lines 90 to 99 in 672f0a7
| if (hidServicesSpecification.isAutoShutdown()) { | |
| // Ensure we release resources during shutdown | |
| Runtime.getRuntime().addShutdownHook( | |
| new Thread() { | |
| @Override | |
| public void run() { | |
| shutdown(); | |
| } | |
| }); | |
| } |
Despite this being an upstream issue, Java has some ways of thread pooling so that we can manage this downstream until upstream has a permanent fix.
@Vzor- will be submitting a PR which references this issue with a proposed downstream threading solution.
Metadata
Metadata
Assignees
Labels
No labels