Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4417795

GraphicsEnvironment does not detect when multiple monitors are added/removed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.4.0, 1.4.2_03
    • client-libs
    • x86
    • windows_2000

    Description

      On multimonitor capable win32 systems, GraphicsEnvironment only correctly identifies monitors present when a Java app is started up. Monitors added or removed using Display Settings are not identified by GraphicsEnvironment. The following test can be used to reproduce this problem.

      --AddDisplayTest.java--

      import java.awt.*;
      import java.awt.event.*;

      public class AddDisplayTest extends Frame implements ActionListener {
          public static void main(String args[]) {
              AddDisplayTest f = new AddDisplayTest();
              Button b = new Button("Count Displays");
              b.addActionListener(f);
              f.add(b);
              f.pack();
              f.show();
          }

          public AddDisplayTest() {
              super("AddDisplayTest");
          }

          public void actionPerformed(ActionEvent e) {
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice[] gds = ge.getScreenDevices();
              System.out.println(gds.length + " screens detected:");
              for (int i = 0; i < gds.length; i++) {
                  System.out.println(" " + gds[i]);
              }
          }
      }


      ###@###.### 2004-04-16

      BEA reports this problem which we suspect is due to the same bug. The bug results in a VM crash:

      When attaching via windows remote desktop to a workstation. If that workstation already has an instance of the Workshop IDE running, certain circumstances will produce a JVM crash.
       
      Specifically, if the workstation is dual montior enabled (not necessarily having two attached, but merely being capable of having two), and the machine that is attaching to the workstation is not dual monitor enabled,

      GraphicsEnvironment.getScreenDevices() still returns an array of two objects.
      Calling getScreenBounds() on the second member of the array crashes the VM with an Access Violation.
       
      Attached, you will find a Test.java program i used to attempt to repro this problem. Unforutnately, virtually every machine in our office is dual monitor enabled, so i couldn't repro the crash. However, the information returned by getScreenDevices() is patently incorrect in several circumstances that are easy to repro.
       
      The simple program, Test.java pops up a frame with a button that dumps screen information to the console. It iterates over the screen devices and prints a name and bounds rectangle.

      On a dual monitor system, if you disable one monitor, and start the app, you'll see one device listed when you press the button. if you re-enable the second monitor (without restarting the app), you'll still see only one device listed when the button is pressed.

      If you start the app while both monitors are enabled, you'll see both when you press the button. When you disable one and press the button, you'll still see two listed, but the screen coordinates of the first and second are now the same.
       
      My belief is that if there is NO dual monitor support, attempting to access the second screen device through the remote-desktop instance will crash theVM.
      there is no workaround that i can detect other than NOT calling
       
      There is no way for me to know that accessing the second device will cause a crash. The entire app simply disappears.
       
      Also attached is an hs_pid*.log file with the crash information.


      ****
      Any swing based application can be used to reproduce the crash. Make sure your host has more
      than one screen device. To reproduce run the app on the host and connect to host using MS remote
      desktop client. The crash happens momentarily.
      ###@###.### 10/18/04 22:58 GMT

      Attachments

        Issue Links

          Activity

            People

              art Artem Ananiev (Inactive)
              bchristi Brent Christian
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: