vision-camera-code-scanner
vision-camera-code-scanner copied to clipboard
iOS - worklet error , Android - undefined error
Hi guys i was heading some issue with iOS and Android both.
Android:
Frame Processor threw an error: undefined is not a function
iOS:
Error: Javascript worklet error
at _f (native)
Error: Exception in HostFunction: Javascript worklet error
...
i fixed it by directly using __scanCodes
here is example code that fully works for me
Solution
export const Scanner: React.FC = () => {
const devices = useCameraDevices();
const device = devices.back;
const frameProcessor = useFrameProcessor(frame => {
'worklet';
const barcodes = __scanCodes(frame, [BarcodeFormat.ALL_FORMATS]);
}, []);
if (device == null) return <></>;
return (
<Camera
style={{flex: 1}}
device={device}
isActive={true}
frameProcessor={frameProcessor}
frameProcessorFps={5}
/>
);
};
i'm not sure that exactly why this works. But i will work around when i have some time
Same error:
libc++abi: terminating with uncaught exception of type facebook::jsi::JSError: Exception in HostFunction: Javascript worklet error
Error: Javascript worklet error
at _f (native)
Error: Exception in HostFunction: Javascript worklet error
Error: Javascript worklet error
at _f (native)
at _f (native)
@whtjs how've you fixed it?. I still got this error
@namnhagiletech did you try the solution?
There no need to try the solution.
The correct way is import react-native-reanimated at index.js, remember to install pods for ios and config the babel file. It'll work
@namnh240795 when i use with apollo-client@^3.5.4
, i need to change metro.config.js
to enable cjs extension
Same issue for me.
react-native-reanimated": "2.10.0
react-native": "0.70.0
vision-camera-code-scanner": "0.2.0
It crashes when I call scanBarcodes
.
libc++abi: terminating with uncaught exception of type facebook::jsi::JSError: Exception in HostFunction: Javascript worklet error
Error: Javascript worklet error
at _f (native)
Error: Exception in HostFunction: Javascript worklet error
Error: Javascript worklet error
at _f (native)
at _f (native)
@aliaksei-niamkovich what platform are you crashing facing on ?? If iOS included what xcode version are you using?
@whtjs iOS, Version 14.0 (14A309)
@aliaksei-niamkovich I also had same issue after upgrade to xcode 14, you can check this on react-native-vision-camera's issue
tl;dr try to
- downgrade xcode 13
- remove pods and reinstall
- clean & build
@whtjs Thanks, now It works!
Any news regarding this? According to the vision camera issue it's not an issue with vision camera, but rather with the Swift implementation of this (and other) plugin
Hey all, react-native-reanimated maintainer here.
Exception in HostFunction: Javascript worklet error
is a generic error message that shows up when some worklet throws an error (like undefined is not a function
here). Reanimated catches all errors from worklets and passes them to the console or LogBox.
While the error is caused by other third-party library, we are currently improving the developer experience by presenting the full error message instead of only "Javascript worklet error". See the PR: https://github.com/software-mansion/react-native-reanimated/pull/3558
As per this issue for now you can do a patch so that you can build in Xcode 14
diff --git a/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h b/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h
index a2ccdcb..b9e0a56 100644
--- a/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h
+++ b/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h
@@ -53,7 +53,7 @@ objc_name : NSObject<FrameProcessorPluginBase>
@end \
@implementation objc_name (FrameProcessorPlugin) \
\
-__attribute__((constructor)) static void VISION_CONCAT(initialize_, objc_name)() \
++(void)load \
{ \
[FrameProcessorPluginRegistry addFrameProcessorPlugin:@"__" @ #name callback:^id(Frame* frame, NSArray<id>* args) { \
return [objc_name callback:frame withArgs:args]; \
As per this issue for now you can do a patch so that you can build in Xcode 14
diff --git a/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h b/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h index a2ccdcb..b9e0a56 100644 --- a/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h +++ b/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h @@ -53,7 +53,7 @@ objc_name : NSObject<FrameProcessorPluginBase> @end \ @implementation objc_name (FrameProcessorPlugin) \ \ -__attribute__((constructor)) static void VISION_CONCAT(initialize_, objc_name)() \ ++(void)load \ { \ [FrameProcessorPluginRegistry addFrameProcessorPlugin:@"__" @ #name callback:^id(Frame* frame, NSArray<id>* args) { \ return [objc_name callback:frame withArgs:args]; \
Very Good Information!! Thanks 👍
As per this issue for now you can do a patch so that you can build in Xcode 14
diff --git a/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h b/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h index a2ccdcb..b9e0a56 100644 --- a/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h +++ b/node_modules/react-native-vision-camera/ios/Frame Processor/FrameProcessorPlugin.h @@ -53,7 +53,7 @@ objc_name : NSObject<FrameProcessorPluginBase> @end \ @implementation objc_name (FrameProcessorPlugin) \ \ -__attribute__((constructor)) static void VISION_CONCAT(initialize_, objc_name)() \ ++(void)load \ { \ [FrameProcessorPluginRegistry addFrameProcessorPlugin:@"__" @ #name callback:^id(Frame* frame, NSArray<id>* args) { \ return [objc_name callback:frame withArgs:args]; \
Hi, I have applied this patch but still facing the same issue:(
same