jnativehook icon indicating copy to clipboard operation
jnativehook copied to clipboard

Library hangs on MacOS 10.13.5

Open williamcrossover opened this issue 7 years ago • 50 comments
trafficstars

After updating to MacOS 10.13.5, the library eventually hangs the system.

How to reproduce:

  1. Run the provided sample application in this library "ant run" v2.1.0 and let it run for a few hours. The system eventually starts to crawl and mouse pointer hangs, windows hangs.
  2. If the sample application is killed, everything goes back to normal.

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!

williamcrossover avatar Jun 05 '18 15:06 williamcrossover

Every time system is freezing we have an event that WindowServer process is hanging. Sample form system report

Thread 0x73e3b            DispatchQueue 85          7 samples (1-7)           priority 37 (base 37)
  <thread QoS user initiated (requested user interactive, ipc override user interactive), IO tier 0>
  7  start_wqthread + 13 (libsystem_pthread.dylib + 11241) [0x7fff771e5be9] 1-7
    7  _pthread_wqthread + 980 (libsystem_pthread.dylib + 12242) [0x7fff771e5fd2] 1-7
      7  _dispatch_workloop_worker_thread + 880 (libdispatch.dylib + 109857) [0x7fff76eadd21] 1-7
        7  _dispatch_root_queue_drain_deferred_wlh + 332 (libdispatch.dylib + 93965) [0x7fff76ea9f0d] 1-7
          7  _dispatch_queue_invoke + 373 (libdispatch.dylib + 37222) [0x7fff76e9c166] 1-7
            7  _dispatch_queue_serial_drain + 222 (libdispatch.dylib + 90234) [0x7fff76ea907a] 1-7
              7  _dispatch_source_invoke + 620 (libdispatch.dylib + 16513) [0x7fff76e97081] 1-7
                7  _dispatch_continuation_pop + 472 (libdispatch.dylib + 85633) [0x7fff76ea7e81] 1-7
                  7  _dispatch_client_callout + 8 (libdispatch.dylib + 7608) [0x7fff76e94db8] 1-7
                    7  __IOHIDEventSystemClientScheduleWithDispatchQueue_block_invoke + 219 (IOKit + 326228) [0x7fff518c7a54] 1-7
                      7  __IOHIDEventSystemClientQueueCallback + 277 (IOKit + 326546) [0x7fff518c7b92] 1-7
                        7  event_system_callback(void*, void*, void*, __IOHIDEvent*) + 201 (SkyLight + 120504) [0x7fff70d166b8] 1-7
                          7  hid_translation_state_append_hid_event(hid_translation_state_t*, __IOHIDEvent*) + 2549 (SkyLight + 2113396) [0x7fff70efcf74] 1-7
                            7  hid_translation_state_append_hid_event(hid_translation_state_t*, __IOHIDEvent*) + 3848 (SkyLight + 2114695) [0x7fff70efd487] 1-7
                              7  CursorTrackingInfo::updateCursorPosition(CGPoint, CGPoint (*)(CGPoint)) + 364 (SkyLight + 2450274) [0x7fff70f4f362] 1-7
                                7  _EVGSetMouseLocation + 138 (SkyLight + 898862) [0x7fff70dd472e] 1-7
                                  7  IOHIDSetFixedMouseLocation + 83 (IOKit + 224706) [0x7fff518aedc2] 1-7
                                    7  IOConnectCallMethod + 186 (IOKit + 15316) [0x7fff5187bbd4] 1-7
                                      7  io_connect_method + 369 (IOKit + 15783) [0x7fff5187bda7] 1-7
                                        7  mach_msg_trap + 10 (libsystem_kernel.dylib + 78346) [0x7fff7701520a] 1-7
                                         *7  hndl_mach_scall64 + 22 (kernel + 129414) [0xffffff800021f986] 1-7
                                           *7  mach_call_munger64 + 509 (kernel + 1517245) [0xffffff80003726bd] 1-7
                                             *7  mach_msg_overwrite_trap + 891 (kernel + 402667) [0xffffff80002624eb] 1-7
                                               *7  ipc_kmsg_send + 189 (kernel + 326109) [0xffffff800024f9dd] 1-7
                                                 *7  ipc_kobject_server + 304 (kernel + 468608) [0xffffff8000272680] 1-7
                                                   *7  ??? (kernel + 1325972) [0xffffff8000343b94] 1-7
                                                     *7  is_io_connect_method + 535 (kernel + 7120311) [0xffffff80008ca5b7] 1-7
                                                       *7  IOUserClient::externalMethod(unsigned int, IOExternalMethodArguments*, IOExternalMethodDispatch*, OSObject*, void*) + 832 (kernel + 7084848) [0xffffff80008c1b30] 1-7
                                                         *7  shim_io_connect_method_structureI_structureO + 457 (kernel + 7092649) [0xffffff80008c39a9] 1-7
                                                           *7  IOCommandGate::runAction(int (*)(OSObject*, void*, void*, void*, void*), void*, void*, void*, void*) + 73 (kernel + 6925545) [0xffffff800089ace9] 1-7
                                                             *7  IOWorkLoop::closeGate() + 37 (kernel + 6912773) [0xffffff8000897b05] 1-7
                                                               *7  lck_mtx_lock + 653 (kernel + 121517) [0xffffff800021daad] 1-7
                                                                 *7  lck_mtx_lock_wait_x86 + 486 (kernel + 1577190) [0xffffff80003810e6] 1-7
                                                                   *7  thread_block_reason + 175 (kernel + 554463) [0xffffff80002875df] 1-7
                                                                     *7  ??? (kernel + 558618) [0xffffff800028861a] 1-7
                                                                       *7  machine_switch_context + 205 (kernel + 1586045) [0xffffff800038337d] (blocked by kernel mutex owned by JavaAppLauncher (NativeHookApp) [12506] thread 0x6d6e3) 1-7

