#1
---------- ImageFetcher Thread pool
The issue is with ImageFetcher (as used by MediaTracker). A small pool
of Threads is used, as you know, and they are allocated as needed to load Images.
In our customer's busy system, occasionally a Thread cannot be started.
This is due to an underlying OS error condition. Examples would be out
of memory for stack (if native threading), or too many threads (on a
fixed-thread-pool OS).
In the customer's system, this is a normal, if not frequent, occurrence,
and they periodically recover/reclaim resources in order to allow Java
to use more Threads. The VM is running 24/7 with a highly variable load.
Application code which fails for this reason can be unloaded and restarted.
AWT can never be restarted, so resource leaks are a problem. We have
just fixed one in ImageFetcher, as follows (example from PBP 1.1, but
similar applies to all versions of AWT):
Instead of
info.fetchers[i] = new ImageFetcher(fetcherGroup, i);
info.fetchers[i].start();
info.numFetchers++;
we now do
Thread newF = new ImageFetcher(fetcherGroup, i);
newF.start();
info.fetchers[i] = newF;
info.numFetchers++;
This arranges that when start() throws an exception, the slot in the
small pool of Threads is not filled with a useless Object.
#2
----------- MediaTracker hang
In a similar vein, we have noted (but not yet fixed) that the Image for
which the ImageFetcher Threads were being started has already been
queued by the above point.
So if a new ImageFetcher Thread cannot be started, and no others are
currently running, MediaTracker will hang indefinitely waiting for this
Image to load.
We reckon it should probably report an ERROR instead.
-------
#3 Reprodcibility
we reproduced the issue in-house by modifying our
implementation of Thread.start() to look at the name and detect "Image
Fetcher". We then spoofed occasional failures specifically of starting
those Threads (throwing an Error).
The extra challenge is to find a test application which has intermittent
bursts of Image loading, but I guess any interactive Image browser PBP
app would do. Or it should not be too hard to construct one for the
purpose.
[[We used the customer's Java TV stack, but that is not available to you.]]
********************