JDK-8223158 : Docked MacBook cannot start any Java Swing applications
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,9,10,11,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-04-30
  • Updated: 2021-04-12
  • Resolved: 2019-10-12
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 11 JDK 8 Other 8u231Fixed openjdk8u252Fixed
A MacBook Pro (15-inch, Late 2016) running on MacOS Mojave 10.14.3 with
DisplayLink Driver 5.1 for the Dell Dock D6000.

A single external monitor with 1920x1200 resolution via a DisplayPort Adapter
is attached to the dock.

When the macBook is connected to the dock and the lid is closed, no Java
Swing based application using JDK8 or JDK11 or JDK12 will start. However, it
works with JDK7.
Fix Request (13u): need it here. Applies cleanly.

Fix request (8u) Backport for parity with Oracle. Applies clean.

Fix request (11u) I would like to downport this for parity with 11.0.7-oracle. Applies clean.

glMask=2 value was given by customer, through logs generated while running their app, where the environment to reproduce this issue is present. I am not able to reproduce this issue locally due to lack of hardware needed, so have to rely on customer to give us the logs which we analysed and gave them the fix.

URL: https://hg.openjdk.java.net/jdk/jdk/rev/70968bcc110c User: psadhukhan Date: 2019-10-15 09:43:32 +0000

Comment from DisplayLink Driver developer: ============================================== Just comment to the update of ............ I wonder how you got the "glMask =2" From my experience, the kind of value indicates that this is Display that is not drived by DisplayLink(which has glMask like (2048, 4096, ..). Either this is issue of macOS, or glMask=2 value is wrong as it belongs to non-DisplayLink display. Maybe it is outdated glMask of display that was closed. As stated in point 3("close the lid of the MacBook") ===============================================

URL: https://hg.openjdk.java.net/jdk/client/rev/70968bcc110c User: psadhukhan Date: 2019-10-12 03:20:22 +0000

fix is on review: http://mail.openjdk.java.net/pipermail/2d-dev/2019-October/010333.html http://cr.openjdk.java.net/~psadhukhan/8223158/webrev.2/

It was found GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration() is returning null in this particular setup. Since it was difficult to reproduce locally, enabling tracing reveals that CGLGraphicsConfig#getCGLConfigInfo() was failing in NSOpenGLPixelFormat.initWithAttributes() Appkit documentation https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=objc says that it will return "nil if an object with the desired attributes could not be initialized". Now, when the main display is closed, the CGDisplayIDToOpenGLDisplayMask(displayID) is returning 2 as glMask which when passed as an attribute to NSOpenGLPixelFormat, it fails to initialize. Normally, with main Display being used, glMask is 1. Proposed fix is to see if first initialization fails, then retry initialization without the offending glMask value for NSOpenGLPFAScreenMask attributes, as documentation https://developer.apple.com/documentation/appkit/1436213-opengl_pixel_format_attributes/nsopenglpfascreenmask?language=objc says "All screens specified in the bit mask are guaranteed to be supported by the pixel format.", so if it is not guranteed to be supported, initAttributes() might fail.

Submitter says only "JDK7" and "JDK8" so until someone gets more details, I think we should assume it affects 8 GA, not just 8u211. But clarification on that would be a good thing to get from the user, since it seems unlikely anyone will be able to quickly get hold of the hardware necessary to verify this.

Steps to reproduce with a simple java code ------------------------------------------------------- 1. attach the MacBook to the dock 2. attach an external monitor to the dock 3. close the lid of the MacBook 4. run "javac Demo2.java" 5. run "java Demo2"