Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worklets.createRunOnJS stop the app #207

Open
IlyaZusko opened this issue Jul 11, 2024 · 7 comments
Open

Worklets.createRunOnJS stop the app #207

IlyaZusko opened this issue Jul 11, 2024 · 7 comments

Comments

@IlyaZusko
Copy link

In my project, I use the frameProcessor from the react-native-vision-camera library. I have a code like this:

  const device = useCameraDevice('front');

  const {detectFaces} = useFaceDetector({
    classificationMode: 'all',
  });

  const handleDetectedFaces = Worklets.createRunOnJS(faces => {
    console.log('faces detected', faces);
  });

  const frameProcessor = useFrameProcessor(
    frame => {
      'worklet';
      const faces = detectFaces(frame);
      handleDetectedFaces(faces);
    },
    [],
  );

  return (
    <View style={{ flex: 1 }}>
      <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={true}
        enableFpsGraph
        fps={15}
        videoHdr={false}
        frameProcessor={frameProcessor}
      />
    </View>
    )

When I launch the project and go to the screen where the function is called, the application immediately freezes and in xcode I get errors like in the screenshot below
Снимок экрана 2024-07-11 в 12 22 34

My package.json

"react": "^18.3.1",
"react-native": "^0.74.3",
"react-native-vision-camera": "^4.4.1",
"react-native-vision-camera-face-detector": "^1.7.0",
"react-native-worklets-core": "^1.3.3",

My babel.config.js

module.exports = {
  presets: ['module:@react-native/babel-preset', 'module:react-native-dotenv'],
  plugins: [
    [
      'react-native-reanimated/plugin',
      {
        processNestedWorklets: true,
      },
    ],
    ['react-native-worklets-core/plugin'],
  ],
};

Initially, I assumed that this was due to the fact that I transfer too often from the worklet stream to the js stream, however, I also tried to write just a functional where, at the click of a button, I would transfer information to the js stream once and the application still hung with the same errors in xcode. Has anyone faced similar problems and how did you solve them?

@SarjuHansaliya
Copy link

Yeah I have been also facing the same issue. This started happening after I migrated to react-native-vision-camera v4.

Here is my dependancies

"react-native": "0.71.19"
"react-native-reanimated": "3.5.4"
"react-native-vision-camera": "4.5.0"
"react-native-vision-camera-face-detector": "1.7.0"
"react-native-worklets-core": "1.3.3"

And the fact is, If I create fresh project with above dependencies then it works. So I am clueless on how to debug this in my existing app.

@mrousavy I know you are very much busy, but just a guide on how to debug this would be really helpful.

@hannojg
Copy link
Member

hannojg commented Jul 24, 2024

  • @IlyaZusko can you please expand the left hand side menu in Xcode so we can see the full call stack? Right now its truncated
  • Can you try just using the reanimated plugin? So try to remove this plugin entry ['react-native-worklets-core/plugin'], and see if it changes anything
  • Could you add all your code in to a reproduction app? This will help us a lot debugging this issue!

@Meligy
Copy link

Meligy commented Aug 5, 2024

Hopefully this is not thread hijacking. But: what version of the library is recommended to use, that wouldn't suffer from this issue for example?

@SarjuHansaliya
Copy link

I upgraded to below versions and now its working without any issues

"react-native": "0.73.9"
"react-native-reanimated": "3.14.0"
"react-native-vision-camera": "4.5.1"
"react-native-vision-camera-face-detector": "1.7.0"
"react-native-worklets-core": "1.3.3"

@pvedula7
Copy link

Same issue, even with the packages from above comment.

@vijaysahani4115
Copy link

@IlyaZusko did you resolved this issue ?

@c-goettert
Copy link

I am facing the same issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants