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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, openjfx11, openjfx16
    • Fix Version/s: openjfx17
    • Component/s: javafx
    • Labels:
      None
    • Environment:

      Any JavaFX version from 11 to 17-ea, any platform

      Backports

        Description

        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

          Attachments

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

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved: