This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 160063 - ImageUtilities.mergeImages gives error if have bad X display
Summary: ImageUtilities.mergeImages gives error if have bad X display
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: issues@platform
URL: http://deadlock.netbeans.org/hudson/j...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-11 00:49 UTC by Jesse Glick
Modified: 2010-04-01 14:48 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
An attempt to do the merge manually using getRGB (2.55 KB, patch)
2009-03-11 19:01 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2009-03-11 00:49:46 UTC
DISPLAY=whatever ant -f ide.ergonomics/build.xml clean netbeans -v

produces

java.lang.InternalError: Can't connect to X11 window server using 'whatever' as the value of the DISPLAY variable.
	at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
	at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
	at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
	at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:89)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at java.awt.Toolkit$2.run(Toolkit.java:834)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
	at org.openide.util.ImageUtilities.ensureLoaded(ImageUtilities.java:529)
	at org.openide.util.ImageUtilities.doMergeImages(ImageUtilities.java:560)
	at org.openide.util.ImageUtilities.mergeImages(ImageUtilities.java:183)
	at org.netbeans.modules.ide.ergonomics.ant.IconResource.getInputStream(IconResource.java:77)
	at org.apache.tools.ant.util.ResourceUtils.copyResource(ResourceUtils.java:372)
	at org.apache.tools.ant.taskdefs.Copy.doResourceOperations(Copy.java:888)
	at org.apache.tools.ant.taskdefs.Copy.execute(Copy.java:511)
	at org.netbeans.modules.ide.ergonomics.ant.ExtractLayer.execute(ExtractLayer.java:276)
....

(It is OK if $DISPLAY is simply unset.)

Probably ImageUtilities methods should be made to avoid loading the default toolkit or graphics environment if at all
possible. Especially in this case, the error is silly because the image was simply loaded from disk using ImageIO; there
is no reason to depend on the AWT toolkit at all.
Comment 1 Jesse Glick 2009-03-11 01:05:14 UTC
I imagine IconResource could just use BufferedImage.get/setRGB methods to directly compute the overlay.

(Not sure why the X display on the NB-Core-Build job suddenly became bad to begin with, but it shouldn't cause the
regular build to fail. Likely would have broken C/V later.)
Comment 2 Jesse Glick 2009-03-11 17:50:44 UTC
Various builds are now (randomly?) failing on deadlock because of this, e.g.

http://deadlock.netbeans.org/hudson/job/profiler-main/417/consoleText

....
Copying 34 resources to
/hudson/workdir/jobs/profiler-main/workspace/ide.ergonomics/build/classes/org/netbeans/modules/ide/ergonomics/apisupport
_X11TransSocketOpen: socket() failed for local
_X11TransSocketOpenCOTSClient: Unable to open socket for local
_X11TransOpen: transport open failed for local/deadlock.nbextras.org:11
Failed to build target: all-ide.ergonomics

BUILD FAILED
/hudson/workdir/jobs/profiler-main/workspace/nbbuild/build.xml:675: The following error occurred while executing this line:
/hudson/workdir/jobs/profiler-main/workspace/nbbuild/build.xml:670: The following error occurred while executing this line:
/hudson/workdir/jobs/profiler-main/workspace/nbbuild/build.xml:717: The following error occurred while executing this line:
/hudson/workdir/jobs/profiler-main/workspace/ide.ergonomics/build.xml:110: The following error occurred while executing
this line:
/hudson/workdir/jobs/profiler-main/workspace/ide.ergonomics/build.xml:199: java.lang.InternalError: Can't connect to X11
window server using ':11' as the value of the DISPLAY variable.

What the root problem is - why Toolkit.getDefaultToolkit fails in this environment - I have no idea. But it is worth at
least checking whether fixing this issue would allow the build to continue and even pass C/V.
Comment 3 Jaroslav Tulach 2009-03-11 19:01:45 UTC
Created attachment 78069 [details]
An attempt to do the merge manually using getRGB
Comment 4 Jaroslav Tulach 2009-03-11 19:03:16 UTC
The only open problem is that to find out that some pixel in BufferedImage is "empty". Open the 
ide.ergonomics/src/**/badge.png to see what it means "empty".
Comment 5 Jesse Glick 2009-03-11 20:45:01 UTC
Fixing ide.ergonomics to do its own blending without IU.mI. Confirming that this makes the module build even with
DISPLAY=broken. Leaving open in case we decide that IU.mI itself should be improved.

core-main #c4902c16114f
Comment 6 Jaroslav Tulach 2009-03-12 08:56:46 UTC
Thanks for "packARGB(overARGB(unpackARGB(b), unpackARGB(m)))". I hope I will never need to touch that code.
Comment 7 Quality Engineering 2009-03-12 09:58:17 UTC
Integrated into 'main-golden', will be available in build *200903120302* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c4902c16114f
User: Jesse Glick <jglick@netbeans.org>
Log: #160063: implement alpha blending directly, without requiring java.awt.Toolkit.
Comment 8 Jesse Glick 2009-03-12 16:33:34 UTC
I hope I won't either! It was a fun afternoon nonetheless.