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

java.awt.SplashScreen.getSize() returns incorrect size for high dpi splash screens

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u92
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b124
    • CPU:
      x86
    • OS:
      other

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_91"
        Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
        Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Darwin saotome.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

        A DESCRIPTION OF THE PROBLEM :
        When a high-dpi splashscreen is available (e.g. splash.png and splash@2x.png), the SplashScreen#getSize() and SplashScreen#getBounds methods return an incorrect size.

        This is most likely caused by an incorrect implementation of the SplashScreen#getBounds method when the scale factor is applied:

                    if (scale > 0 && scale != 1) {
                        bounds.setSize((int) (bounds.getWidth() / scale),
                                (int) (bounds.getWidth() / scale));
                    }


        This should become

                    if (scale > 0 && scale != 1) {
                        bounds.setSize((int) (bounds.getWidth() / scale),
                                (int) (bounds.getHeight() / scale));
                    }

        Regression was introduced in this commit: http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/4fa603c72f2f

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        - Compile the attached class (SplashScreenTest)
        - Create a non-square regular and retina splash screen image (e.g. https://raw.githubusercontent.com/JetBrains/intellij-community/master/community-resources/src/idea_community_about.png and https://raw.githubusercontent.com/JetBrains/intellij-community/master/community-resources/src/idea_community_about%402x.png)
        - Run the application on a high-dpi device (e.g. a recent Macbook) and specify the splash screen using -splash:path/to/splash.png

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The reported width and height of the splash screen are not the same, as the source image is a non-square image
        ACTUAL -
        The reported width and height of the splash screen are the same

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.Dimension;
        import java.awt.EventQueue;
        import java.awt.SplashScreen;

        import javax.swing.JFrame;
        import javax.swing.JLabel;
        import javax.swing.WindowConstants;

        public class SplashScreenTest {
          public static void main(String[] args) throws Exception{
            SplashScreen splashScreen = SplashScreen.getSplashScreen();
            Dimension size = splashScreen.getSize();
            System.out.println("size = " + size);
            if ( (size.getWidth() == size.getHeight())){
              throw new RuntimeException("Width and height of the splash screen are the same, which shouldn't be the case");
            }
            Thread.sleep(2000);
            EventQueue.invokeLater(new Runnable() {
              @Override
              public void run() {
                showUI();
              }
            });
          }

          private static void showUI(){
            JFrame frame = new JFrame("Test");
            frame.getContentPane().add(new JLabel("Label"));
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            frame.setVisible(true);
          }
        }

        ---------- END SOURCE ----------

          Issue Links

            Activity

            Hide
            alexsch Alexander Scherbatiy added a comment - - edited
            The issue is resolved in the fix JDK-8145174

            But the proposed test can be contributed under this bug id.
            See discussion: http://mail.openjdk.java.net/pipermail/awt-dev/2016-May/011380.html
            Webrev: http://cr.openjdk.java.net/~alexsch/robin.stevens/8158178/webrev.00/
            Show
            alexsch Alexander Scherbatiy added a comment - - edited The issue is resolved in the fix JDK-8145174 But the proposed test can be contributed under this bug id. See discussion: http://mail.openjdk.java.net/pipermail/awt-dev/2016-May/011380.html Webrev: http://cr.openjdk.java.net/~alexsch/robin.stevens/8158178/webrev.00/
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/b00c1ad05f98
            User: alexsch
            Date: 2016-06-07 16:15:21 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/b00c1ad05f98 User: alexsch Date: 2016-06-07 16:15:21 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/b00c1ad05f98
            User: lana
            Date: 2016-06-22 19:53:10 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/b00c1ad05f98 User: lana Date: 2016-06-22 19:53:10 +0000

              People

              • Assignee:
                alexsch Alexander Scherbatiy
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: