-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1.7, 1.2.2
-
generic
-
generic
Name: vi73552 Date: 04/05/99
THis is reported agianst Swing1.1.1beta2
IconImage failes silently without indicating and error
from media tracker. I added this code to cahch the failurs
at run time. Its easy to see on a bad nfs mount.
Most older versions of linux RH4.2 have a poor nfs implementation.
public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
if( loadStatus == MediaTracker.ABORTED ) {
System.out.println(" IMAGE ABORTED paintIcon Called "+image+" "+imageObserver);
loadImage(image);
}
if(imageObserver == null) {
g.drawImage(image, x, y, c);
} else {
g.drawImage(image, x, y, imageObserver);
}
}
___________________________________________________________
vasya wrote:
> Dear Michael,
>
> Hello again. Please send us full source to reproduce this bug.
> Another questions - Are you use jdk on Linux? JavaSoft does not
> support this jdk please go to
> http://java.sun.com/products/jdk/jdk-ports.html.
I won't use NT so I guess I'm out of luck there. This bug has little to do with
the JVM.
Anyway the application is close to 27959 lines of code so I don't think you want it sent to you.
The problem is my application is threaded and IconImage will fail in a threaded enviroment.
It is easily seen that its incorrect.
The probelm is simple. IconImage uses Media traker to load a image with a timeout.
The timeout in MediaTracker is based on System time. And worse MediaTackre is perfomring IO
Now if you use a multi-threaded aplication the media tracker thread will run a varying about on
both
Unix and NT in the same amout of wall time. On unix there will be a context switch whenever
IO blocks.
On NT whenever NT feels like it : (
Thus the mendia tracker thread will get actualy use a unknown amout of cpu time in a given fixed
wall time.
This is where IconImage fails it has a hard coded timeout and no way to force the load on failure.
Some demo code to handle and operation wich normamly suceeds in 5000 microseconds and is restarted
from scratch 5 times.
boolean workDone = false;
int maxTries = 5;
while( !workDone ) {
workDone = doWorkandTimeOut( 5000);
maxTries++;
if( maxTries && !workDone ) {
throw new Exception( "doWorkandTimeOut timed out ");
}
}
For Icon image a simple test case would be to start a bunch of threads while loading a largish
image.
The underlying probel is Java provides no way to gif you a time based on cpu speed*cpu time.
Which is roughly how much proccesing you got done. The problem is the coder of IconImage did not
consider the
case of many threads nor did he consider slow I/O. The code obviously incorrect by simple
inspection.
If you really want and example I'll conjure one up but this code really blows on NT with its
round robin cruft.
Mike
>
>
> Sincerely yours,
>
> Vassili Igouchkine.
>
> The evaluation of your bug report has been completed.
>
> Unfortunately, we do not have enough information to create a
> new Bug. Please resubmit this bug report with as much of
> the following information as you can:
>
> - Exact steps to reproduce the problem.
> - Java source code that demonstrates the problem.
> - The exact text of any error message(s) that appeared.
> - Any trace information.
> - Additional configuration information that you think
> is relevant to the problem.
>
> Thank you for taking the time to report this problem.
>
(Review ID: 56488)
======================================================================
vasya wrote:
> Dear Michael,
>
> It will be better, if you send us compact test to reproduce this problem -
> it saves our time and mekes bug processing faster.
>
> Sincerely yours,
>
> Vassili Igouchkine.
>
> Your bug has been submitted into our internal Bug Tracking system. It has been
> assigned Bug Id: 4226683.
Hi Vassli here is a little demo program which shows that starting another time consuming thread is
able to move the MediaTracker trhead from a COMPLETED status to a LOADING status.
I could not get it to move to ABORT status. But I can get this in my larger app.
Probably need to throw in a bit of I/O and more threads. I ran one worker thread with the current
settings.
There needs to be a bit more to get it to error out but the fact that I can change the state of the
MediaTracker via runing more threads shows how they influncence media tracker.
I move my code to the local dis and I'm still able to get it to abort in the full application.
Very intresting. I'll continue to research this. I thought it would run local hmmm.
I wonder how I get it to abort. I can't in a small program.
I'll keep looking. Its got to be a threads issue.
Mike
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.text.*;
import javax.swing.tree.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.image.*;
import java.net.*;
import org.javagroup.process.*;
import org.javagroup.util.*;
/**
* A single column table for object viewer
*
*
*/
public class Demo extends JToggleButton {
static int MAX_THREADS=1;
String name="foobar";
boolean lastState=false;
String imageName = "ScrollRightArrow.gif";
public Demo(String imageName){
if( imageName != null ) {
this.imageName = imageName;
}
initView();
}
public void initView(){
setText(name);
setBorderPainted(false);
setHorizontalAlignment(RIGHT);
setHorizontalTextPosition(LEFT);
loadIcon();
}
public void loadIcon(){
System.out.println(" START THREADS ");
startThreads();
try {
synchronized( this ) {
wait(200);
}
}catch(Exception e ) {}
ImageIcon iconDisabled=
new ImageIcon(imageName);
int ires= iconDisabled.getImageLoadStatus();
String res ="";
if( ires == MediaTracker.ABORTED ) res ="ABORTED";
if( ires == MediaTracker.ERRORED ) res ="ERRORED";
if( ires == MediaTracker.COMPLETE ) res ="COMPLETE";
if( ires == MediaTracker.LOADING ) res ="LOADING";
System.out.println(ires+" "+res+ " LOADED IMAGE NAME ="+imageName);
setDisabledIcon(iconDisabled);
setSelectedIcon(iconDisabled);
setPressedIcon(iconDisabled);
setIcon(iconDisabled);
}
public void startThreads(){
for( int i =0; i < MAX_THREADS; i++ ) {
Thread t = new Thread(){
public void run(){
synchronized( this ) {
try {
wait(250);
}catch( Exception e ) {
System.err.println(" Interupted "+e );
}
}
//for( int k=0; k < Integer.MAX_VALUE; k++ ) {
for( int k=0; k < 10000000; k++ ) {
int foo=k;
}
System.out.println(" DONE THREAD ");
}
};
t.start();
}
}
public static void main( String[] args ) {
try {
JFrame frame = new JFrame( "Bug" );
String file=null;
if( args.length != 0 ) {
MAX_THREADS = Integer.parseInt(args[0]);
if( args.length == 2 ){
file = args[1];
}
}
Demo demo= new Demo(file);
frame.getContentPane().add(demo);
frame.setBounds(0,0,150,50);
frame.setVisible(true);
System.out.println("DONE SHOWNING ");
}catch( Exception e ) {
System.out.println(" ERROR : "+e );
}
}
}
Vassili.Igouchkine@Russia 1999-04-05
MIME-Version: 1.0
To: vasya <###@###.###>
Subject: Re: (Review ID: 56488) Icon Image fails silently with hardcoded timeout
Content-Transfer-Encoding: 7bit
vasya wrote:
> Dear Michael,
>
> It will be better, if you send us compact test to reproduce this problem -
> it saves our time and mekes bug processing faster.
>
> Sincerely yours,
>
> Vassili Igouchkine.
>
> Your bug has been submitted into our internal Bug Tracking system. It has been
> assigned Bug Id: 4226683.
Found it it was in my app sorry the Abort was caused by me not java.
I still think the fact that it aborted silent ly is a bug and still don't like the
fixed timeout. It does not take much to let this code be robust and load images under the worst
of conditions.
You can withdraw this as a bug report if you want to its now just a request for enchancement on code
review.
The enchanment is the IconImage throws and exception if image load fails. It threw me for a loop.
Thanks a lot for your time. If your willing to bear with me I'm putting Swing through some pretty
strenous testing.
Some problems are mine some may be in Swing. I should be able to find them all. If you can accept a
few false alarms.
Swing 1111-bate2 is looking pretty good so far to me. I need to track down that graphics stack
corruption when
the double buffering is enabled. I draw fine without double buffering.
Mike
Vassili.Igouchkine@Russia 1999-04-06
- duplicates
-
JDK-4253075 Animated GIFs with transparent backgrounds do not work when scaled
- Resolved