And this is the dump for thread 0x6d6e3

  2002 Thread_448227: Java: JNativeHook Hook Thread
    + 2002 hook_get_multi_click_time  (in libJNativeHook-2.1.0.x86_64.dylib) + 69  [0x124b733d5]
    +   2002 IOServiceOpen  (in IOKit) + 36  [0x7fff5187b6ac]
    +     2002 io_service_open_extended  (in IOKit) + 131  [0x7fff5187b73f]
    +       2002 mach_msg  (in libsystem_kernel.dylib) + 60  [0x7fff77014724]
    +         2002 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x7fff7701520a]

MFoly avatar Jun 05 '18 16:06 MFoly

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.

kwhat avatar Jun 05 '18 16:06 kwhat

A little more update:

I remember implementing this thread mess because this library was using C and I could not call the Objective-C dispatch_async function due to the lack of block support. Later, Iván Munsuri Ibáñez made a contribution that lead to the Obj-C Runtime Library which you can call from C. I think all of these mutexs can be replaced with imp_implementationWithBlock to somehow translate a function pointer to a block.

kwhat avatar Jun 05 '18 17:06 kwhat

@MFoly how did you generate that trace?

kwhat avatar Jun 06 '18 04:06 kwhat

@kwhat It seems that this fix is failing to capture any key or mouse movement for older MacOS versions.

shoaib-xo avatar Jun 06 '18 06:06 shoaib-xo

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 0ae5800756522098e397be125e07423e55a4f871

kwhat avatar Jun 06 '18 06:06 kwhat

Tested on 10.13.4 and 10.12.6 and same results. Will retry with the latest changes and post results shortly.

shoaib-xo avatar Jun 06 '18 06:06 shoaib-xo

Make sure you remove the library from the temp folder.

kwhat avatar Jun 06 '18 06:06 kwhat

Hi there! I was also seeing the same issue since updating to High Sierra, and was delighted to see you're already working on fixing it! I compiled the latest code and haven't seen any freeze since, so fingers crossed that bug is fixed!

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:

public class Main {
    public static void main(String[] args) {
        try {
            GlobalScreen.registerNativeHook();
        } catch (NativeHookException ex) {
            System.err.println("There was a problem registering the native hook.");
        }

        NativeKeyListener keyListener = new NativeKeyListener() {
            @Override
            public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) {
                System.out.print("\n\n Pressed \n\n");
            }

            @Override
            public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) {
                System.out.print("\n\n Released \n\n");
            }

            @Override
            public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) {

            }
        };

        GlobalScreen.addNativeKeyListener(keyListener);
        Scanner scanner = new Scanner(System.in);
        scanner.next();
    }
}

The program prints key events when using JNativeHook 2.1.0, but doesn't with the newest code. Please let me know if there's any way I can help debug this issue!

FD- avatar Jun 06 '18 14:06 FD-

@FD- I have tested your example after adding this line after attaching the listener and it works fine: GlobalScreen.setEventDispatcher(new SwingDispatchService());

