AppContext issue in Apple Java 6 -- same issue in Oracle Java 7?

Doug Zwick Doug.Zwick at blackboard.com
Wed Jun 26 15:46:39 PDT 2013


James Tomson wrote:

> We've been experiencing lockup issues with our Java Web Start application
> on MacOSX since the introduction of 7u25. Running with 7u25, our
> application is now invoking swing methods on both the AWT-EventQueue owned
> by our 'main' thread group, as well as a queue instance owned by a
> "javawsApplicationThreadGroup" group.
>
> Now in this situation of dispatching events multiple AWT-EventQueues there
> is a risk of deadlock, and in our case we've seen these fairly frequently
> with 7u25, which renders our app unresponsive and must be forced quit.

I have dug deeper into this, and we are somehow getting our code running on AWT-EventQueue-0 in the "main" ThreadGroup, and not on AWT-EventQueue-2 in the "javawsApplicationThreadGroup" group. One way this will happen is callbacks on the AppKit thread, as we can see in the thread dumps that AWT-AppKit is in the "main" group. However, it is not just our JNI code that can cause this, it looks like the EAWT API for wiring up the About, Preferences and Quit menu items in the application menu will queue their callbacks up on AWT-EventQueue-0 as well, as per this stack trace I generated by instrumenting requests to our Swing invokeLater bottleneck routine:

  @ com.elluminate.platform.macos.MacAppUtils$CocoaEventProxy.handleAbout(MacAppUtils.java:197)
  @ com.apple.eawt._AppEventLegacyHandler$1.dispatchEvent(_AppEventLegacyHandler.java:97)
  @ com.apple.eawt._AppEventLegacyHandler.sendEventToEachListenerUntilHandled(_AppEventLegacyHandler.java:188)
  @ com.apple.eawt._AppEventLegacyHandler.handleAbout(_AppEventLegacyHandler.java:95)
  @ com.apple.eawt._AppEventHandler$_AboutDispatcher.performUsing(_AppEventHandler.java:248)
  @ com.apple.eawt._AppEventHandler$_AboutDispatcher.performUsing(_AppEventHandler.java:242)
  @ com.apple.eawt._AppEventHandler$_AppEventDispatcher$1.run(_AppEventHandler.java:497)
  @ java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
  @ java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
  @ java.awt.EventQueue.access$200(EventQueue.java:103)
  @ java.awt.EventQueue$3.run(EventQueue.java:694)
  @ java.awt.EventQueue$3.run(EventQueue.java:692)
  @ java.security.AccessController.doPrivileged(Native Method)
  @ java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
  @ java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
  @ java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
  @ java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
  @ java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
  @ java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
  @ java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
  @ java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

This call was made on AWT-EventQueue-0, in the "main" ThreadGroup. It looks like the EAWT code needs to be updated to shift into the proper thread group before trying to queue its "_AppEventDispatcher$1" anonymous Runnable on the EDT.

The "Legacy" in "AppEventLegacyHandler" is interesting. I'll have to dig deeper, and verify that we are using the current API for registering the About/Preferences/Quit handlers.

This email and any attachments may contain confidential and proprietary information of Blackboard that is for the sole use of the intended recipient. If you are not the intended recipient, disclosure, copying, re-distribution or other use of any of this information is strictly prohibited. Please immediately notify the sender and delete this transmission if you received this email in error.


More information about the macosx-port-dev mailing list