React Native Camera Crashes After Taking Image #174785
-
BodyHi! I'm actually trying to make an app that scans images on my S24+ using react-native-camera, but when I take pictures, it just crashes directly after. Does someone have a fix for this please? I tried reducing the image format and everything, but it doesnt work... Only fix was switching to an older phone :(( Thanks! Guidelines
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Hit me up if you have a fix too |
Beta Was this translation helpful? Give feedback.
-
|
Try (https://github.com/mrousavy/react-native-vision-camera) |
Beta Was this translation helpful? Give feedback.
-
|
After a bit of profiling and debugging, I realized the crash stemmed from a mismatch between the default image capture format and the device’s native stream configuration on high-resolution sensors (notably on Samsung’s S24+). The root issue is that react-native-camera doesn’t dynamically negotiate supported formats on modern devices. It often defaults to an unsupported preview size that causes the native layer to crash after image capture. A more robust solution is to migrate to react-native-vision-camera, which provides fine-grained control over format negotiation and proper device synchronization through hooks like const device = useCameraDevices().back;
const format = useCameraFormat(device, [
{ videoAspectRatio: 16 / 9 },
{ videoResolution: { width: 3048, height: 2160 } },
{ fps: 60 },
]);
<Camera
device={device}
isActive={true}
format={format}
photo={true}
/>This explicitly constrains the output to a supported aspect ratio and frame rate, ensuring that the hardware encoder doesn’t attempt to allocate unsupported buffers. In short, the crash isn’t React Native’s fault 😑 It’s the camera HAL failing under incompatible resolutions. Using react-native-vision-camera resolves this by enforcing a deterministic format negotiation layer. Hope this saves someone else a few hours of low-level debugging, cause it sure took me a lot of time to find this issue 😆 P-S: Pls 🎩 me if this didnt work 😄 |
Beta Was this translation helpful? Give feedback.
After a bit of profiling and debugging, I realized the crash stemmed from a mismatch between the default image capture format and the device’s native stream configuration on high-resolution sensors (notably on Samsung’s S24+).
The root issue is that react-native-camera doesn’t dynamically negotiate supported formats on modern devices. It often defaults to an unsupported preview size that causes the native layer to crash after image capture.
A more robust solution is to migrate to react-native-vision-camera, which provides fine-grained control over format negotiation and proper device synchronization through hooks like
useCameraFormat().Here’s the configuration that stabilized the capture…