We had the same issue.

rmoawad avatar Jun 06 '18 15:06 rmoawad

@rmoawad Thanks, that did the trick! I wonder if this is a bug or an intentional change.

FD- avatar Jun 06 '18 15:06 FD-

Are the fixes available publicly? Unfortunately, the provided fix has broken code for Linux.

Exception in thread "pool-4-thread-1" java.lang.UnsatisfiedLinkError: org.jnativehook.GlobalScreen.getAutoRepeatRate()Ljava/lang/Integer;
	at org.jnativehook.GlobalScreen.getAutoRepeatRate(Native Method)
	at org.jnativehook.GlobalScreen.<clinit>(Unknown Source)
	

shoaib-xo avatar Jun 25 '18 08:06 shoaib-xo

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.

kwhat avatar Jun 25 '18 16:06 kwhat

Thank god i found this. have been debugging my stuff for days, thinking it was something i had done. Is there a working build that fixes this? Willing to pay 30$ since i dont understand this stuff.

Quesadilla1 avatar Aug 05 '18 00:08 Quesadilla1

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. But it is fine to move the mouse since it is not listened in my application.

Could you please find some time to check it? Thank you!


Here is the relevant system report (similar to the ones posted above by MFoly):

Date/Time:       2018-08-06 09:59:44 +0800
OS Version:      Mac OS X 10.13.6 (Build 17G65)
Architecture:    x86_64h
Report Version:  26


  Thread 0x1945bd           DispatchQueue 76          11 samples (1-11)         priority 37 (base 37)
  <thread QoS user initiated (requested user interactive, ipc override user interactive), IO tier 0>
  11  start_wqthread + 13 (libsystem_pthread.dylib + 11241) [0x7fff578ccbe9] 1-11
    11  _pthread_wqthread + 980 (libsystem_pthread.dylib + 12242) [0x7fff578ccfd2] 1-11
      11  _dispatch_workloop_worker_thread + 880 (libdispatch.dylib + 109857) [0x7fff57594d21] 1-11
        11  _dispatch_root_queue_drain_deferred_wlh + 332 (libdispatch.dylib + 93965) [0x7fff57590f0d] 1-11
          11  _dispatch_queue_invoke + 373 (libdispatch.dylib + 37222) [0x7fff57583166] 1-11
            11  _dispatch_queue_serial_drain + 222 (libdispatch.dylib + 90234) [0x7fff5759007a] 1-11
              11  _dispatch_source_invoke + 620 (libdispatch.dylib + 16513) [0x7fff5757e081] 1-11
                11  _dispatch_continuation_pop + 472 (libdispatch.dylib + 85633) [0x7fff5758ee81] 1-11
                  11  _dispatch_client_callout + 8 (libdispatch.dylib + 7608) [0x7fff5757bdb8] 1-11
                    11  __IOHIDEventSystemClientScheduleWithDispatchQueue_block_invoke + 219 (IOKit + 325428) [0x7fff31f80734] 1-11
                      11  __IOHIDEventSystemClientQueueCallback + 277 (IOKit + 325746) [0x7fff31f80872] 1-11
                        11  event_system_callback(void*, void*, void*, __IOHIDEvent*) + 201 (SkyLight + 119880) [0x7fff513fb448] 1-11
                          11  hid_translation_state_append_hid_event(hid_translation_state_t*, __IOHIDEvent*) + 2549 (SkyLight + 2112776) [0x7fff515e1d08] 1-11
                            11  hid_translation_state_append_hid_event(hid_translation_state_t*, __IOHIDEvent*) + 3848 (SkyLight + 2114075) [0x7fff515e221b] 1-11
                              11  CursorTrackingInfo::updateCursorPosition(CGPoint, CGPoint (*)(CGPoint)) + 364 (SkyLight + 2449984) [0x7fff51634240] 1-11
                                11  _EVGSetMouseLocation + 138 (SkyLight + 898166) [0x7fff514b9476] 1-11
                                  11  IOHIDSetFixedMouseLocation + 83 (IOKit + 223906) [0x7fff31f67aa2] 1-11
                                    11  IOConnectCallMethod + 186 (IOKit + 14036) [0x7fff31f346d4] 1-11
                                      11  io_connect_method + 369 (IOKit + 14503) [0x7fff31f348a7] 1-11
                                        11  mach_msg_trap + 10 (libsystem_kernel.dylib + 78346) [0x7fff576fc20a] 1-11
                                         *11  hndl_mach_scall64 + 22 (kernel + 125414) [0xffffff800021e9e6] 1-11
                                           *11  mach_call_munger64 + 509 (kernel + 1513245) [0xffffff800037171d] 1-11
                                             *11  mach_msg_overwrite_trap + 891 (kernel + 398667) [0xffffff800026154b] 1-11
                                               *11  ipc_kmsg_send + 189 (kernel + 322109) [0xffffff800024ea3d] 1-11
                                                 *11  ipc_kobject_server + 304 (kernel + 464608) [0xffffff80002716e0] 1-11
                                                   *11  ??? (kernel + 1321972) [0xffffff8000342bf4] 1-11
                                                     *11  is_io_connect_method + 535 (kernel + 7120231) [0xffffff80008ca567] 1-11
                                                       *11  IOUserClient::externalMethod(unsigned int, IOExternalMethodArguments*, IOExternalMethodDispatch*, OSObject*, void*) + 832 (kernel + 7084768) [0xffffff80008c1ae0] 1-11
                                                         *11  shim_io_connect_method_structureI_structureO + 457 (kernel + 7092569) [0xffffff80008c3959] 1-11
                                                           *11  IOCommandGate::runAction(int (*)(OSObject*, void*, void*, void*, void*), void*, void*, void*, void*) + 73 (kernel + 6925433) [0xffffff800089ac79] 1-11
                                                             *11  IOWorkLoop::closeGate() + 37 (kernel + 6912661) [0xffffff8000897a95] 1-11
                                                               *11  lck_mtx_lock + 653 (kernel + 117517) [0xffffff800021cb0d] 1-11
                                                                 *11  lck_mtx_lock_wait_x86 + 486 (kernel + 1575750) [0xffffff8000380b46] 1-11
                                                                   *11  thread_block_reason + 175 (kernel + 550463) [0xffffff800028663f] 1-11
                                                                     *11  ??? (kernel + 554618) [0xffffff800028767a] 1-11
                                                                       *11  machine_switch_context + 205 (kernel + 1584605) [0xffffff8000382ddd] (blocked by kernel mutex owned by io.howtimeflies.client.HowTimeFliesApp [31774] thread 0x18bd0b) 1-11

