JDK-8049901 : Graphics2D.drawLine sometimes draws lines too long with D3D on Intel HD cards
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2014-07-09
  • Updated: 2014-12-15
  • Resolved: 2014-12-15
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.
Other
tbd_majorResolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Display adapter: Intel(R) Iris(TM) Pro Graphics 5200

A DESCRIPTION OF THE PROBLEM :
Horizontal and vertical lines are sometimes drawn one pixel longer than they should be.

Having noticed this issue myself immediately upon moving to Java 8, I am opening this report with additional information as requested by the comments on https://bugs.openjdk.java.net/browse/JDK-8035278


ADDITIONAL REGRESSION INFORMATION: 
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run a program that draws horizontal and/or vertical lines with Graphics2D.drawLine (or methods that uses this method, like drawRect), as in the code provided.

2. Maximize the window.  Observe the horizontal and vertical lines now being drawn one pixel longer than they should be.

3. Keep resizing and/or moving the window around, and continue to observe: at times, the lines are drawn correctly, and at times, they are drawn one pixel too long.

Note: step #2 (maximizing) is in no way required to induce the behavior, but the bug consistently occurs the first time the window is maximized.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Lines should be drawn consistently as specified when calling drawLine, regardless of window size (assuming not too small) or position on screen.
ACTUAL -
Horizontal and vertical lines are occasionally drawn one pixel longer than specified.  As the window is resized or moved around, the lines intermittently change between being drawn correctly and being drawn too long.

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;

public class DrawLineBugDemo {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame f = new JFrame();

                f.add(new JPanel() {
                    @Override
                    protected void paintComponent(Graphics g) {
                        super.paintComponent(g);

                        // Draw rectangle (buggy: sometimes not a rectangle)
                        g.drawRect(1, 1, 20, 20);

                        // Draw every other pixel (just for visual reference)
                        for (int i = 3; i < 20; i += 2) {
                            g.drawLine(3, i, 3, i);
                            g.drawLine(i, 3, i, 3);
                        }

                        // Draw lines of three different lengths
                        for (int i = 0; i < 3; ++i) {
                            // Horizontal (buggy: for i > 0, sometimes drawn a pixel too long)
                            int x = 7;
                            int y = 7 + i * 2;
                            g.drawLine(x, y, x + i, y);

                            // Vertical (buggy: for i > 0, sometimes drawn a pixel too long)
                            x = 13 + i * 2;
                            y = 7;
                            g.drawLine(x, y, x, y + i);

                            // Diagonal (seems okay)
                            x = 7 + i * 4;
                            y = 15;
                            g.drawLine(x, y, x + i, y + i);
                        }
                    }
                });

                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setSize(150, 100);
                f.setVisible(true);
            }
        });
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Problem is not observed when running with -Dsun.java2d.d3d=false


