Replies: 4 comments 2 replies
-
Very interesting idea. Could this help to speed up data sharing between the react-native-reanimated worklet runtime and the js thread runtime? |
Beta Was this translation helpful? Give feedback.
-
What do you mean by arbitrarily complex? Would it count objects with pre-built prototypes, i.e. maps and sets? What about prototypes that exist on one runtime, but don't on another (class instances)? @SamuelScheit regarding your question, it's hard to tell if it will speed up the worklets in a significant way. It would definitely help with the data sharing, however we try to keep the data sharing itself to an absolute minimum. Initialization of worklets etc. would certainly benefit from it but it's hard to estimate the overall performance gain. Import factor here are also the new opportunities that arise. Such API could greatly simplify the codebase of Reanimated and might open a window for new features which are too difficult to implement or maintain with current API of JSI. This is particularly important as we are working on |
Beta Was this translation helpful? Give feedback.
-
How does this work for functions? Can a function be created and serialized on one runtime, then deserialized and called (with proper closure) on another? |
Beta Was this translation helpful? Give feedback.
-
A few more questions:
|
Beta Was this translation helpful? Give feedback.
-
Would people be interested in a JSI API that enables very fast copying of objects between runtimes? The API would look something like:
A value (which can be arbitrarily complex) serialized by one runtime can then be de-serialized multiple times by multiple runtimes, if desired. The runtimes must all be the same kind though! I.e. cannot serialize in Hermes and de-serialize in JSC. The semantics are similar to
structuredClone()
:It is up to the developer to deliver the Serialized instance to the other runtime, potentially in another thread.
The serialization/deserialization will use internal VM APIs, so it is extremely fast, much much faster than what is possible using JSI today. Note that the
Serialized
object is fully opaque - once created, it can only be used to de-serialize the data and be destroyed.This can be used as a building block of a Web Worker implementation.
Beta Was this translation helpful? Give feedback.
All reactions