Thread 0x18bd0b           Thread name "Java: JNativeHook Hook Thread"         11 samples (1-11)         priority 37 (base 31)
  <thread QoS default (requested default), process unclamped, process received importance donation from WindowServer [240], IO tier 0>
  11  hook_get_multi_click_time + 69 (libJNativeHook-2.1.0.x86_64.dylib + 25557) [0x10cd113d5] 1-11
    11  IOServiceOpen + 36 (IOKit + 12716) [0x7fff31f341ac] 1-11
      11  io_service_open_extended + 131 (IOKit + 12863) [0x7fff31f3423f] 1-11
        11  mach_msg_trap + 10 (libsystem_kernel.dylib + 78346) [0x7fff576fc20a] 1-11
         *11  hndl_mach_scall64 + 22 (kernel + 125414) [0xffffff800021e9e6] 1-11
           *11  mach_call_munger64 + 509 (kernel + 1513245) [0xffffff800037171d] 1-11
             *11  mach_msg_overwrite_trap + 891 (kernel + 398667) [0xffffff800026154b] 1-11
               *11  ipc_kmsg_send + 189 (kernel + 322109) [0xffffff800024ea3d] 1-11
                 *11  ipc_kobject_server + 304 (kernel + 464608) [0xffffff80002716e0] 1-11
                   *11  ??? (kernel + 1320610) [0xffffff80003426a2] 1-11
                     *11  is_io_service_open_extended + 279 (kernel + 7116199) [0xffffff80008c95a7] 1-11
                       *11  IOHIDSystem::newUserClient(task*, void*, unsigned int, OSDictionary*, IOUserClient**) + 79 (IOHIDFamily + 185149) [0xffffff7f80f7933d] 1-11
                         *11  IOCommandGate::runAction(int (*)(OSObject*, void*, void*, void*, void*), void*, void*, void*, void*) + 312 (kernel + 6925672) [0xffffff800089ad68] 1-11
                           *11  IOHIDSystem::newUserClientGated(task*, void*, unsigned int, OSDictionary*, IOUserClient**) + 244 (IOHIDFamily + 185438) [0xffffff7f80f7945e] 1-11
                             *11  IOService::attach(IOService*) + 357 (kernel + 6732997) [0xffffff800086bcc5] 1-11
                               *11  thread_block_reason + 175 (kernel + 550463) [0xffffff800028663f] 1-11
                                 *11  ??? (kernel + 554618) [0xffffff800028767a] 1-11
                                   *11  machine_switch_context + 205 (kernel + 1584605) [0xffffff8000382ddd] 1-11

