[kaffe] MediaTracker

Jukka Santala jsantala at tml.hut.fi
Tue May 28 06:18:12 PDT 2002


This will probably need some further testing. One class in X-Smiles passes
a fake URL to MediaTracker in hopes that it'll fast-fail and just get
ignored. Though we'll probably change that, in interest of compatibility I
wrote a patch to make this work on Kaffe more or less as it seems on other
JRE's. Problem is, it's not exactly well documented.

It appears that with URL class the error occurs even before MediaTracker
enters its wait() section, and hence it never catches the notify() -
leading to "hangs" of several minutes or worse while Kaffe waits to time
out. In this patch, flags are checked for ImageObserver.ERROR before
entering wait(), and the synchronized section has been extended to
encompass all of that to prevent race-conditions between the check and
wait() on the assumption that with an URL the error could come in with
some latency. For the latter reason, imageUpdate() has also been modified
to fire notify() in this case.

We probably SHOULD also check ABORT in the same manner, but since I
couldn't immediately come up with a test-case to compare this against
other JRE's, I didn't add that in yet.

 -Jukka Santala
-------------- next part --------------
Index: libraries/javalib/java/awt/MediaTracker.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/MediaTracker.java,v
retrieving revision 1.11
diff -u -r1.11 MediaTracker.java
--- libraries/javalib/java/awt/MediaTracker.java	12 Oct 1999 02:29:40 -0000	1.11
+++ libraries/javalib/java/awt/MediaTracker.java	28 May 2002 13:10:41 -0000
@@ -301,8 +301,8 @@
 			return false;
 		}
 	
-		if ((e.img.checkImage(e.w, e.h, e, true) & (ImageObserver.FRAMEBITS|ImageObserver.ALLBITS)) == 0) {
-			synchronized ( e ) {
+		synchronized ( e ) {
+			if ((e.img.checkImage(e.w, e.h, e, true) & (ImageObserver.FRAMEBITS|ImageObserver.ALLBITS|ImageObserver.ERROR)) == 0) {
 				e.wait( ms);
 			}
 		}
@@ -337,7 +337,7 @@
 			w = width;
 			h = height;
 		}
-		if ( (infoflags & (ALLBITS | FRAMEBITS | ABORT)) != 0 ) {
+		if ( (infoflags & (ALLBITS | FRAMEBITS | ABORT | ImageObserver.ERROR)) != 0 ) {
 			notify();
 			return (false);
 		}


More information about the kaffe mailing list