0 Replies - 674 Views - Last Post: 09 October 2020 - 10:35 AM Rate Topic: -----

#1 thierrylach   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-October 20

How to stop OpenJDK 13 Swing application on MacOS from hanging when di

Posted 09 October 2020 - 10:35 AM

I have an application which I am trying to upgrade from running under Java 8 (pre-licensed version) to OpenJDK 13. This application is started when a user logs in and sleeps for a time interval, then wakes up and calls a web service to see if it should display. The display is full screen, dimensions set by calling getGraphicsDevice().getDisplayMode().getWidth()/getHeight() (getGraphicsDevice().getFullScreenWindow() returns null).

The application runs as expected using OpenJDK 13 on MS Windows.

It is started when the user logs in by using a launch agent plist with the KeepALive set to true.

It is launched with the following command to use the embedded JRE. No other JRE exists on the computer. $CP is intentionally omitted as it is long.

JAVACMD=../plugins/JRE/contents/HOME/jre/bin/java

ARGS=-Dapple.laf.useScreenMenuBar=false -Xdock:name=KMonitor

cd  /library/kmonitor/kmonitor.app/contents/java

exec "$JAVACMD" -cp "$CP" ${ARGS} "com.bbdo.nait.kmonitor.osx.bbdo.Main"
The application includes a custom JRE made from OpenJDK 13 using Maven.



On MacOS over 75% of the time the application hangs when displaying the window.

Environment:

uname -a
Darwin det-devops-im 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64



java --version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)



The custom JRE is built using the following Maven configuration:

<properties>
    ...
    <compiler.version>13</compiler.version>
    <exe.suffix></exe.suffix>
    <java.version>${compiler.version}</java.version>
    <jlink.modules>java.base,java.desktop,java.management,java.xml,java.rmi,java.sql,jdk.jcmd</jlink.modules>
    ...
</properties>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>create-runtime</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <echo>******************* RUNNING JLINK **************************</echo>
                    <delete dir="${project.build.directory}/jre${compiler.version}" />
                    <delete dir="${project.build.directory}/jlink" />
                    <exec executable="${java.home}/bin/jlink"
                          dir="${project.basedir}"
                          failonerror="true">
                        <arg value="--module-path"/>
                        <arg value="${project.build.outputDirectory}"/>
                        <arg value="--add-modules"/>
                        <arg value="${jlink.modules}"/>
                        <arg value="--output"/>
                        <arg value="${project.build.directory}/jre${compiler.version}/Contents/Home/jre"/>
                    </exec>
                    <copy todir="${project.build.directory}/jre${compiler.version}/Contents/Home/jre/bin"
                          verbose="true"
                          failonerror="true"
                          overwrite="true"
                          force="true">
                        <fileset dir="${java.home}/bin">
                            <include name="jps${exe.suffix}" />
                            <include name="jstack${exe.suffix}" />
                        </fileset>
                    </copy>
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>



Using jstack running in a shell loop in a terminal session I see that there appears to be a deadlock between the AppKit Thread and the AWT Event Queue:

"AWT-EventQueue-0" #22 prio=6 os_prio=31 cpu=35.56ms elapsed=1.61s allocated=459K defined_classes=113 tid=0x00007f9b571ee000 nid=0x11403 runnable  [0x00007000054d4000]
   java.lang.Thread.State: RUNNABLE
    at sun.awt.CGraphicsDevice.nativeGetScreenInsets([email protected]/Native Method)
    at sun.awt.CGraphicsDevice.getScreenInsets([email protected]/CGraphicsDevice.java:120)
    at sun.lwawt.LWWindowPeer.getDefaultMaximizedBounds([email protected]/LWWindowPeer.java:599)
    at sun.lwawt.LWWindowPeer.getMaximizedBounds([email protected]/LWWindowPeer.java:623)
    - locked <0x000000070110fda8> (a java.lang.Object)
    at sun.lwawt.macosx.CPlatformwindow.maximize([email protected]/CPlatformwindow.java:611)
    at sun.lwawt.macosx.CPlatformwindow.setVisible([email protected]/CPlatformwindow.java:736)
    at sun.lwawt.LWWindowPeer.setVisibleImpl([email protected]/LWWindowPeer.java:293)
    at sun.lwawt.LWComponentPeer.setVisible([email protected]/LWComponentPeer.java:773)
    at java.awt.Component.show([email protected]/Component.java:1678)
    - locked <0x00000007005b9e58> (a java.awt.Component$AWTTreeLock)
    at java.awt.window.show([email protected]/window.java:1049)
    at java.awt.Component.show([email protected]/Component.java:1716)
    at java.awt.Component.setVisible([email protected]/Component.java:1663)
    at java.awt.window.setVisible([email protected]/window.java:1021)
    at com.bbdo.nait.kmonitor.screen.DynamicScreen$2.run(DynamicScreen.java:184)
    at java.awt.event.InvocationEvent.dispatch([email protected]/InvocationEvent.java:313)
    at java.awt.EventQueue.dispatchEventImpl([email protected]/EventQueue.java:770)
    at java.awt.EventQueue$4.run([email protected]/EventQueue.java:721)
    at java.awt.EventQueue$4.run([email protected]/EventQueue.java:715)
    at java.security.AccessController.executePrivileged([email protected]/AccessController.java:753)
    at java.security.AccessController.doPrivileged([email protected]/AccessController.java:391)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege([email protected]/ProtectionDomain.java:85)
    at java.awt.EventQueue.dispatchEvent([email protected]/EventQueue.java:740)
    at java.awt.EventDispatchThread.pumpOneEventForFilters([email protected]/EventDispatchThread.java:203)
    at java.awt.EventDispatchThread.pumpEventsForFilter([email protected]/EventDispatchThread.java:124)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy([email protected]/EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents([email protected]/EventDispatchThread.java:109)
    at java.awt.EventDispatchThread.pumpEvents([email protected]/EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.run([email protected]/EventDispatchThread.java:90)

   Locked ownable synchronizers:
    - None
"AppKit Thread" #18 daemon prio=5 os_prio=31 cpu=214.42ms elapsed=1.94s allocated=340K defined_classes=218 tid=0x00007f9b57173000 nid=0x307 waiting for monitor entry  [0x00007ffee1d6d000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at sun.lwawt.LWComponentPeer.getBounds([email protected]/LWComponentPeer.java:605)
    - waiting to lock <0x000000070110fda8> (a java.lang.Object)
    at sun.lwawt.macosx.CPlatformView.getBounds([email protected]/CPlatformView.java:94)
    at sun.lwawt.macosx.CPlatformView.deliverMouseEvent([email protected]/CPlatformView.java:208)

   Locked ownable synchronizers:
    - None



Is This A Good Question/Topic? 0
  • +

Page 1 of 1