vision-camera-barcode-scanner icon indicating copy to clipboard operation
vision-camera-barcode-scanner copied to clipboard

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

Open marcshilling opened this issue 1 year ago • 3 comments

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?

marcshilling avatar Jan 30 '24 22:01 marcshilling

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.

grevtsovna avatar Feb 05 '24 05:02 grevtsovna

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:

  • Galaxy A51
  • Galaxy Tab S7 FE
  • Galaxy Tab S6 Lite
  • Galaxy S21 FE 5G
  • Galaxy M11
  • Galaxy S20 FE

KraljSamo avatar Feb 06 '24 07:02 KraljSamo

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

mgcrea avatar Feb 06 '24 07:02 mgcrea