Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-1163

DOMException: "The "opacity" property does not support dimension values"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8
    • None
    • None
    • None
    • Using Batik 1.8 dependencies from Maven Central.
      Reproduced on Windows, using Java 1.8 (likely not relevant in this case).

    Description

      One of the users of my library, TwelveMonkeys ImageIO reported an issue, trying to read certain SVG files (my project uses the rasterizer to convert SVG to BufferedImage, through the javax.imageio API). See the issue here for details: https://github.com/haraldk/TwelveMonkeys/issues/299

      I tracked it down to an internal DOMException, with the message "The "opacity" property does not support dimension values".

      The "offending" values in the CSS were:

      opacity:9.090909e-002

      Manually changing the values to:

      opacity: 0.09090909

      ...I was able to read/display the SVG using the library/Batik, everything seemingly okay.

      I can open the original SVG in question in both IE and Chrome without issues (as far as I can see, there might be internal warnings not displayed to me as an end user). Not sure whether this is a spec/leniency issue, or if this is a Batik bug, but would be happy if you could look into it.

      The stack trace I see in my application is this:

      java.lang.NullPointerException
      at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
      at org.apache.batik.anim.dom.SVGOMStyleElement.getCSSStyleSheet(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.getStyleSheetNodes(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.getComputedStyle(Unknown Source)
      at org.apache.batik.bridge.CSSUtilities.getComputedStyle(Unknown Source)
      at org.apache.batik.bridge.CSSUtilities.convertVisibility(Unknown Source)
      at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(Unknown Source)
      at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.transcode(SVGImageReader.java:307)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
      at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.init(SVGImageReader.java:547)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.getDefaultWidth(SVGImageReader.java:560)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader.getWidth(SVGImageReader.java:227)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader.read(SVGImageReader.java:129)
      at javax.imageio.ImageReader.read(ImageReader.java:940)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReaderTest.testFoo(SVGImageReaderTest.java:154)

      However, as mentioned, there seems to be an internal exception thrown (and caught again), inside the CSSEngine/parseStyleSheet() method. I believe this is the cause, and the NPE just happens after, for some reason. The following stack trace is never shown in my application, but created by invoking its printStackTrace() method from the debugger:

      org.w3c.dom.DOMException: The "opacity" property does not support dimension values.
      at org.apache.batik.css.engine.value.AbstractValueFactory.createInvalidLexicalUnitDOMException(Unknown Source)
      at org.apache.batik.css.engine.value.svg.OpacityManager.createValue(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine$StyleSheetDocumentHandler.property(Unknown Source)
      at org.apache.batik.css.parser.Parser.parseStyleDeclaration(Unknown Source)
      at org.apache.batik.css.parser.Parser.parseRuleSet(Unknown Source)
      at org.apache.batik.css.parser.Parser.parseStyleSheet(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown Source)
      at org.apache.batik.anim.dom.SVGOMStyleElement.getCSSStyleSheet(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.getStyleSheetNodes(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(Unknown Source)
      at org.apache.batik.css.engine.CSSEngine.getComputedStyle(Unknown Source)
      at org.apache.batik.bridge.CSSUtilities.getComputedStyle(Unknown Source)
      at org.apache.batik.bridge.CSSUtilities.convertVisibility(Unknown Source)
      at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(Unknown Source)
      at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.transcode(SVGImageReader.java:307)
      at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
      at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.init(SVGImageReader.java:547)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader$Rasterizer.getDefaultWidth(SVGImageReader.java:560)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader.getWidth(SVGImageReader.java:227)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReader.read(SVGImageReader.java:129)
      at javax.imageio.ImageReader.read(ImageReader.java:940)
      at com.twelvemonkeys.imageio.plugins.svg.SVGImageReaderTest.testFoo(SVGImageReaderTest.java:154)

      Unfortunately the JARs from Maven central have debug info stripped out, so I don't have line numbers, and it's quite hard to follow what's happening in the debugger. It's probably easier for you, if you have classes with debug information available.

      Attachments

        1. Lynparza_PARPinhibition.svg
          160 kB
          Harald Kuhr

        Activity

          People

            Unassigned Unassigned
            haraldk76 Harald Kuhr
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: