JDK-7167639 : Per-pixel translucent windows incorrect color rendering with ATI video drivers
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86
  • Submitted: 2012-05-09
  • Updated: 2018-09-05
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
tbdUnresolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)

but the problem happens indifferently under 32 or 64 bit JVMs, and also with 1.7 previous versions (e.g. 1.7.0_03).

ADDITIONAL OS VERSION INFORMATION :
-Linux  Ubuntu x86_64    3.0.0-19-generic  SMP  GNU/Linux
-Linux  OpenSuse x86_64    3.1.10-1.9-desktop  SMP PREEMPT  GNU/Linux

but I guess pretty much any native Linux distro with fglrx AMD ATI video drivers installed.

EXTRA RELEVANT SYSTEM CONFIGURATION :
Video Card:  ATI Radeon HD 5770  [Radeon HD 5700 Series].

A DESCRIPTION OF THE PROBLEM :
The symptoms are exactly the same as bug 6782013, so please read here:
http://bugs.sun.com/view_bug.do;jsessionid=5915497d257d8eae1736a87de5?bug_id=6782013
 
(to be complete I will add that, when the transparent window in question is placed on top of a black background, the windows appears as desired).

The only difference with 6782013 is, this time, the bug is not caused by Compiz or any other window manager (for example, it happens also on metacity, with the compositing manager feature enabled).
It is rather due to the presence of the AMD ATI video drivers (which, on the other hand, are needed for 3d acceleration).

When you remove any fglrx video driver present on the system (either installed via the official AMD ATI .run package or the proprietary drivers installation choice in Ubuntu), the problem disappears.
I have tested other system parameters and tried many different programming techniques, but no other change makes the difference as the removal of the above-mentioned drivers.

Please note that, under a native Windows host (in my case, Windows 7 x64 sp1, tested with any of the latest ATI video drivers version installed), the problem also occurs on Oracle-VirtualBox Linux guests which have VirtualBox additions installed only and no fglrx driver present.
This, added to the fact that the bug does not take place at all under a native Windows OS JVM, seems to enforce the idea that the problem is somehow due to the interaction between the Linux JVM and the ATI video drivers.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the code indicated below. Then open any window with white background or change desktop background to white.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Please take a look at these screenshots (they show the correct output of a java program which uses per-pixel transparency under native Windows):
http://setedivento.altervista.org/Working1.png
http://setedivento.altervista.org/Working2.png
ACTUAL -
The same output on a Linux machine with the discussed configuration:
http://setedivento.altervista.org/NotWorking1.png
http://setedivento.altervista.org/NotWorking2.png

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
[Pretty much any code that deals with per-pixel transparent windows, but I prefer to paste the one available in bug 6782013 because it underlines the behaviour is not GraphicsConfiguration nor Double-buffering dependant]


package demo;

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

import javax.swing.*;

import com.sun.awt.AWTUtilities;
import com.sun.awt.AWTUtilities.Translucency;

public class TranslucencyTest {

	@SuppressWarnings("serial")
	public static void main(String[] args) {
		AWTUtilities.isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT);
		GraphicsConfiguration gc = findTranslucencyGC();
		JFrame window = new JFrame(gc);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.setUndecorated(true);
		window.setSize(500, 500);
		AWTUtilities.setWindowOpaque(window, false);

		JPanel panel = new JPanel() {
			protected void paintComponent(Graphics g) {
				if (g instanceof Graphics2D) {
					final int R = 50;
					final int G = 50;
					final int B = 200;

					Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B,
							0), getWidth(), getHeight(),
							new Color(R, G, B, 255), true);
					Graphics2D g2d = (Graphics2D) g;
					g2d.setPaint(p);
					g2d.fillRect(0, 0, getWidth(), getHeight());
				} else {
					super.paintComponent(g);
				}
			}
		};
		panel.setDoubleBuffered(false);
		panel.setOpaque(false);
		
		JButton close = new JButton("Close Application");
		close.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		
		panel.add(close);
		
		window.getContentPane().add(panel);
		window.setVisible(true);
	}

	private static GraphicsConfiguration findTranslucencyGC() {
		GraphicsEnvironment env = GraphicsEnvironment
				.getLocalGraphicsEnvironment();
		GraphicsDevice[] devices = env.getScreenDevices();

		for (GraphicsDevice device : devices)
			for (GraphicsConfiguration config : device.getConfigurations())
				if (AWTUtilities.isTranslucencyCapable(config))
					return config;

		return null;
	}
}
---------- END SOURCE ----------

Comments
We are fixing issues on priority starting with issues reported on 9 and 8u builds. All other issues reported on older jdk versions are marked with tbd_major for now.
25-05-2016

Does it affect JDK 9 ?
22-07-2015