Closed ShioriSaito-asken closed 4 months ago
We encounter a SIGSEGV (0xb) error when calling MatOfByte.toArray(). This error occurs occasionally under high request loads (800 requests per minute for about 10 minutes). If you have any idea how to fix this, I would really appreciate it.
MatOfByte.toArray()
build.gradle.kts
// https://mvnrepository.com/artifact/org.bytedeco/javacv implementation("org.bytedeco:javacv:1.5.10") // https://mvnrepository.com/artifact/org.bytedeco/javacv-platform implementation("org.bytedeco:javacv-platform:1.5.10")
We are resizing a JPG image and converting it to a ByteArray using Kotlin. Error log shows that the method below cause the error.
ByteArray
private fun minimize(mat: Mat, size: ImageSizePair): ByteArray { // The reduction ratio (base/original) adopts the smaller percentage in width-height to maintain the aspect ratio. return mat.let { val dist = resize(mat, size) MatOfByte().run { Imgcodecs.imencode(".jpg", dist, this) val array = this.toArray() array } } ?: throw IllegalArgumentException("") }
We have also added a PointerScope to the caller of this method, but the issue persists.
PointerScope
fun resize(image: ByteArray, size: ImageSize): ByteArray { return PointerScope().use { val mat = Imgcodecs.imdecode(MatOfByte(*image), Imgcodecs.IMREAD_ANYCOLOR) when (size) { // ... ANALYZE -> minimize(mat, ANALYZE_IMAGE_SIZE) } } }
I will attach the contents of the “hs_err_pid” file. hs_err_pid31.log
I would recommend using the C++ API, it's probably more stable
Thank you for your response. We will consider it.
Describe the issue
We encounter a SIGSEGV (0xb) error when calling
MatOfByte.toArray()
. This error occurs occasionally under high request loads (800 requests per minute for about 10 minutes). If you have any idea how to fix this, I would really appreciate it.code
build.gradle.kts
We are resizing a JPG image and converting it to a
ByteArray
using Kotlin. Error log shows that the method below cause the error.We have also added a
PointerScope
to the caller of this method, but the issue persists.error log
I will attach the contents of the “hs_err_pid” file. hs_err_pid31.log