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

macOS API calls must be thread safe #152

Open
tresf opened this issue Jun 6, 2024 · 0 comments
Open

macOS API calls must be thread safe #152

tresf opened this issue Jun 6, 2024 · 0 comments

Comments

@tresf
Copy link
Contributor

tresf commented Jun 6, 2024

Per hidapi, macOS HID API calls MUST be executed on the same thread to be safe:

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.

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.

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

No branches or pull requests

1 participant