JDK-8176490 : [macosx] Sometimes NSWindow.isZoomed hangs
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u121,9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2017-03-10
  • Updated: 2017-11-29
  • Resolved: 2017-03-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 JDK 9
10Fixed 8u152Fixed 9 b166Fixed
Related Reports
Relates :  
Description
Discussion at AWT mailing list - http://mail.openjdk.java.net/pipermail/awt-dev/2017-March/012661.html

Steps to reproduce it with attached WindowTest.java, maybe you need 2-3 attempts:

(0. start the demo program)
1. click on the button in the first window ; a second window opens
2. click on the button in the second dialog ; a third windows open
3. move the third window via mouse and click on the label
4. wait 9 seconds ; a fourth windows is opened (the fourth windows should be opened behind the third)
5. try to close the fourth
-> EDT is blocked

The relevant thread stacks are:

"AWT-EventQueue-0" #13 prio=6 os_prio=31 tid=0x00007fa86ea7e000 nid=0xd203 runnable [0x0000700010632000]
   java.lang.Thread.State: RUNNABLE
    at sun.lwawt.macosx.CWrapper$NSWindow.isZoomed(java.desktop@9-ea/Native Method)
    at sun.lwawt.macosx.CPlatformWindow.isMaximized(java.desktop@9-ea/CPlatformWindow.java:509)
    at sun.lwawt.macosx.CPlatformWindow.setVisible(java.desktop@9-ea/CPlatformWindow.java:558)
    at sun.lwawt.LWWindowPeer.setVisibleImpl(java.desktop@9-ea/LWWindowPeer.java:253)
    at sun.lwawt.LWComponentPeer.setVisible(java.desktop@9-ea/LWComponentPeer.java:763)
    at java.awt.Component.hide(java.desktop@9-ea/Component.java:1705)
    - locked <0x00000007a48a2c20> (a java.awt.Component$AWTTreeLock)
    at java.awt.Window.hide(java.desktop@9-ea/Window.java:1118)
    at java.awt.Dialog.hide(java.desktop@9-ea/Dialog.java:1152)
    at java.awt.Window.hide(java.desktop@9-ea/Window.java:1110)
    - locked <0x00000007a802e218> (a java.util.Vector)
    at java.awt.Dialog.hide(java.desktop@9-ea/Dialog.java:1152)
    at java.awt.Component.show(java.desktop@9-ea/Component.java:1670)
    at java.awt.Component.setVisible(java.desktop@9-ea/Component.java:1615)
    at java.awt.Window.setVisible(java.desktop@9-ea/Window.java:1017)
    at java.awt.Dialog.setVisible(java.desktop@9-ea/Dialog.java:1005)
    
"AppKit Thread" #11 daemon prio=5 os_prio=31 tid=0x00007fa87076b000 nid=0x307 waiting for monitor entry [0x00007fff5e87e000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.awt.Window.getOwnedWindows_NoClientCode(java.desktop@9-ea/Window.java:1478)
    - waiting to lock <0x00000007a802e218> (a java.util.Vector)
    at java.awt.Window$1.getOwnedWindows(java.desktop@9-ea/Window.java:4127)
    at sun.lwawt.macosx.CPlatformWindow.orderAboveSiblingsImpl(java.desktop@9-ea/CPlatformWindow.java:1153)
    at sun.lwawt.macosx.CPlatformWindow.orderAboveSiblings(java.desktop@9-ea/CPlatformWindow.java:1118)
    at sun.lwawt.macosx.CPlatformWindow.windowDidBecomeMain(java.desktop@9-ea/CPlatformWindow.java:1182)

Comments
http://mail.openjdk.java.net/pipermail/awt-dev/2017-March/012717.html
29-03-2017

jdk9-fix-yes: approved by AWT lead.
29-03-2017

jdk9-fix-request: - Justification: Fix for regression introduced into JDK9 by JDK-8169589 - Risk Analysis: Low (small changes in CPlatformWindow class) - Webrev : http://cr.openjdk.java.net/~dmarkov/8176490/webrev.00/ - Testing (done/to-be-done) : Regression test provided with the fix - Back ports (done/to-be-done) : it is necessary to back port the fix to JDK8u - Fix For Release : JDK 9
28-03-2017

Review - http://mail.openjdk.java.net/pipermail/awt-dev/2017-March/012708.html
28-03-2017

Possible fix: Add a new field isZoomed to CPlatformWindow class. The field will contain information about current zoom state for the window. The method deliverMoveResizeEvent() will update the new field using data from the platform. The invocations of CWrapper.NSWindow.isZoomed() in CPlatformWindow should be replaced with isZoomed field.
23-03-2017

Most likely the deadlock was triggered by JDK-8169589, since it introduced new window ordering behaviour, (i.e. added invocation of Window.getOwnedWindows_NoClientCode()).
23-03-2017

Problem description: On OSX AppKit thread and EDT or main application thread might be blocked when a child window is displayed and its parent is hidden at the same time (see stack traces above). AppKit thread performs windows ordering caused by displaying of the child windows. It retrieves child windows for the parent window and tries to acquire the monitor inside Window.getOwnedWindows_NoClientCode(). However the monitor is already owned by EDT/main application thread which executes setVisible(false) on the parent window. That thread hangs on invocation of CWrapper.NSWindow.isZoomed() since the function must be executed on AppKit thread.
23-03-2017

Does it affect 8 GA ?
10-03-2017

This is not a P2 stopper, so deferred to 10 as we are on RDP2 phase for JDK 9
10-03-2017