I've found this issue happens intermitently on my setup:
Ubuntu 13.04 64-bit
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
I get an intermitent crash when decoding JPEGs, decoding in several threads.
Thread pool is created thus:
ExecutorService threadpool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()+1);
ImageScaler class is:
private class ImageScaler extends SwingWorker<ImageIcon, String> {
private int size;
public ImageScaler(int size) {
this.size = size;
}
@Override
public ImageIcon doInBackground() {
LOGGER.log(Level.FINE,
"Loading image: "+url);
ImageReader ir;
//create a new instance of imageReader
synchronized(sync){
Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType("image/jpeg");
ir = it.next();
if (ir == null) {
LOGGER.log(Level.SEVERE,
"No image reader found for JPEGs");
System.exit(1);
}
ImageReaderSpi spi = ir.getOriginatingProvider();
try {
ir = spi.createReaderInstance();
} catch (Exception e) {
LOGGER.log(Level.SEVERE,
"Could not create new JPEG reader instance", e);
return null;
}
}
//Load the image from the URL (could be local or HTTP)
BufferedImage image;
try {
[...]
File cacheDir = new File (strCacheDir);
cacheDir.mkdirs();
URL u = new URL(url);
FileCacheImageInputStream fcis = new FileCacheImageInputStream(
u.openStream(), cacheDir);
ir.setInput(fcis);
image = ir.read(0);
fcis.close();
} catch (Exception e) {
LOGGER.log(Level.WARNING,
"Could not read image "+url, e);
return null;
} catch (OutOfMemoryError e) {
LOGGER.log(Level.WARNING,
"Out of memory reading image: "+url, e);
return null;
} finally {
ir.dispose();
}
The crash actually occurs in ICC_Profile code. I get intermitent colour issues with decoded JPEGs where the image is totally mid-green except for areas that are dark which tend to black. Is there an issue in the colour code for multi-threaded decode? I've done my best to create an image reader in a thread-safe way.
I've found this issue happens intermitently on my setup: 3.10-1ubuntu0. 13.04.2)
Ubuntu 13.04 64-bit
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
I get an intermitent crash when decoding JPEGs, decoding in several threads.
Thread pool is created thus: newFixedThreadP ool(Runtime. getRuntime( ).availableProc essors( )+1);
ExecutorService threadpool = Executors.
Image decode tasks added this: submit( scaler) ;
ImageScaler scaler = new ImageScaler(size);
threadpool.
ImageScaler class is: ImageIcon, String> {
private class ImageScaler extends SwingWorker<
private int size;
public ImageScaler(int size) {
this.size = size;
}
@Override log(Level. FINE,
public ImageIcon doInBackground() {
LOGGER.
"Loading image: "+url);
ImageReader ir;
//create a new instance of imageReader (sync){ ImageReader> it = ImageIO. getImageReaders ByMIMEType( "image/ jpeg"); log(Level. SEVERE, exit(1) ; ngProvider( ); rInstance( ); log(Level. SEVERE,
synchronized
Iterator<
ir = it.next();
if (ir == null) {
LOGGER.
"No image reader found for JPEGs");
System.
}
ImageReaderSpi spi = ir.getOriginati
try {
ir = spi.createReade
} catch (Exception e) {
LOGGER.
"Could not create new JPEG reader instance", e);
return null;
}
}
//Load the image from the URL (could be local or HTTP)
BufferedImage image;
try {
[...] mkdirs( ); ageInputStream fcis = new FileCacheImageI nputStream( openStream( ), cacheDir); setInput( fcis); log(Level. WARNING, log(Level. WARNING,
File cacheDir = new File (strCacheDir);
cacheDir.
URL u = new URL(url);
FileCacheIm
u.
ir.
image = ir.read(0);
fcis.close();
} catch (Exception e) {
LOGGER.
"Could not read image "+url, e);
return null;
} catch (OutOfMemoryError e) {
LOGGER.
"Out of memory reading image: "+url, e);
return null;
} finally {
ir.dispose();
}
return new ImageIcon( resizeImage( image, size));
}
@Override log(Level. WARNING, firePropertyCha nge(PNAME_ RENDEREDICON, 0, 1);
protected void done() {
if (isCancelled())
return;
ImageIcon icon = null;
try {
icon = get();
} catch (Exception ignore) {}
if (icon == null) {
LOGGER.
"Scaled image is null: "+url);
return;
}
rendered = icon;
renderedSize = size;
mPcs.
}
}
The crash actually occurs in ICC_Profile code. I get intermitent colour issues with decoded JPEGs where the image is totally mid-green except for areas that are dark which tend to black. Is there an issue in the colour code for multi-threaded decode? I've done my best to create an image reader in a thread-safe way.
I've attached the crash log file.