And this is the console output on my application shutdown:


Aug 06, 2018 9:59:36 AM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_button_released [830]: Button 1 released 1 time(s). (1473, 853)

Aug 06, 2018 9:59:36 AM org.jnativehook.GlobalScreen$NativeHookThread enable
INFO: process_button_released [851]: Button 1 clicked 1 time(s). (1473, 853)

Aug 06, 2018 9:59:51 AM org.jnativehook.GlobalScreen$NativeHookThread enable
WARNING: hook_event_proc [1090]: CGEventTap timeout!

2018-08-06 09:59:51,859 Thread-0                         INFO  i.h.c.HowTimeFliesApp            Application shutting down

howtimeflies-io avatar Aug 06 '18 02:08 howtimeflies-io

Thanks for working on this! A fix for this along with a proper, new release would be much appreciated.

hendriks73 avatar Aug 07 '18 15:08 hendriks73

A fix for this bug would be much appreciated! Meanwhile, had to stop using it on OS X 10.13.6. I can assist with testing it if that will help.

gershkovich avatar Aug 15 '18 13:08 gershkovich

@hendriks73 @gershkovich

My temporary workaround is returning a fixed number in this line .

-       long clicktime = hook_get_multi_click_time();
+       // long clicktime = hook_get_multi_click_time();
+       long clicktime = 1000;

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.

howtimeflies-io avatar Aug 22 '18 01:08 howtimeflies-io

@gershkovich @hendriks73 Thanks for the tip! I used compiled jar from Maven. I am trying to avoid the pain of compiling it locally. Any documentation that you can recommend? (I actually tried to follow the docs here but quickly failed – my compiled version did not work).

gershkovich avatar Aug 22 '18 16:08 gershkovich

I use maven dependency <groupId>com.1stleg</groupId> <artifactId>jnativehook</artifactId> 2.1.0

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?

vahagnsargsian avatar Aug 31 '18 09:08 vahagnsargsian

@gershkovich @vahagnsargsian

Please try my compiled jar with my local changes mentioned in the above comment if you like.

Note:

  • it was compiled following this wiki page
  • it works only on macOS since it's not cross-platform compiled

howtimeflies-io avatar Sep 01 '18 02:09 howtimeflies-io

thank you, when do you think there will be an update so I can update by maven dependency and get crossplatform working version (which will not hang on mac), as before?

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? ))

vahagnsargsian avatar Sep 18 '18 16:09 vahagnsargsian

@howtimeflies-io
I tested your compiled jar but for unknown reasons when i add a NativeKeyListener, the listener is not catching any events, but it's not crashing anymore and the logging works. The same code works when I use the maven dependency.

MaxEgg avatar Oct 07 '18 11:10 MaxEgg

2.1.1 version is very important for all library users, please can you launch it as soon as possible

vahagnsargsian avatar Oct 11 '18 08:10 vahagnsargsian