Comments
Update: the submitter also sees this on an HD 4000 card on which we enable D3D as below :- [I] D3DInitializer::InitImpl [I] OS Version = OS_WINDOWS7 or newer [I] CheckAdaptersInfo [I] ------------------ [I] Adapter Ordinal : 0 [I] Adapter Handle : 0x10001 [I] Description : Intel(R) HD Graphics 4000 [I] GDI Name, Driver : \\.\DISPLAY5, igdumdim64.dll [I] Vendor Id : 0x8086 [I] Device Id : 0x0162 [I] SubSys Id : 0xd0001458 [I] Driver Version : 10.18.10.3621 [I] GUID : {D7B78E66-4222-11CF-CD79-0AF0B4C2C735} [I] D3DPPLM::CheckDeviceCaps: adapter 0: Passed [I] ------------------ [I] D3DGD_getDeviceCapsNative [I] D3DContext::InitContext device 0 [I] D3DContext::ConfigureContext device 0 [V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING [I] D3DContext::ConfigureContext: successfully created device: 0 [I] D3DContext::InitDevice: device 0 [I] D3DContext::InitDefice: successfully initialized device 0 [V] | CAPS_DEVICE_OK [V] | CAPS_RT_PLAIN_ALPHA [V] | CAPS_RT_TEXTURE_ALPHA [V] | CAPS_RT_TEXTURE_OPAQUE [V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20 [V] | CAPS_AA_SHADER [V] | CAPS_PS30 [V] | CAPS_MULTITEXTURE [V] | CAPS_TEXNONPOW2 [V] | CAPS_TEXNONSQUARE [I] D3DInitializer::CleanImpl (normal)
14-07-2014

from the submitter :- Thanks for looking into this! Results before upgrading to the latest driver: [I] D3DInitializer::InitImpl [I] OS Version = OS_WINDOWS7 or newer [I] CheckAdaptersInfo [I] ------------------ [I] Adapter Ordinal : 0 [I] Adapter Handle : 0x10001 [I] Description : Intel(R) Iris(TM) Pro Graphics 5200 [I] GDI Name, Driver : \\.\DISPLAY1, igdumdim64.dll [I] Vendor Id : 0x8086 [I] Device Id : 0x0d22 [I] SubSys Id : 0xd0001458 [I] Driver Version : 10.18.10.3412 [I] GUID : {D7B78E66-4E62-11CF-BC7A-0AF0B5C2C735} [I] D3DPPLM::CheckDeviceCaps: adapter 0: Passed [I] ------------------ [I] Adapter Ordinal : 1 [I] Adapter Handle : 0x10003 [I] Description : Intel(R) Iris(TM) Pro Graphics 5200 [I] GDI Name, Driver : \\.\DISPLAY2, igdumdim64.dll [I] Vendor Id : 0x8086 [I] Device Id : 0x0d22 [I] SubSys Id : 0xd0001458 [I] Driver Version : 10.18.10.3412 [I] GUID : {D7B78E66-4E62-11CF-BC7A-0AF0B5C2C735} [I] D3DPPLM::CheckDeviceCaps: adapter 1: Passed [I] ------------------ [I] D3DGD_getDeviceCapsNative [I] D3DContext::InitContext device 0 [I] D3DContext::ConfigureContext device 0 [V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING [I] D3DContext::ConfigureContext: successfully created device: 0 [I] D3DContext::InitDevice: device 0 [I] D3DContext::InitDefice: successfully initialized device 0 [V] | CAPS_DEVICE_OK [V] | CAPS_RT_PLAIN_ALPHA [V] | CAPS_RT_TEXTURE_ALPHA [V] | CAPS_RT_TEXTURE_OPAQUE [V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20 [V] | CAPS_AA_SHADER [V] | CAPS_PS30 [V] | CAPS_MULTITEXTURE [V] | CAPS_TEXNONPOW2 [V] | CAPS_TEXNONSQUARE [I] D3DGD_getDeviceCapsNative [I] D3DContext::InitContext device 1 [I] D3DContext::ConfigureContext device 1 [V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING [I] D3DContext::ConfigureContext: successfully created device: 1 [I] D3DContext::InitDevice: device 1 [I] D3DContext::InitDefice: successfully initialized device 1 [V] | CAPS_DEVICE_OK [V] | CAPS_RT_PLAIN_ALPHA [V] | CAPS_RT_TEXTURE_ALPHA [V] | CAPS_RT_TEXTURE_OPAQUE [V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20 [V] | CAPS_AA_SHADER [V] | CAPS_PS30 [V] | CAPS_MULTITEXTURE [V] | CAPS_TEXNONPOW2 [V] | CAPS_TEXNONSQUARE [I] D3DInitializer::CleanImpl (normal) Results using the latest driver (5/21/2014) -- unfortunately, the behavior described in the bug report persists: [I] D3DInitializer::InitImpl [I] OS Version = OS_WINDOWS7 or newer [I] CheckAdaptersInfo [I] ------------------ [I] Adapter Ordinal : 0 [I] Adapter Handle : 0xd5cb066f [I] Description : Intel(R) Iris(TM) Pro Graphics 5200 [I] GDI Name, Driver : \\.\DISPLAY5, igdumdim64.dll [I] Vendor Id : 0x8086 [I] Device Id : 0x0d22 [I] SubSys Id : 0xd0001458 [I] Driver Version : 10.18.10.3621 [I] GUID : {D7B78E66-4E62-11CF-CD79-0AF0B5C2C735} [I] D3DPPLM::CheckDeviceCaps: adapter 0: Passed [I] ------------------ [I] Adapter Ordinal : 1 [I] Adapter Handle : 0xc60075d [I] Description : Intel(R) Iris(TM) Pro Graphics 5200 [I] GDI Name, Driver : \\.\DISPLAY6, igdumdim64.dll [I] Vendor Id : 0x8086 [I] Device Id : 0x0d22 [I] SubSys Id : 0xd0001458 [I] Driver Version : 10.18.10.3621 [I] GUID : {D7B78E66-4E62-11CF-CD79-0AF0B5C2C735} [I] D3DPPLM::CheckDeviceCaps: adapter 1: Passed [I] ------------------ [I] D3DGD_getDeviceCapsNative [I] D3DContext::InitContext device 0 [I] D3DContext::ConfigureContext device 0 [V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING [I] D3DContext::ConfigureContext: successfully created device: 0 [I] D3DContext::InitDevice: device 0 [I] D3DContext::InitDefice: successfully initialized device 0 [V] | CAPS_DEVICE_OK [V] | CAPS_RT_PLAIN_ALPHA [V] | CAPS_RT_TEXTURE_ALPHA [V] | CAPS_RT_TEXTURE_OPAQUE [V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20 [V] | CAPS_AA_SHADER [V] | CAPS_PS30 [V] | CAPS_MULTITEXTURE [V] | CAPS_TEXNONPOW2 [V] | CAPS_TEXNONSQUARE [I] D3DGD_getDeviceCapsNative [I] D3DContext::InitContext device 1 [I] D3DContext::ConfigureContext device 1 [V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING [I] D3DContext::ConfigureContext: successfully created device: 1 [I] D3DContext::InitDevice: device 1 [I] D3DContext::InitDefice: successfully initialized device 1 [V] | CAPS_DEVICE_OK [V] | CAPS_RT_PLAIN_ALPHA [V] | CAPS_RT_TEXTURE_ALPHA [V] | CAPS_RT_TEXTURE_OPAQUE [V] | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20 [V] | CAPS_AA_SHADER [V] | CAPS_PS30 [V] | CAPS_MULTITEXTURE [V] | CAPS_TEXNONPOW2 [V] | CAPS_TEXNONSQUARE [I] D3DInitializer::CleanImpl (normal) I've also attached zoomed-in screenshots showing the issue.
11-07-2014

We previously : http://mail.openjdk.java.net/pipermail/2d-dev/2013-December/004058.html blacklisted everything except HD 4000 and newer but that was apparently not enough.
10-07-2014

http://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units has a list of device ids for haswell gpus. I don't know how complete it although someone with a very new macbook reports 0x0a2e as the device id which does appear on the list. We may have to blacklist all these device ids for bad drivers but unless we can find a driver version that works its back to turning it off completely for vendor == intel.
10-07-2014

Definitely an Intel HD specific problem. Works fine on my ATI card. The HD5200 is very new and 6.3.9600 is the latest version of Windows ie Windows 8.1 So this doesn't look promising for D3D on that chipset. I'll have to see if anyone with an earlier Intel chip can reproduce.
10-07-2014