esteinberg / plantuml4idea

Intellij IDEA plugin for PlantUML
Apache License 2.0
633 stars 113 forks source link

Zooming the diagram throw an exception in Rider 2023.2 (index out of bounds) #396

Closed craigwardman closed 1 year ago

craigwardman commented 1 year ago

Getting an error when zooming diagrams in the preview window, stack trace:

   org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
Index 9218 out of bounds for length 9216
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage(MySvgTranscoder.kt:110)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage$default(MySvgTranscoder.kt:73)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage(MySvgTranscoder.kt)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder.createImage(MySvgTranscoder.kt)
    at org.plantuml.idea.preview.image.svg.MyImageEditorImpl$MyScaledImageProvider.createImage(MyImageEditorImpl.java:247)
    at org.plantuml.idea.preview.image.svg.MyImageEditorUI$ImageZoomModelImpl.lambda$setZoomFactorOptimized$1(MyImageEditorUI.java:431)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:254)
    at com.intellij.util.Alarm$Request.runSafely(Alarm.java:373)
    at com.intellij.util.Alarm$Request.run(Alarm.java:360)
    at com.intellij.util.concurrency.Propagation.contextAwareCallable$lambda$2(propagation.kt:328)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:272)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:249)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:31)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:227)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:215)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 9218 out of bounds for length 9216
    at org.apache.batik.ext.awt.image.GraphicsUtil.mult_BYTE_COMP_Data(GraphicsUtil.java:1513)
    at org.apache.batik.ext.awt.image.GraphicsUtil.multiplyAlpha(GraphicsUtil.java:1028)
    at org.apache.batik.ext.awt.image.GraphicsUtil.coerceData(GraphicsUtil.java:1018)
    at org.apache.batik.ext.awt.image.rendered.AffineRed.genRect(AffineRed.java:176)
    at org.apache.batik.ext.awt.image.rendered.AffineRed.copyData(AffineRed.java:99)
    at org.apache.batik.ext.awt.image.rendered.FormatRed.copyData(FormatRed.java:109)
    at org.apache.batik.ext.awt.image.rendered.AbstractRed.getData(AbstractRed.java:533)
    at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(GraphicsUtil.java:236)
    at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(GraphicsUtil.java:427)
    at org.apache.batik.gvt.RasterImageNode.primitivePaint(RasterImageNode.java:104)
    at org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:529)
    at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(CompositeGraphicsNode.java:161)
    at org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:529)
    at org.apache.batik.gvt.ImageNode.paint(ImageNode.java:74)
    at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(CompositeGraphicsNode.java:161)
    at org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:529)
    at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(CompositeGraphicsNode.java:161)
    at org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:529)
    at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(CompositeGraphicsNode.java:161)
    at org.apache.batik.gvt.CanvasGraphicsNode.primitivePaint(CanvasGraphicsNode.java:159)
    at org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:529)
    at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(CompositeGraphicsNode.java:161)
    at org.apache.batik.gvt.AbstractGraphicsNode.paint(AbstractGraphicsNode.java:529)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoderKt.render(MySvgTranscoder.kt:290)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoderKt.access$render(MySvgTranscoder.kt:1)
    at org.plantuml.idea.preview.image.svg.batik.MySvgTranscoder$Companion.createImage(MySvgTranscoder.kt:100)
    ... 23 more

As a workaround pressing the "1:1" button gets the diagram to show at 100% zoom.

krasa commented 1 year ago

Cannot reproduce, please post the rest of the stacktrace.

craigwardman commented 1 year ago

Cannot reproduce, please post the rest of the stacktrace.

Have updated to the end of the trace visible in Rider.

krasa commented 1 year ago

Related #393

krasa commented 1 year ago

Please update and report back if it happens again. Thanks

craigwardman commented 1 year ago

yes it seems to have fixed the zoom issue. Not sure if it's related but with "SVG preview" enabled none of the sprites work, just get a red box with a cross through it. Disabling "SVG preview" fixes it.

krasa commented 1 year ago

Yes, SVG rendering of sprites is now broken.

krasa commented 1 year ago

Fixed.