-
Notifications
You must be signed in to change notification settings - Fork 342
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
Library hangs on MacOS 10.13.5 #225
Comments
Every time system is freezing we have an event that WindowServer process is hanging.
And this is the dump for thread 0x6d6e3
|
Well, it looks like there is a deadlock between the dispatch thread and the hook_get_multi_click_time function. There is a lot of stupid threading going on to work with the functions to get the key char because the function for OSX can only run on the main thread. Most of this crap is not documented by Apple, and I do not have access to a mac that is capable of running 10.13 so I cannot debug. For the 0x6d6e3 thread, things are hanging on line 461. My guess is that 0x73e3b is hanging around line 226. Apple has a nasty habit of changing the way POSIX APIs work in conjunction with their overly complex "frameworks." If one of you could set the log level to DEBUG and paste the log output here, it may help narrow down what's going on. |
A little more update: I remember implementing this thread mess because this library was using C and I could not call the Objective-C |
@MFoly how did you generate that trace? |
@kwhat It seems that this fix is failing to capture any key or mouse movement for older MacOS versions. |
Which versions? The oldest I have is 10.7. I made several amended commits over the last two hours so make sure you are using the latest srcs. I have been able to stop the Tap timeout error and click count should work correctly now. Latest HASH 0ae5800 |
Tested on 10.13.4 and 10.12.6 and same results. Will retry with the latest changes and post results shortly. |
Make sure you remove the library from the temp folder. |
Hi there! Unfortunately, it seems like something in the newest commits broke global key events. Although they seem to work in your example application, they don't in this simple program:
The program prints key events when using JNativeHook 2.1.0, but doesn't with the newest code. |
@FD- I have tested your example after adding this line after attaching the listener and it works fine: We had the same issue. |
@rmoawad Thanks, that did the trick! I wonder if this is a bug or an intentional change. |
Are the fixes available publicly? Unfortunately, the provided fix has broken code for Linux.
|
I didn't build the other platforms into the library, only osx. You can extract the public lib folder from the jar and copy the other platforms to the new jar. I am still working on getting an OS X toolchain working and it is getting close. |
Thank god i found this. have been debugging my stuff for days, thinking it was something i had done. |
Hi @kwhat This issue is still happening with your changes in the commit 7a82ecd6 . It freezes the system for a few seconds for every mouse clicking /wheeling which my application registered the listeners to. Could you please find some time to check it? Here is the relevant system report (similar to the ones posted above by MFoly):
And this is the console output on my application shutdown:
|
Thanks for working on this! |
A fix for this bug would be much appreciated! |
My temporary workaround is returning a fixed number in this line .
1000ms for the double click interval is a good number for me, since my application does not need to precisely identify a mouse clicking is a single one or a double one. Hopefully this workaround could help you. |
@gershkovich @hendriks73 |
I use maven dependency is there a new version which will work on latest macos without hanging? if no what I can do to make the library work on latest macos, is there any jar file to download and use as library? |
Please try my compiled jar with my local changes mentioned in the above comment if you like. Note:
|
thank you, my software is depending on this library, I am not able to go to any other alternative and this is really urgent, so hope you will help me and other users with making new version so when we can hope to have that update? )) |
@howtimeflies-io |
@macdevign The line The hang issue is solved by separate changes in the jnativehook code itself. Building the library from the sources of this repository should fix them. I suggest you read through all the information in the issue discussion above. All I just wrote is already covered. |
I created a quick replacement library for JNativeHook that offers simplified functionalities. You might find this helpful while waiting for next release to fix this. |
Nice.
Thank you! |
|
> What OS are you running?
Primarily Linux, but I do have access to Windows.
> The low level native codes should support all keys. However, I do not
have native key code mappings to convert that into the Java AWT KeyEvent.
They should support all keys that I can get a low-level keycode. There are
some keys that do not produce native key codes (the eject button on OS X
comes to mind) that cannot be supported. There is an adapter class that
can convert to AWT keycodes if needed. See
https://github.com/kwhat/jnativehook/blob/2.1/src/java/org/jnativehook/keyboard/SwingKeyAdapter.java
The general issue is that I do not have access to Mac right now and the
cross compiler I was using is not working and I have not figured out all of
the issues it is experiencing yet. Most of the code issues are fixed in
git, however, I cannot compile to create a release. You can probably build
locally to see if this fixes your issue, or if there is another problem
that needs attention.
…On Mon, Apr 22, 2019 at 8:31 AM Hoai Phuoc Truong ***@***.***> wrote:
1. What OS are you running? The low level native codes should support
all keys. However, I do not have native key code mappings to convert that
into the Java AWT KeyEvent. You can run the low level native binary on the
respective OS and let me know what are the key codes for the multimedia
keys. Just open a bug on the repo and I'll add the details.
2. I'm not sure what the problem in JNativeHook. Even if I could
contribute, I'm not in control of the release of the fix.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#225 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFFCRE22GO6PAQKS2I3QXDPRXK6RANCNFSM4FDMNP2A>
.
|
|
I've built the jnativehook jar from source (had to delete src/java/module-info.java for it to build under OpenJDK 8) on my Mac and my application has been working without freezes for the last couple of days. A copy of the jar is in https://github.com/kolovos/minigen/blob/master/io.dimitris.minigen/lib/jnativehook-2.1.20190707.jar in case it's useful to anyone else. |
any chance we can get this on maven central? maybe a 2.1.1 ? |
… On Mon, Oct 21, 2019 at 3:02 AM Bogdan Bugarschi ***@***.***> wrote:
any chance we can get this on maven central? maybe a 2.1.1 ?
the snapshot repos don't seem to be working (i.e. there nothing there :P)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#225?email_source=notifications&email_token=AAFFCRBE25ZAM5LJ5H7OHNDQPV43VA5CNFSM4FDMNP2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBZY2RY#issuecomment-544443719>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFFCRFZ6OLHCEHGHIR7WW3QPV43VANCNFSM4FDMNP2A>
.
|
IDK Why but non of my artifacts are showing up right now. |
Any news on this issue ? The .jars here https://oss.sonatype.org/content/repositories/snapshots/com/1stleg/jnativehook/2.1.SNAPSHOT/ all give back a 404 so I can't get them, and Maven still doesn't have the 2.1.1 artifact up Thanks a lot |
I am working on a new build method for this library using Maven, Cmake and GitHub Actions. Maven is still terrible but it should be done in the coming days. |
I am pretty sure I know what is causing this issue. It is probably caused by the thread safety around this nonsense. The whole issue revolves around the TIS API requiring that it runs on the Main loop. It may be possible to solve this with blocks. I just got OS X in Virtualbox with the awesome myspaghetti/macos-virtualbox project so I can actually do some testing and debugging for OS X. If any of you want to take a stab at this, please open a pull-request against the maven or 2.2 branch. |
Fix this by importing this library and adding this line GlobalScreen.setEventDispatcher(new SwingDispatchService()); works like a charm |
Hey Jay, thanks for testing. Which library build is that? Is it part of the 2.2 branch? |
Hi kwhat, sorry this was meant for the hang bug in jnativehook. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@dipeshpatidar if there is still a problem with Big Sur / Monterey, please open a new bug. I currently have no way of running either of these releases so it will be a while before I can take a look. |
Is this still a problem with 2.2.1? Did @jaysworldofcode 's @dipeshpatidar Your issue is discussed in #359, please add notes to that ticket. |
After updating to MacOS 10.13.5, the library eventually hangs the system.
How to reproduce:
To get the same effect (so you can observe and reproduce the issue more quickly), run v2.0.3 sample application and the issue appears in minutes.
Any ideas on the issue @kwhat ?
Thanks!
The text was updated successfully, but these errors were encountered: