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

Many animated gifs are not shown



    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.2, 1.3.1, 1.4.0
    • Fix Version/s: 1.3.0_05
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
    • CPU:
      generic, x86
    • OS:
      generic, windows_nt



        Name: stC104175 Date: 05/22/2000

        java version "1.3.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build jini-re-000208-06:03)
        Java HotSpot(TM) Client VM (build 1.3.0rc1-S, interpreted mode)

        java version "1.2.2"
        Classic VM (build JDK-1.2.2-W, green threads, sunwjit)

        java version "1.2.1"
        Solaris VM (build Solaris_JDK_1.2.1_03, native threads, sunwjit)

        java version "1.1.8"

        Just try to load at about 30 different animated images simultaneously one after
        another. Specify your java.awt.image.ImageObserver to be notified by loading
        process. You will see, that not all of the images are loaded!

        Test code example:
        public class Test extends java.awt.Component

        java.util.Vector images = new java.util.Vector();
        public boolean imageUpdate(java.awt.Image img,
                                   int f, int x, int y, int w, int h)
            if ( !images.contains( img ) ) {
        images.addElement( img );
        System.out.println("Deal with "+images.size()+" images");
            return super.imageUpdate( img, f, x, y, w, h );
        public static void main (String[] args) {
            System.out.println("Total number of images: "+args.length);
            Test test = new Test();// Test is ImageObserver
            // args is animated images names list
            for (int i = 0; i < args.length; i ++) {
                test.prepareImage( test.getToolkit().getImage( args[i] ), test );

        }// end of class 'Test' definition

        This is a problem of synchronization. See class sun.awt.image.ImageFetcher.
        There are several interesting points:
         o There may be no more then 4 ImageFetcher-s in the system.

         o New ImageFetcher may be created only in the method
            "void add(ImageFetchable src)" and only if less then 4 Fetchers
            are currently in the system (see method code)

         o In any case new request for loading is registered in the list (waitList)
            in the method "add".

         o If the ImageFetcher thread is loading animated gif, it becomes the
            "Image Animator" & unregistered itself from the available fetchers list.
            See the code of the method "void startingAnimation()".

        Now! Nobody excepting "add" method can create a new ImageFetcher.
        Suppose, we load 30 animated images. First 4 images are registered by
        "add" method, 4 fetchers are created & start to load them.

        During a loading process the other 26 images are registered in "waitList" by
        "add" method, but no new fetchers are created, because there are already
        4 fetchers in the system (and they are loading first 4 images).

        Method "add" will not be invoked, because all of the 30 images
        are registered in the "waitList".

        For a little while, 4 fetchers turn into "Image Animator" & unregistered
        themselves from the fetchers list. So we've gone to the situation, when no
        fetchers in the system to load other 26 images.

        100% reproduction:
        Insert a delay after thread conversion from "fetcher" to
        "animator" in the method "void startingAnimation()":
        diff -c for jdk1.1.8, sun/awt/image/ImageFetcher.java
        *** 157,162 ****
        --- 157,163 ----
                            fetchers[i] = null;
                            me.setName("Image Animator " + i);
        + try{ Thread.sleep( 1000 ); }catch(InterruptedException e){}

          Suggested fix:
        Burn a new ImageFetcher instead of converted to "animator" in the
        method "void startingAnimation()" if the waitList.size is greater
        then fetchers number:
        diff -c for jdk1.1.8, sun/awt/image/ImageFetcher.java
        *** 157,162 ****
        --- 157,167 ----
                            fetchers[i] = null;
                            me.setName("Image Animator " + i);
        + if ( waitList.size() > numfetchers ) {
        + fetchers[i] = new ImageFetcher(i);
        + fetchers[i].start();
        + numfetchers++;
        + }

        NOTE: In jdk1.2.2 sources the fields "fetchers" & "waitList" belong to
        additional "info" filed of the type sun.awt.image.FetcherInfo. But this
        does not affect to the my description, evaluation & suggested fix.
        (Review ID: 102246)

        Name: bsC130419 Date: 07/13/2001

        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
        Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

          Bug Id 4339995

        we want to work about 5000 Money-Cash-Computers to run with a Browser in Java
        and our clients want to see animated gifs. Could you say up to which date the
        problem will be solved. Could we have the source-code to fix the problem by
        ourselves ?
        Is there a work around and how can we get this?
        Kind regards

        Norbert Schultewolter
        (Review ID: 128036)


            Issue Links



                asultano Alex Sultanov
                stompkinsunw Sean Tompkins (Inactive)
                0 Vote for this issue
                0 Start watching this issue