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

Android: Some preview images in Ensemble8 are not displayed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Labels:

      Description

      As reported in https://bitbucket.org/javafxports/android/issue/14/some-ensemble8-preview-images-are-not in Ensemble8 the preview images of some samples are not displayed. Loading the PNG-Image causes an EOFException. Debugging the issue reveals, that the skip method in java.util.zip.InflaterInputStream on Android, in accordance with the javadoc, does not skip all requested bytes in one go. e.g.: only 1 instead of 4.
      So the following patch fixes it by implementing a loop:


      diff --git a/modules/graphics/src/main/java/com/sun/javafx/iio/png/PNGIDATChunkInputStream.java b/modules/graphics/src/main/java/com/sun/javafx/iio/png/PNGIDATChunkInputStream.java
      --- a/modules/graphics/src/main/java/com/sun/javafx/iio/png/PNGIDATChunkInputStream.java
      +++ b/modules/graphics/src/main/java/com/sun/javafx/iio/png/PNGIDATChunkInputStream.java
      @@ -68,7 +68,16 @@
       
           private void nextChunk() throws IOException {
               if (!foundAllIDATChunks) {
      - if (4 != source.skip(4)) { // CRC
      + // must use loop, because java.util.zip.InflaterInputStream on Android, sometimes does not skip all bytes in one go
      + long toBeSkipped = 4; // CRC
      + while (toBeSkipped > 0) {
      + long skipped = source.skip(toBeSkipped);
      + if(skipped <= 0) {
      + break;
      + }
      + toBeSkipped -= skipped;
      + }
      + if (toBeSkipped > 0) {
                       throw new EOFException();
                   }
                   int chunkLength = (source.read() << 24) | (source.read() << 16) |

        Attachments

          Activity

            People

            Assignee:
            vadim Vadim Pakhnushev
            Reporter:
            sfuchsjfx Stefan Fuchs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: