Android: Some preview images in Ensemble8 are not displayed

XMLWordPrintable

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

      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) |

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

              Created:
              Updated:
              Resolved:
              Imported: