android / android/camera-samples

java.lang.IndexOutOfBoundsException, because of YuvToRgbConverter.yuvToRgb

Open
#377 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
5.5k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hello, we use cameraX for the production and started to notice increasing crashes, because of the ** yuvToRgb** (specifically _**imageToByteArray(image: Image, outputBuffer: ByteArray)**_) [YuvToRgbConverter](https://github.com/android/camera-samples/blob/main/CameraUtils/lib/src/main/java/com/example/android/camera/utils/YuvToRgbConverter.kt) starting camera x core beta version ~20.

We use this class for converting Image from cameraX to Bitmap and it is an official recommendation from Google themselves.

Perpahs you should update the code because it is not stable anymore? Or please provide another solution for converting Image to the Bitmap.

Here is the list of devices with the crash:
CUBOT X19
Samsung Galaxy S9+
HUAWEI Y7 2019
BQru-5514G

The full crash log:

`Fatal Exception: java.lang.IndexOutOfBoundsException
off=1382400, len=1920 out of bounds (size=1382407)
java.nio.Buffer.checkBounds (Buffer.java:559)
java.nio.DirectByteBuffer.get (DirectByteBuffer.java:234)
com.idenfy.idenfySdk.documentscamerasession.ui.utils.CustomBitmapConverter.imageToByteArray (CustomBitmapConverter.java:117)
com.idenfy.idenfySdk.documentscamerasession.ui.utils.CustomBitmapConverter.convertYuvToBitmap (CustomBitmapConverter.java:41)
com.idenfy.idenfySdk.documentscamerasession.ui.utils.CustomDocumentImageProcessor.analyze (CustomDocumentImageProcessor.java:76)
androidx.camera.core.ImageAnalysis.lambda$setAnalyzer$1 (ImageAnalysis.java:367)
java.lang.Thread.run (Thread.java:784)`

Contributor guide

Open the contributing guide

Research direction

Read CameraUtils/lib/src/main/java/com/example/android/camera/utils/YuvToRgbConverter.kt, starting at imageToByteArray and yuvToRgb, and compare their buffer handling with the provided IndexOutOfBoundsException. Run the relevant CameraX sample or tests if available and verify that conversion no longer throws for the reported image formats and devices.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.