Exported SVG has negative dash length

• Apr 6, 2025 - 14:47

Exported SVG from the atteched MuseScore file contains a negative dash length on page 2, causing an exception in jawa.awt.BasicStroke:

[ERROR] FOUserAgent - SVG graphic could not be built. Reason: java.lang.IllegalArgumentException: negative dash length java.lang.IllegalArgumentException: negative dash length
    at java.desktop/java.awt.BasicStroke.(BasicStroke.java:216)
    at org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
    at org.apache.batik.bridge.PaintServer.convertFillAndStroke(PaintServer.java:164)
    at org.apache.batik.bridge.SVGShapeElementBridge.createShapePainter(SVGShapeElementBridge.java:117)
    at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createFillStrokePainter(SVGDecoratedShapeElementBridge.java:58)
    at org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(SVGDecoratedShapeElementBridge.java:84)
    at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(SVGShapeElementBridge.java:91)
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224)
    at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
    at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)
    at org.apache.fop.render.pdf.PDFImageHandlerSVG.handleImage(PDFImageHandlerSVG.java:104)
    at org.apache.fop.render.intermediate.AbstractIFPainter.drawImage(AbstractIFPainter.java:255)
    at org.apache.fop.render.intermediate.AbstractIFPainter.drawImage(AbstractIFPainter.java:211)
    at org.apache.fop.render.intermediate.AbstractIFPainter.drawImageUsingImageHandler(AbstractIFPainter.java:174)
    at org.apache.fop.render.pdf.PDFPainter.drawImageUsingURI(PDFPainter.java:219)
    at org.apache.fop.render.pdf.PDFPainter.drawImage(PDFPainter.java:182)
[...]

Happened twice for now, didn't see this with earlier versions. This is MuseScore-Studio-4.5.0.250721848-x86_64.AppImage on Ubuntu. Error is on page 2 (Sanctus_wb-2.svg)

Error seems to originate from this line:

8482      stroke-dasharray="19.7717, -18.2136"

Changing " -18.2136" to "18.2136" avoids the exception. Comparing the page between MuseScore and the PDF generated from the SVG, the "rit." on measure 31 seems to have an appended '' ("rit.", see attached screenshot).

I wouldn't see what I'd be doing wrong, also I doubt that the value should be negative in the first place. Any ideas?

Thanks a lot,
Hari

Attachment Size
Sanctus_wb.mscz 68.37 KB
Sanctus_wb-2.svg 394.81 KB
Sanctus_wb-1.svg 380.13 KB
Screenshot from 2025-04-06 15-44-37.png 157.14 KB

Comments

the above got munged by the markdown, it shall read "seems to have an appended" and then show an underscore char. The rit. has an additional underscore in the svg output which isn't there in the app.

In reply to by Jojo-Schmitz

valid point, albeit the same happens on 4.5.1:
- open file in 4.5.1
- save file
- export SVG via json
- attempt to use the SVG via java awt (apache fio in my case)

I did remove the rit. and re-added it. Now the exported SVG is fine. So I'd suppose that some line calculation for the dashed line after the rit is broken and can led to negative numbers in some cases.

Do you still have an unanswered question? Please log in first to post your question.