Hi @kwhat , Thanks a lot for your efforts with creating this library! Some sort of unique staff! Unhappy to see it is pretty much abandoned :( Is there any chance to go forward with v2.1.1 and fix this bug?

kazakovium avatar Oct 20 '18 09:10 kazakovium

I am also waiting for 2.1.1 for months

maybe anyone knows if there is some cross-platform (osx,linux,windows) alternative to use instead of this library?

vahagnsargsian avatar Nov 28 '18 04:11 vahagnsargsian

Does anyone have a working jar that wont hang the system?

The jar @howtimeflies-io wont capture keys im afraid.

enesaltinkaya avatar Jan 30 '19 11:01 enesaltinkaya

@enesaltinkaya I had the same problem: https://github.com/kwhat/jnativehook/issues/225#issuecomment-395086742, but @rmoawad found a solution: https://github.com/kwhat/jnativehook/issues/225#issuecomment-395105103

FD- avatar Jan 30 '19 12:01 FD-

@FD- thanks a lot! I missed that before you pointed out. Now its working without hanging the pc.

enesaltinkaya avatar Jan 30 '19 12:01 enesaltinkaya

"@FD- thanks a lot! I missed that before you pointed out. Now its working without hanging the pc." from @FD's comment on using the following line to resolve the issue GlobalScreen.setEventDispatcher(new SwingDispatchService());"

I have added the above line on several swing app running on Mac Mojave using the above line , and after some time, the hang still persist. Just to let those using it know that it may not have solved the hanging issue.

Jnativehook is a useful library if it resolve the hang issue. Unfortunately I couldn't find any jnativehook alternative.

Hope that this issue is resolved with new library update.

macdevign avatar Mar 21 '19 07:03 macdevign

@macdevign The line GlobalScreen.setEventDispatcher(new SwingDispatchService()); is just meant to fix the issue that keys are not captured.

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.

FD- avatar Mar 21 '19 09:03 FD-

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. https://github.com/repeats/SimpleNativeHooks

hptruong93 avatar Apr 22 '19 07:04 hptruong93

Nice. Two questions:

  1. Does SimpleNativeHooks support media keys properly?
  2. Any chance you could contribute to JNativeHook to (finally) fix it?

Thank you!

hendriks73 avatar Apr 22 '19 10:04 hendriks73

  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.

hptruong93 avatar Apr 22 '19 15:04 hptruong93

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 [email protected] 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 https://github.com/kwhat/jnativehook/issues/225#issuecomment-485450902, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFFCRE22GO6PAQKS2I3QXDPRXK6RANCNFSM4FDMNP2A .

kwhat avatar Apr 22 '19 20:04 kwhat

@hptruong93

  1. macOS 10.14. — I'll simply try it out.

hendriks73 avatar Apr 23 '19 08:04 hendriks73

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.

kolovos avatar Jul 09 '19 19:07 kolovos

New builds are here

https://oss.sonatype.org/content/repositories/snapshots/com/1stleg/jnativehook/2.1.SNAPSHOT/ https://oss.sonatype.org/content/repositories/snapshots/com/1stleg/jnativehook/2.1.SNAPSHOT/jnativehook-2.1.20190725.024655-45.jar

kwhat avatar Jul 25 '19 02:07 kwhat

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)

boogie666 avatar Oct 21 '19 10:10 boogie666

https://issues.sonatype.org/browse/MVNCENTRAL-5285

On Mon, Oct 21, 2019 at 3:02 AM Bogdan Bugarschi [email protected] 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 https://github.com/kwhat/jnativehook/issues/225?email_source=notifications&email_token=AAFFCRBE25ZAM5LJ5H7OHNDQPV43VA5CNFSM4FDMNP2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBZY2RY#issuecomment-544443719, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFFCRFZ6OLHCEHGHIR7WW3QPV43VANCNFSM4FDMNP2A .

kwhat avatar Oct 21 '19 17:10 kwhat

IDK Why but non of my artifacts are showing up right now.

kwhat avatar Oct 21 '19 17:10 kwhat

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

gabriel-dehan avatar Nov 05 '19 12:11 gabriel-dehan

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.

kwhat avatar May 20 '20 01:05 kwhat

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.

kwhat avatar May 20 '20 01:05 kwhat

Fix this by importing this library and adding this line GlobalScreen.setEventDispatcher(new SwingDispatchService()); works like a charm

jaysworldofcode avatar Oct 02 '20 16:10 jaysworldofcode

Hey Jay, thanks for testing. Which library build is that? Is it part of the 2.2 branch?

kwhat avatar Oct 02 '20 16:10 kwhat

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.

jaysworldofcode avatar Oct 02 '20 16:10 jaysworldofcode

@jaysworldofcode @kwhat i have imported the library in my local maven repo .m2 and now the mac machine doesn't hangs or freezes but the application crashes on BigSur but not on Catalina. I am adding the crash logs, please let me know any effective way to avoid this. logs.txt

dipeshpatidar avatar Jul 07 '21 05:07 dipeshpatidar

@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.

kwhat avatar Sep 27 '21 16:09 kwhat

Is this still a problem with 2.2.1? Did @jaysworldofcode 's GlobalScreen.setEventDispatcher(new SwingDispatchService()); solution work for you? I don't use an OS X computer so I can't test by leaving it running all day. The latest 2.2 had some reworking of the OS X code that may have resolved this issue.

@dipeshpatidar Your issue is discussed in #359, please add notes to that ticket.

kwhat avatar Feb 18 '22 01:02 kwhat