私たちのアプリでは、javax.media.JAI ライブラリを使用して画像をスケーリングおよび改善します。
ただし、場合によっては (10 回に 1 回)、VM がクラッシュすることがあります。
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fdb6f49140b, pid=2153, tid=140580255180544
#
# JRE version: 6.0_22-b22
# Java VM: OpenJDK 64-Bit Server VM (20.0-b11 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.10.4
# Distribution: Fedora release 16 (Verne), package fedora-61.1.10.4.fc16-x86_64
# Problematic frame:
# C [libgs.so+0x16940b] s_DCT_set_defaults+0x8b
#
# An error report file with more information is saved as:
# /usr/share/tomcat/hs_err_pid2153.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
# http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
ログをコードに追加すると、正確な行を特定するのに役立ちました
DebugHelper.errorLog("Start transformImage2");
List modImages = new ArrayList();
PageImage page = new PageImage();
// generate rendered image.
RenderedOp im = JAI.create("fileload", image.getFile()
.getAbsolutePath());
// get the width and height of original image.
float width = im.getWidth();
float height = im.getHeight();
// improve the quality of image.
DebugHelper.errorLog("Improving quality of image");
RenderingHints qualityHints = new RenderingHints(
RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
qualityHints.put(RenderingHints.KEY_ANTIALIASING,
「変換イメージ 2 の開始」は印刷されますが、「イメージの品質の向上」は印刷されません。したがって、それが 3 ~ 4 行にあることがわかります。さらに、hs_err* ファイルから float width = im.getWidth(); を指します。
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.imageio.plugins.jpeg.JPEGImageReader.initJPEGImageReader()J+0
j com.sun.imageio.plugins.jpeg.JPEGImageReader.(Ljavax/imageio/spi/ImageReaderSpi;)V+174
j com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(Ljava/lang/Object;)Ljavax/imageio/ImageReader;+5
j javax.imageio.spi.ImageReaderSpi.createReaderInstance()Ljavax/imageio/ImageReader;+2
j javax.imageio.ImageIO$ImageReaderIterator.next()Ljavax/imageio/ImageReader;+16
j javax.imageio.ImageIO$ImageReaderIterator.next()Ljava/lang/Object;+1
j com.sun.image.codec.jpeg.JPEGCodec$ImageIOJPEGImageDecoder.(Ljava/io/InputStream;)V+26
j com.sun.image.codec.jpeg.JPEGCodec$ImageIOJPEGImageDecoder.(Ljava/io/InputStream;Lcom/sun/image/codec/jpeg/JPEGCodec$1;)V+2
j com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder(Ljava/io/InputStream;)Lcom/sun/image/codec/jpeg/JPEGImageDecoder;+6
j com.sun.media.jai.codecimpl.JPEGImage.(Ljava/io/InputStream;Lcom/sun/media/jai/codec/ImageDecodeParam;)V+35
j com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(I)Ljava/awt/image/RenderedImage;+29
j com.sun.media.jai.opimage.CodecRIFUtil.create(Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+184
j com.sun.media.jai.opimage.JPEGRIF.create(Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+4
j sun.reflect.GeneratedMethodAccessor740.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+48
J sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j javax.media.jai.FactoryCache.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j javax.media.jai.OperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+57
j javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+12
j javax.media.jai.registry.RIFRegistry.create(Ljavax/media/jai/OperationRegistry;Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+35
j com.sun.media.jai.opimage.StreamRIF.create(Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+191
j sun.reflect.GeneratedMethodAccessor740.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+48
J sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j javax.media.jai.FactoryCache.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j javax.media.jai.OperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+57
j javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+12
j javax.media.jai.registry.RIFRegistry.create(Ljavax/media/jai/OperationRegistry;Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+35
j com.sun.media.jai.opimage.FileLoadRIF.create(Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+158
j sun.reflect.GeneratedMethodAccessor740.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+48
J sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j javax.media.jai.FactoryCache.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j javax.media.jai.OperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+57
j javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+12
j javax.media.jai.registry.RIFRegistry.create(Ljavax/media/jai/OperationRegistry;Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+35
j javax.media.jai.RenderedOp.createInstance(Z)Ljavax/media/jai/PlanarImage;+171
J javax.media.jai.RenderedOp.createRendering()V
j javax.media.jai.RenderedOp.getWidth()I+1
j com.myapp.helpers.conversion.DocumentConverter.transformImage(Lcom/myapp/helpers/conversion/PageImage;Ljava/lang/String;Lcom/myapp/helpers/conversion/ImageSetting;)Ljava/util/List;+39
j com.myapp.helpers.conversion.DocumentConverter.convertDocuments(Ljava/util/List;Ljava/lang/String;Lcom/myapp/helpers/conversion/ImageSetting;)Ljava/util/Map;+597
J com.myapp.helpers.conversion.ConversionTask.run()V
そこでいくつか質問があります
問題の正確な原因は何ですか?
エラーが常に発生しないのはなぜですか?同じ画像が正常に変換される場合と失敗する場合があるのはなぜですか?
解決方法 (もちろん :) ?