🐛 [Android] Crash when calling toArrayBuffer
What's happening?
I encounter this error when trying to call frame.toArrayBuffer() in frame processor on Android devices, it works fine on iOS though. Please inspect the logcat below.
I found out that this issue is also related to this error, but it was closed a long time ago. Maybe there was something changes to Android 15 API?
Reproduceable Code
const frameProcessor = useFrameProcessor((frame) => {
'worklet'
const arrayBuffer = frame.toArrayBuffer()
console.log(arrayBuffer.byteLength)
}, [])
Relevant log output
2025-05-26 00:26:56.911 10276-10340 Frame com.mrousavy.camera.example I Converting 1280 x 720 @ 1280 HardwareBuffer...
2025-05-26 00:26:56.911 10276-10340 .camera.example com.mrousavy.camera.example E lockImpl:290 failed with 'Error3::BAD_VALUE'
2025-05-26 00:26:56.911 10276-10340 Gralloc3 com.mrousavy.camera.example W lock(0xb400006e6b06cf90, ...) failed: 3
2025-05-26 00:26:56.912 10276-10340 Frame com.mrousavy.camera.example I Converting 1280 x 720 @ 1280 HardwareBuffer...
2025-05-26 00:26:56.912 10276-10340 .camera.example com.mrousavy.camera.example E lockImpl:290 failed with 'Error3::BAD_VALUE'
2025-05-26 00:26:56.912 10276-10340 Gralloc3 com.mrousavy.camera.example W lock(0xb400006e6b06d530, ...) failed: 3
2025-05-26 00:26:56.938 10276-10340 Frame com.mrousavy.camera.example I Converting 1280 x 720 @ 1280 HardwareBuffer...
2025-05-26 00:26:56.939 10276-10340 .camera.example com.mrousavy.camera.example E lockImpl:290 failed with 'Error3::BAD_VALUE'
2025-05-26 00:26:56.939 10276-10340 Gralloc3 com.mrousavy.camera.example W lock(0xb400006e6b06d140, ...) failed: 3
2025-05-26 00:26:56.944 10276-10340 Frame com.mrousavy.camera.example I Converting 1280 x 720 @ 1280 HardwareBuffer...
2025-05-26 00:26:56.945 10276-10340 .camera.example com.mrousavy.camera.example E lockImpl:290 failed with 'Error3::BAD_VALUE'
2025-05-26 00:26:56.945 10276-10340 Gralloc3 com.mrousavy.camera.example W lock(0xb400006e6b06e730, ...) failed: 3
Camera Device
{
"formats": [],
"sensorOrientation": "landscape-left",
"hardwareLevel": "limited",
"maxZoom": 1,
"minZoom": 1,
"maxExposure": 6,
"supportsLowLightBoost": false,
"neutralZoom": 1,
"physicalDevices": [
"ultra-wide-angle-camera"
],
"supportsFocus": true,
"supportsRawCapture": false,
"isMultiCam": false,
"minFocusDistance": 999.999985098839,
"minExposure": -6,
"name": "10 (BACK) androidx.camera.camera2",
"hasFlash": false,
"hasTorch": false,
"position": "back",
"id": "10"
}
Device
Android 15 emulator with Google Play Service
VisionCamera Version
4.6.4
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information
- [ ] I am using Expo
- [x] I have enabled Frame Processors (react-native-worklets-core)
- [x] I have read the Troubleshooting Guide
- [x] I agree to follow this project's Code of Conduct
- [x] I searched for similar issues in this repository and found none.
Guten Tag, Hans here 🍻
Looks like you provided helpful information and logs, which is good! Regarding your issue with frame.toArrayBuffer() on Android 15, I suggest checking if your environment is properly set up or if there are some configurations you might have missed. Since it's working on iOS, it could be specific to the Android implementation or the emulator's handling.
Please keep an eye on updates to see if this gets addressed. If you find a need for more detailed help, you might want to consider sponsoring the project here to get quicker responses. Let's keep this open for now!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
I have checked my environment and configurations, they are correctly set up. @mrousavy can you please have a look?
I have the same issue @mrousavy
Seems device specific.
Samsung Galaxy S25, Android 15: ❌ crashes Samsung A36, Android 15: ❌ crashes Samsung Galaxy S24 FE, Android 15: 🟢 works as expected Samsung S20, Android 13: 🟢 works as expected
Temporary workaround is to wrap calls with a try catch
try {
const buffer = frame.toArrayBuffer();
// do processing on buffer
} catch (err) {
// handle devices that throw, so app doesn't crash
}
| GPU | |
|---|---|
| samsung a36 | Adreno 710 |
| samsung galaxy s25 | Adreno 830 |
| samsung galaxy s24 fe | Xclipse 940 |
| Samsung S20 FE 5g | Adreno 650 |
From logcat
2025-10-20 10:23:32.993 22236-22395 Frame com.sample.app I Converting 1280 x 720 @ 1280 HardwareBuffer... 2025-10-20 10:23:32.994 22236-22395 SnapAlloc com.sample.app E Lock failed - CPU can't access 2025-10-20 10:23:32.994 22236-22395 qdgralloc com.sample.app E Lock: Failed to lock via SnapAlloc. Error code: 3 2025-10-20 10:23:32.994 22236-22395 qdgralloc com.sample.app E Snap failed to lock buffer 2025-10-20 10:23:32.994 22236-22395 Gralloc5 com.sample.app W lock(0x792c522350, ...) failed: 3