-
Notifications
You must be signed in to change notification settings - Fork 40
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
In callInContext the function parameter is not a valid worklet and cannot be called between contexts or from/to JS from/to a context. #125
Comments
Is this because of recursion? Does it work if you refactor your code to use simple for loops instead of recursively calling |
Same thing happening to me, with the simplest worklet possible - just immediately returning a string |
Happening to me as well. Running on Expo 49, and build with EAS.
Is this package compatible with Expo ? |
The problem with the fibionacci example is that when the using recursion like you do - the function is not available as a worklet at the point of initialisation and will therefore be undefined in the context of the workletized fibionacci function. Reanimated gives the same error: const fibonacci = (num: number): number => {
"worklet";
if (num <= 1) return 1;
return fibonacci(num - 1) + fibonacci(num - 2);
};
runOnUI(fibonacci)(100); Results in:
You can look at the transpiled code for the worklet to see that this is failing at the declaration level:
Results in:
Meaning that the worklet is not yet created when the plugin transforms its closure. |
Makes complete sense, recursion doesn't need to be supported imo. |
Any update on this? I am experiencing the same error. For example my code is:
When I look at the logs I see: Loading react-native-worklets-core... |
const worklet = useWorklet( Even this doesn't work. How am i suppose to use this lib |
I don't think this library is ment or at a point for public usage to easily run stuff on a seperate worker. margelo is one of the goats of RN (imo :P) but don't know what his plans are for this library, i hope someday we have a library like https://github.com/joltup/react-native-threads or the old multi-tread from margelo so we can easily do extensive stuff on a seperate thread ;p |
It is - but there is not a lot of real world cases for when you would use that- heavy lifting should be done on the native side, not on JS.
Thank you! ❤️
Worklets is a new and improved version of my old multithreading library. Worklets can be used to run stuff on a separate Thread, and the example app here demonstrates how to do that. VisionCamera V3 also uses this for Frame Processors, and this is being used in production by many apps. |
Im also upto using it in production but there is the memory leak issue (#137 , #129 ). Am I missing something? Is there a way to avoid that? Obviously I need to return some data to javascript (when a face is recognized etc) so somehow I need to call a JS function or set state from the worklet. Is there a way to do that without the memory leak bug? Without calling JS what would you use the worklet for if it cannot send any information the the js thread. |
Similar to @lgspacil and @nikhilyadavvvv, I am trying to implement a very simple example from the usage doc and getting This happens after the logs I am using it in a React component, like so:
@mrousavy are we missing something from this usage example? |
Did you install the plugin as described in the installation instructions? It is need so that the Javascript function is decorated with information necessary to make it runnable on another thread. |
@chrfalch yes I did 🙂 provided you're talking about this step:
|
My issue above looks to have been caused by the fact that our repo was using an older version of |
@ellora-virtue Did you have a way to return a value from the worklet? |
While using:
I get:
Running:
I did rebuild, prebuild, clean cache, clean pods, removed node modules reinstalled etc..
The text was updated successfully, but these errors were encountered: