When running a JavaFX WebView embedded in a JFXPanel on macOS 14, right after hitting the Caps lock key, a deadlock happens and the application freezes.
To reproduce, run the attached test with JDK 17+ and JavaFX 17+, and when the webView shows up, just hit the Caps lock key. The application will freeze.
A thread dump will show:
"AWT-EventQueue-0" #22 [55307] prio=6 os_prio=31 cpu=146.91ms elapsed=20.07s tid=0x000000011786b400 nid=55307 waiting on condition [0x00000001722f5000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@21/Native Method)
- parking to wait for <0x000000070fd64bd8> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(java.base@21/LockSupport.java:221)
at java.util.concurrent.FutureTask.awaitDone(java.base@21/FutureTask.java:500)
at java.util.concurrent.FutureTask.get(java.base@21/FutureTask.java:190)
at com.sun.javafx.webkit.InputMethodClientImpl.getTextLocation(javafx.web@21.0.1/InputMethodClientImpl.java:139)
at javafx.scene.Scene$InputMethodRequestsDelegate.getTextLocation(javafx.graphics@21.0.1/Scene.java:4169)
at javafx.embed.swing.InputMethodSupport$InputMethodRequestsAdapter.getTextLocation(javafx.swing@21.0.1/InputMethodSupport.java:61)
at sun.awt.im.InputMethodContext.getTextLocation(java.desktop@21/InputMethodContext.java:279)
at sun.lwawt.macosx.CInputMethod$6.run(java.desktop@21/CInputMethod.java:722)
- locked <0x000000070fc761c8> (a [I)
at java.awt.event.InvocationEvent.dispatch(java.desktop@21/InvocationEvent.java:308)
at java.awt.EventQueue.dispatchEventImpl(java.desktop@21/EventQueue.java:773)
at java.awt.EventQueue$4.run(java.desktop@21/EventQueue.java:720)
at java.awt.EventQueue$4.run(java.desktop@21/EventQueue.java:714)
at java.security.AccessController.executePrivileged(java.base@21/AccessController.java:778)
at java.security.AccessController.doPrivileged(java.base@21/AccessController.java:400)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@21/ProtectionDomain.java:87)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@21/ProtectionDomain.java:98)
at java.awt.EventQueue$5.run(java.desktop@21/EventQueue.java:747)
at java.awt.EventQueue$5.run(java.desktop@21/EventQueue.java:745)
at java.security.AccessController.executePrivileged(java.base@21/AccessController.java:778)
at java.security.AccessController.doPrivileged(java.base@21/AccessController.java:400)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(java.base@21/ProtectionDomain.java:87)
at java.awt.EventQueue.dispatchEvent(java.desktop@21/EventQueue.java:744)
at java.awt.EventDispatchThread.pumpOneEventForFilters(java.desktop@21/EventDispatchThread.java:203)
at java.awt.EventDispatchThread.pumpEventsForFilter(java.desktop@21/EventDispatchThread.java:124)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(java.desktop@21/EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(java.desktop@21/EventDispatchThread.java:109)
at java.awt.EventDispatchThread.pumpEvents(java.desktop@21/EventDispatchThread.java:101)
at java.awt.EventDispatchThread.run(java.desktop@21/EventDispatchThread.java:90)
which points to com.sun.javafx.webkit.InputMethodClientImpl.getTextLocation and sun.awt.im.InputMethodContext.getTextLocation, in a very similar way than this open issue: https://bugs.openjdk.org/browse/JDK-8221261