Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8267314

Loading some animated GIFs fails with ArrayIndexOutOfBoundsException: Index 4096 out of bounds for length 4096

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx17
    • jfx11, 8, jfx16
    • javafx
    • None
    • Any JavaFX version from 11 to 17-ea, any platform

        Some animated GIF files fail to load, and either throw:

        java.lang.ArrayIndexOutOfBoundsException: Index 4096 out of bounds for length 4096
                at javafx.graphics/com.sun.javafx.iio.gif.GIFImageLoader2$LZWDecoder.readString(GIFImageLoader2.java:385)
                at javafx.graphics/com.sun.javafx.iio.gif.GIFImageLoader2.decodeImage(GIFImageLoader2.java:167)
                at javafx.graphics/com.sun.javafx.iio.gif.GIFImageLoader2.load(GIFImageLoader2.java:232)
                at javafx.graphics/com.sun.javafx.iio.ImageStorage.loadAll(ImageStorage.java:374)
                at javafx.graphics/com.sun.javafx.iio.ImageStorage.loadAll(ImageStorage.java:271)
                at javafx.graphics/com.sun.javafx.tk.quantum.PrismImageLoader2.loadAll(PrismImageLoader2.java:142)
                at javafx.graphics/com.sun.javafx.tk.quantum.PrismImageLoader2.<init>(PrismImageLoader2.java:77)
                at javafx.graphics/com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.processStream(PrismImageLoader2.java:252)
                at javafx.graphics/com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.processStream(PrismImageLoader2.java:225)
                at javafx.graphics/com.sun.javafx.runtime.async.AbstractRemoteResource.call(AbstractRemoteResource.java:109)
                at javafx.graphics/com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.access$001(PrismImageLoader2.java:225)
                at javafx.graphics/com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.lambda$call$0(PrismImageLoader2.java:259)
         
        or simply show one/two frames but fail to load the rest.

        The attached test shows the latter.

        In fact, with some debugging, it can be found that the same exception as above is happening but it is not thrown, because partially (as in just two frames) loaded gifs are allowed:

        https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/javafx/iio/ImageStorage.java#L376

          1. fuller.gif
            4.50 MB
            Jose Pereda
          2. GifTest.java
            0.6 kB
            Jose Pereda

              jpereda Jose Pereda
              jpereda Jose Pereda
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: