Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8221261

Deadlock on macOS in JFXPanel app when handling IME calls

    XMLWordPrintable

Details

    Backports

      Description

        Below is the stack trace showing a deadlock reproduced when using WebView via JFXPanel in JetBrains IDE:

        "AWT-EventQueue-0" prio=0 tid=0x0 nid=0x0 waiting on condition
              java.lang.Thread.State: WAITING on java.util.concurrent.FutureTask at 51c6338d
             at java.base at 11.0.2/jdk.internal.misc.Unsafe.park(Native Method)
             at java.base at 11.0.2/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
             at java.base at 11.0.2/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:447)
             at java.base at 11.0.2/java.util.concurrent.FutureTask.get(FutureTask.java:190)
             at platform/javafx.web at 11.0.2/com.sun.javafx.webkit.InputMethodClientImpl.getLocationOffset(InputMethodClientImpl.java:157)
             at platform/javafx.graphics at 11.0.2/javafx.scene.Scene$InputMethodRequestsDelegate.getLocationOffset(Scene.java:4140)
             at platform/javafx.swing at 11.0.2/javafx.embed.swing.InputMethodSupport$InputMethodRequestsAdapter.getLocationOffset(InputMethodSupport.java:67)
             at java.desktop at 11.0.2/sun.awt.im.InputMethodContext.getLocationOffset(InputMethodContext.java:285)
             at java.desktop at 11.0.2/sun.lwawt.macosx.CInputMethod$7.run(CInputMethod.java:779)
             at java.desktop at 11.0.2/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:303)
             at java.desktop at 11.0.2/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
             at java.desktop at 11.0.2/java.awt.EventQueue$4.run(EventQueue.java:727)
             at java.desktop at 11.0.2/java.awt.EventQueue$4.run(EventQueue.java:721)
             at java.base at 11.0.2/java.security.AccessController.doPrivileged(Native Method)
             at java.base at 11.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
             at java.base at 11.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
             at java.desktop at 11.0.2/java.awt.EventQueue$5.run(EventQueue.java:751)
             at java.desktop at 11.0.2/java.awt.EventQueue$5.run(EventQueue.java:749)
             at java.base at 11.0.2/java.security.AccessController.doPrivileged(Native Method)
             at java.base at 11.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
             at java.desktop at 11.0.2/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
             at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:723)
             at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:672)
             at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:367)
             at java.desktop at 11.0.2/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
             at java.desktop at 11.0.2/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
             at java.desktop at 11.0.2/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
             at java.desktop at 11.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
             at java.desktop at 11.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
             at java.desktop at 11.0.2/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

        "JavaFX Application Thread" prio=0 tid=0x0 nid=0x0 runnable
              java.lang.Thread.State: RUNNABLE
          (in native)
             at java.desktop at 11.0.2/sun.lwawt.macosx.LWCToolkit.$$YJP$$doAWTRunLoopImpl(Native
        Method)
             at java.desktop at 11.0.2/sun.lwawt.macosx.LWCToolkit.doAWTRunLoopImpl(LWCToolkit.java)
             at java.desktop at 11.0.2/sun.lwawt.macosx.LWCToolkit.doAWTRunLoop(LWCToolkit.java:1027)
             at java.desktop at 11.0.2/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:827)
             at java.desktop at 11.0.2/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:780)
             at java.desktop at 11.0.2/sun.lwawt.macosx.CInputMethod.characterIndexForPoint(CInputMethod.java:777)

        The "characterIndexForPoint" method performs "invokeAndWait"
         rom JavaFX thread:

                     LWCToolkit.invokeAndWait(new Runnable() {
                         public void run() { synchronized(offsetInfo) {
                             offsetInfo[0] = fIMContext.getLocationOffset(screenX, screenY);
                             insertPositionOffset[0] = fIMContext.getInsertPositionOffset();
                         }}
                     }, fAwtFocussedComponent);

        which is then on EDT delegates back to JavaFX thread and waits for async result.

        It seems a regression of the fix:
        https://hg.openjdk.java.net/openjfx/11/rt/rev/808d535c4e15

        Unfortunately, I don't have a simple reproducer. However, the deadlock is obvious from the code.

        Attachments

          Issue Links

            Activity

              People

                kcr Kevin Rushforth
                ant Anton Tarasov (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: