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

Java SWING EventQueue thread deadlocks with animated GIFs

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      03
    • CPU:
      x86, sparc
    • OS:
      solaris_8, windows_nt

      Backports

        Description

        Customer Problem Description:
        ----------------------------
        The UI for our product is written in Java using SWING. We have run into
        the following problem :

        Our swing-based java application hangs when we are trying to raise a
        JOptionPane to the user. The EventQueue thread seems to be
        deadlocked with two other threads, which are for animaged gif's elsewhere on
        the GUI.

        Here's the thread dump:

        Full thread dump:

        "Image Animator 0" daemon prio=3 tid=0x5e0ed0 nid=0x4f8 waiting on monitor
        [0xebe81000..0xebe819e0]
        at java.lang.Object.wait(Native Method)
        at java.awt.MediaTracker.waitForID(MediaTracker.java:632)
        at javax.swing.ImageIcon.loadImage(ImageIcon.java:226)
        at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
        at javax.swing.JLabel.getDisabledIcon(JLabel.java:409)
        at javax.swing.JLabel.imageUpdate(JLabel.java:806)
        at sun.awt.image.ImageWatched.newInfo(ImageWatched.java:58)
        at
        sun.awt.image.ImageRepresentation.imageComplete(ImageRepresentation.java:626
        )
        at sun.awt.image.ImageDecoder.imageComplete(ImageDecoder.java:138)
        at sun.awt.image.GifFrame.dispose(GifImageDecoder.java:637)
        at sun.awt.image.GifImageDecoder.readImage(GifImageDecoder.java:479)
        at
        sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:223)
        at
        sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:257
        )
        at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:217)
        at sun.awt.image.ImageFetcher.run(ImageFetcher.java:185)

        "Image Animator 0" daemon prio=3 tid=0x6878d8 nid=0x1fc waiting on monitor
        [0xebf81000..0xebf819e0]
        at java.lang.Object.wait(Native Method)
        at java.awt.MediaTracker.waitForID(MediaTracker.java:632)
        at javax.swing.ImageIcon.loadImage(ImageIcon.java:226)
        at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
        at javax.swing.JLabel.getDisabledIcon(JLabel.java:409)
        at javax.swing.JLabel.imageUpdate(JLabel.java:806)
        at sun.awt.image.ImageWatched.newInfo(ImageWatched.java:58)
        at
        sun.awt.image.ImageRepresentation.imageComplete(ImageRepresentation.java:626
        )
        at sun.awt.image.ImageDecoder.imageComplete(ImageDecoder.java:138)
        at sun.awt.image.GifFrame.dispose(GifImageDecoder.java:637)
        at sun.awt.image.GifImageDecoder.readImage(GifImageDecoder.java:479)
        at
        sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:223)
        at
        sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:257
        )
        at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:217)
        at sun.awt.image.ImageFetcher.run(ImageFetcher.java:185)

        "Thread-163" prio=6 tid=0x5d87b0 nid=0xb8 waiting on monitor
        [0xf0101000..0xf01019e0]
        at java.lang.Thread.sleep(Native Method)
        at
        com.xerox.controller.jobGUI.ListJobs$ListJobsWorker.doWork(ListJobs.java:276
        )
        at
        com.xerox.controller.jobGUI.ListJobs$ListJobsWorker.construct(ListJobs.java:
        209)
        at com.xerox.controller.util.SwingWorker$2.run(SwingWorker.java:145)
        at java.lang.Thread.run(Thread.java:484)

        "Thread-35" prio=6 tid=0x521ee0 nid=0x37 waiting on monitor
        [0xeb981000..0xeb9819e0]
        at java.lang.Thread.sleep(Native Method)
        at
        com.xerox.controller.jobGUI.ListJobs$ListJobsWorker.doWork(ListJobs.java:276
        )
        at
        com.xerox.controller.jobGUI.ListJobs$ListJobsWorker.construct(ListJobs.java:
        209)
        at com.xerox.controller.util.SwingWorker$2.run(SwingWorker.java:145)
        at java.lang.Thread.run(Thread.java:484)

        "Thread-34" prio=6 tid=0x521c78 nid=0x36 waiting on monitor
        [0xeba81000..0xeba819e0]
        at java.lang.Thread.sleep(Native Method)
        at
        com.xerox.controller.jobGUI.ListJobs$ListJobsWorker.doWork(ListJobs.java:276
        )
        at
        com.xerox.controller.jobGUI.ListJobs$ListJobsWorker.construct(ListJobs.java:
        209)
        at com.xerox.controller.util.SwingWorker$2.run(SwingWorker.java:145)
        at java.lang.Thread.run(Thread.java:484)

        "Screen Updater" prio=5 tid=0x23c8a0 nid=0x1d waiting on monitor
        [0xf0501000..0xf05019e0]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:420)
        at sun.awt.ScreenUpdater.nextEntry(ScreenUpdater.java:76)
        at sun.awt.ScreenUpdater.run(ScreenUpdater.java:95)

        "Thread-2" prio=5 tid=0x281d0 nid=0x1 runnable [0..0xffbeebc8]

        "Thread-1" prio=5 tid=0xdfeb0 nid=0x11 runnable [0xf0201000..0xf02019e0]
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:413)
        at java.net.ServerSocket.implAccept(ServerSocket.java:243)
        at java.net.ServerSocket.accept(ServerSocket.java:222)
        at JRPC.JRPCServer.run(JRPCServer.java:131)
        at java.lang.Thread.run(Thread.java:484)

        "Thread-0" prio=5 tid=0xe0dc8 nid=0x10 runnable [0xf0301000..0xf03019e0]
        at java.net.PlainDatagramSocketImpl.receive(Native Method)
        at java.net.DatagramSocket.receive(DatagramSocket.java:392)
        at JRPC.ServerUDP.run(ServerUDP.java:41)
        at java.lang.Thread.run(Thread.java:484)

        "TimerQueue" daemon prio=5 tid=0x2456a8 nid=0xf waiting on monitor
        [0xf0401000..0xf04019e0]
        at java.lang.Object.wait(Native Method)
        at javax.swing.TimerQueue.run(TimerQueue.java:233)
        at java.lang.Thread.run(Thread.java:484)

        "AWT-Motif" prio=6 tid=0x1bf0c0 nid=0xd runnable [0xf0601000..0xf06019e0]
        at sun.awt.motif.MToolkit.run(Native Method)
        at java.lang.Thread.run(Thread.java:484)

        "SunToolkit.PostEventQueue-0" prio=5 tid=0x1b50d0 nid=0xc waiting on monitor
        [0xf0701000..0xf07019e0]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:420)
        at sun.awt.PostEventQueue.run(SunToolkit.java:497)

        "AWT-EventQueue-0" prio=5 tid=0x1b3880 nid=0xb waiting on monitor
        [0xf07ff000..0xf08019e0]
        at java.lang.Object.wait(Native Method)
        at java.awt.MediaTracker.waitForID(MediaTracker.java:632)
        at javax.swing.ImageIcon.loadImage(ImageIcon.java:226)
        at javax.swing.ImageIcon.<init>(ImageIcon.java:209)
        at javax.swing.LookAndFeel$1.createValue(LookAndFeel.java:275)
        at javax.swing.UIDefaults.get(UIDefaults.java:145)
        at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:46)
        at javax.swing.UIDefaults.getIcon(UIDefaults.java:250)
        at javax.swing.UIManager.getIcon(UIManager.java:476)
        at
        javax.swing.plaf.basic.BasicOptionPaneUI.getIconForType(BasicOptionPaneUI.ja
        va:508)
        at
        javax.swing.plaf.basic.BasicOptionPaneUI.getIcon(BasicOptionPaneUI.java:490)
        at
        javax.swing.plaf.basic.BasicOptionPaneUI.addIcon(BasicOptionPaneUI.java:471)
        at
        javax.swing.plaf.basic.BasicOptionPaneUI.createMessageArea(BasicOptionPaneUI
        .java:295)
        at
        javax.swing.plaf.basic.BasicOptionPaneUI.installComponents(BasicOptionPaneUI
        .java:124)
        at
        javax.swing.plaf.basic.BasicOptionPaneUI.installUI(BasicOptionPaneUI.java:92
        )
        at javax.swing.JComponent.setUI(JComponent.java:325)
        at javax.swing.JOptionPane.setUI(JOptionPane.java:1425)
        at javax.swing.JOptionPane.updateUI(JOptionPane.java:1447)
        at javax.swing.JOptionPane.<init>(JOptionPane.java:1410)
        at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:670)
        at com.xerox.controller.frameworks.Message.postIt(Message.java:91)
        at com.xerox.controller.frameworks.Message.postIt(Message.java:117)
        at
        com.xerox.controller.frameworks.Message.postQuestion(Message.java:235)
        at
        com.xerox.controller.jobGUI.JobPropsManager.delete(JobPropsManager.java:443)
        at
        com.xerox.controller.jobGUI.JobMenuHandler.actionPerformed(JobMenuHandler.ja
        va:97)
        at
        javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
        at
        javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButto
        n.java:1504)
        at
        javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:3
        78)
        at
        javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:279)
        at
        javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(Basic
        MenuItemUI.java:886)
        at java.awt.Component.processMouseEvent(Component.java:3715)
        at java.awt.Component.processEvent(Component.java:3544)
        at java.awt.Container.processEvent(Container.java:1165)
        at java.awt.Component.dispatchEventImpl(Component.java:2593)
        at java.awt.Container.dispatchEventImpl(Container.java:1214)
        at java.awt.Component.dispatchEvent(Component.java:2497)
        at
        java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2452)
        at
        java.awt.LightweightDispatcher.processMouseEvent(Container.java:2217)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2126)
        at java.awt.Container.dispatchEventImpl(Container.java:1201)
        at java.awt.Window.dispatchEventImpl(Window.java:912)
        at java.awt.Component.dispatchEvent(Component.java:2497)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:333)
        at
        java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
        at
        java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

        "Signal Dispatcher" daemon prio=10 tid=0x9d338 nid=0x9 runnable [0..0]

        "Finalizer" daemon prio=8 tid=0x9a418 nid=0x7 waiting on monitor
        [0xfd181000..0xfd1819e0]
        at java.lang.Object.wait(Native Method)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:149)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
        at
        java.lang.ref.Finalizer$FinalizerWorker$FinalizerThread.run(Finalizer.java:1
        20)

        "Reference Handler" daemon prio=10 tid=0x98ae0 nid=0x6 waiting on monitor
        [0xfd281000..0xfd2819e0]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:420)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:129)

        "VM Thread" prio=5 tid=0x97e80 nid=0x4 runnable

        "VM Periodic Task Thread" prio=10 tid=0x9ca48 nid=0x8 waiting on monitor

        ----------

        Essentially, I think the question boils down to:

        [1] How does one properly get rid of an animated GIF. In particular, how does
            one clean up after it so that the SWING thread used for animating the GIF
            is terminated and does not tie up Swing's eventQueue thread?
            
        [2] What is the proper coding practice to have multiple animated GIFs running
            concurrently. This is a follow on to [1] above as the UI team has serialized
            the activation (running) of multiple animated GIFs.
            
        Below please find a tar file containing sample code to reproduce the problem. To
        recreate the problem, please take the following steps:

        % java IconTest

        Once the GUI is launched, click on the tile labeled 'OptionPane...'. The GUI
        will lock up.

        The work around the developer has put in is to null out the animated GIF icon
        instance before subsequent reuse. You can invoke that behavior in the test code
        as follows,

        % java IconTest -fix

        With the above, the GUI should not hang and a new 'Error' pop up window should
        be displayed, which is what is desired.

        One last final question:

        [3] Looks like we tripped across a bug? The above work around mitigates the number of ocurrences. However, we still run against the problem.

        We are see'ng this problem in all JDK releases 1.3, 1.3.1, 1.4 Beta
        on Solaris. We see this problem on win32 platform too.

        ===============================================================================
        Verified in MB91

        ###@###.### 2002-01-15
        ===============================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                svioletsunw Scott Violet (Inactive)
                Reporter:
                cprasadsunw Ck Prasad (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: