mgcrea / vision-camera-barcode-scanner

High performance barcode scanner for React Native using VisionCamera
MIT License
84 stars 11 forks source link

Frame Processor Error: Exception in HostFunction: java.lang.RuntimeException: Frame is already closed! #23

Open marcshilling opened 7 months ago

marcshilling commented 7 months ago

I'm seeing reports of this from my Android users in production.

The full exception is:

Frame Processor Error: Exception in HostFunction: java.lang.RuntimeException: Frame is already closed! Are you trying to access the Image data outside of a Frame Processor's lifetime?
- If you want to use `console.log(frame)`, use `console.log(frame.toString())` instead.
- If you want to do async processing, use `runAsync(...)` instead.
- If you want to use runOnJS, increment it's ref-count: `frame.incrementRefCount()`

This seems to be an exception that was intentionally put in to throw when apparently doing something wrong: https://github.com/mrousavy/react-native-vision-camera/pull/2327

Not sure if this is a problem with your implementation of the frame processor or upstream: https://github.com/mrousavy/react-native-vision-camera/issues/2253. Any ideas?

grevtsovna commented 7 months ago

I faced the same issue. In my case, it happens when the camera turns off because of leaving the screen.

 ERROR  Frame Processor Error: Exception in HostObject::get for prop 'width': java.lang.RuntimeException: Frame is already closed! Are you trying to access the Image data outside of a Frame Processor's lifetime?
- If you want to use `console.log(frame)`, use `console.log(frame.toString())` instead.
- If you want to do async processing, use `runAsync(...)` instead.
- If you want to use runOnJS, increment it's ref-count: `frame.incrementRefCount()`, js engine: VisionCamera

Downgrading to these versions has partly settled the problem.

{
  "@mgcrea/vision-camera-barcode-scanner": "0.6.6",
  "react-native-vision-camera": "3.6.16"
}

The error still occurs but doesn’t lead to crashes anymore.

KraljSamo commented 7 months ago

This seems to be a common issue on many Samsung devices. Other seem fine according to my logs. I can see this crash on the following Samsung devices:

mgcrea commented 7 months ago

You can try the latest release as it might fix this.