Recent Changes - Search:

edit SideBar

PDF-renderer

In the Utilities menu in vergil, PDFAttribute triggers an exception under Java 1.8. Edward saw this exception under Mac OS 10.9, Christopher has not seen it under 10.7

However, running "cd $PTII/doc/test/junit; make" causes problems under Mac OS X and Linux.

       Force everything to get expanded ptolemy/configs/full/configuration.xml
    (Skipping certain optional packages)
    If you get a 'X connection to xxx:11.0 broken' message, then
    see $PTII/ptolemy/moml/filter/RemoveGraphicalClasses.java
    Or, under Solaris, run java -verbose -classpath
           ${PTII}/lib/ptjacl.jar:${PTII}/lib/diva.jar:${PTII}
           tcl.lang.Shell xxx.tcl
java.awt.color.CMMException: LCMS error 13: Couldn't link the profiles
        at sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native Method)
        at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:156)
        at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
        at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
        at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)
        at com.sun.pdfview.colorspace.PDFColorSpace.getPaint(PDFColorSpace.java:222)
        at com.sun.pdfview.PDFParser.iterate(PDFParser.java:656)
        at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
        at java.lang.Thread.run(Thread.java:745)

Also, under Mac OS X, "It occurred just building a simple SDF model... Open a few libraries and perform a search."

java.awt.color.CMMException: LCMS error 13: Couldn't link the profiles
    at sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native Method)
    at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:156)
    at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
    at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
    at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)
    at com.sun.pdfview.colorspace.PDFColorSpace.getPaint(PDFColorSpace.java:222)
    at com.sun.pdfview.PDFParser.iterate(PDFParser.java:656)
    at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
    at java.lang.Thread.run(Thread.java:745)
java.awt.color.CMMException: LCMS error 13: Couldn'
t link the profiles
    at sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native Method)
    at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:156)
    at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
    at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
    at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)
    at com.sun.pdfview.colorspace.PDFColorSpace.getPaint(PDFColorSpace.java:222)
    at com.sun.pdfview.PDFParser.iterate(PDFParser.java:656)
    at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
    at java.lang.Thread.run(Thread.java:745)

We are running PDF-renderer from https://java.net/projects/pdf-renderer. That tree has not been modified recently.

Line 222 of PDFColorSpace.java is marked below:

   /**                                                                                                              
     * get the PDFPaint representing the color described by the                                                      
     * given color components                                                                                        
     * @param components the color components corresponding to the given                                            
     * colorspace                                                                                                    
     * @return a PDFPaint object representing the closest Color to the                                              
     * given components.                                                                                            
     */

    public PDFPaint getPaint(float[] components) {
--->     float[] rgb = cs.toRGB(components);

        return PDFPaint.getColorPaint(new Color(rgb[0], rgb[1], rgb[2]));
    }

https://issues.apache.org/jira/browse/PDFBOX-2454 leads to https://issues.apache.org/jira/browse/PDFBOX-2184, which says:

"I have a new theory, this could be a race condition in Java's CMM code caused by lazy initialisation, which would explain why we don't get an error until toRGB is called. The Open JDK code for ICC_ColorSpace.java clearly uses lazy initialisation of the color transform object:"

 159       public float[]    toRGB (float[] colorvalue) {
  160  
  161           if (this2srgb == null) {
  162               ColorTransform[] transformList = new ColorTransform [2];
  163               ICC_ColorSpace srgbCS =
  164                   (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB);
  165               PCMM mdl = CMSManager.getModule();
  166               transformList[0] = mdl.createTransform(
  167                   thisProfile, ColorTransform.Any, ColorTransform.In);
  168               transformList[1] = mdl.createTransform(
  169                   srgbCS.getProfile(), ColorTransform.Any, ColorTransform.Out);
  170               this2srgb = mdl.createTransform(transformList);
  171               if (needScaleInit) {
  172                   setComponentScaling();
  173               }
  174           }
  175           ...

"I've added a call to toRGB in the constructor of PDDeviceCMYK() which is called statically and so will be thread safe. Hopefully this will prevent the race condition because it will cause "this2srgb" to be initialised."
 2 down vote accepted


Add a hook on JVM start. In the hook, just put :

Class.forName("javax.imageio.ImageIO");

This will force the class loader to load the class and do whatever static initialization it needs. I think your problem is the class is being loaded on a thread, and the 2nd thread is trying to use ImageIO, which cause a clash on locks (or lackof locks) obtained on color profiles.

Edit: You can add this line to your main too. Make sure it's the first line you call. ImageIO was not the class responsible for ColorSpace initialization.

    Class.forName("java.awt.color.ICC_ColorSpace");
    Class.forName("sun.java2d.cmm.lcms.LCMS");
does the trick

Fix?

This helped.

ptolemy/vergil/pdfrenderer/PDFIcon.java:

    public PDFIcon(NamedObj container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        try {
            // Avoid (cd $PTII/doc/test/junit; make) throwing an exception under Java 1.8                            
            // under Mac OS X and Linux.  Also, the colors are wrong under Mac OS X 10.9.                            
            // The exception is:                                                                                    
            //    java.awt.color.CMMException: LCMS error 13: Couldn't link the profiles                            
            //         at sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native Method)                              
            //         at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:156)                                    
            //         at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)                      
            //         at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)                    
            //         at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)                              
            //         at com.sun.pdfview.colorspace.PDFColorSpace.getPaint(PDFColorSpace.java:222)                  
            //         at com.sun.pdfview.PDFParser.iterate(PDFParser.java:656)                                      
            //         at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)                                  
            //         at java.lang.Thread.run(Thread.java:745)                                                      
            // See http://chess.eecs.berkeley.edu/ptexternal/wiki/Main/PDF-renderer                                  
            // and https://stackoverflow.com/questions/26535842/multithreaded-jpeg-image-processing-in-java          
            Class.forName("javax.imageio.ImageIO");
            Class.forName("java.awt.color.ICC_ColorSpace");
            // This class is not present under Linux?                                                                                            
            try {
                Class.forName("sun.java2d.cmm.lcms.LCMS");
            } catch (Throwable throwable) {
                // Ignore.                                                                                                                        
            }
        } catch (Throwable throwable) {
            throw new IllegalActionException(this, throwable,
                    "Could not instantiate a Java2d class?");
        }
    }
Edit - History - Print - Recent Changes - Search
Page last modified on December 31, 2014, at 12:11 am