JDK-6921661 : GraphicsDevice.getDisplayMode() returns null and changes screen refresh
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u15
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2010-02-01
  • Updated: 2012-01-16
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Server VM (build 14.1-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.31-17-generic-pae #54-Ubuntu SMP Thu Dec 10 17:23:29 UTC 2009 i686 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
Ubuntu 9.10, Gnome 2.28.1, ATI/AMD proprietary FGLRX graphics driver, ATI Radeon ATI Radeon HD 4200 512MB (embedded on Gigabyte motherboard), Dell UltraScan P780 monitor, 1024x768@75Hz

A DESCRIPTION OF THE PROBLEM :
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = environment.getDefaultScreenDevice();
DisplayMode mode = device.getDisplayMode();

Returned DisplayMode is null (which should not happen, per the documentation). Moreover, the call to getDisplayMode() has caused the screen refresh rate to change from 75Hz to 60Hz. The resolution remains at 1280x1024, but the refresh must be set back to 75Hz via OS/desktop settings. The change in refresh rate also causes the screen to be malformed (which is likely a function of the particular monitor).

This behavior has only been observed under Ubuntu (not under Debian or Windows), but testing has been sparse.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
This bug is intermittent. I believe it to be isolated to calling GraphicsDevice.getDisplayMode() as above. Write a program that creates a JFrame, then checks the display mode, then packs the JFrame and sets it visible. (The purpose of checking the display mode is to obtain the screen resolution to position the JFrame at the center.)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
  Program should be able to check the display mode and obtain the current screen resolution. These operations should not manipulate the local environment (screen mode or resolution).
ACTUAL -
DisplayMode is returned as null and the local screen mode refresh rate is changed to 60Hz.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
The JVM does not report an exception, but the screen mode has been changed.

REPRODUCIBILITY :
This bug can be reproduced rarely.

CUSTOMER SUBMITTED WORKAROUND :
There is no workaround for obtaining the screen resolution. Checking for a null DisplayMode is not a workaround, because the getDisplayMode() method appears to be the destructive call.