-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Multithreading with worklets #1561
Conversation
Hi @karol-bisztyga! Thanks for taking time to look into this! I'm currently writing a Camera TurboModule, and I'm planning on creating an API where the user can process frames using JS. So for example: const processFrame = useWorkletCallback((frame: CameraFrame) => {
// process frame data in this worklet, for example to detect faces, render a square ontop of a QR code, or whatever.
}, []);
return <Camera {...props} processFrame={processFrame} />; The benefits of this are hopefully immediately clear:
I'm currently halfway through implementing the Camera base stuff (format selection, capturing videos, capturing photo, ...), but I'm already excited to have something working in the near future. Just leaving this here to make it clear that multithreaded worklets do indeed have many use cases, and perhaps we can work together to extend the proof of concept to a fully functional use case with the Camera process frame API 👍
|
5e8a111
to
6f7572f
Compare
To those interested: I've published the react-native-vision-camera library (🎉) and am now working on the Frame Processor thing. All progress is public at: mrousavy/react-native-vision-camera#2 EDITI've finished the Frame Processors API for iOS and Android!! 🎉🎉🎉 - This is an API where you can run multithreaded JS code on every camera frame in realtime (endless possibilities for video frame processing such as Face filters, QR code scanners, WebRTC and more). Take a look at the docs: VisionCamera - Frame Processors Also, I created a library for running JS code on a separate thread, basically exactly what this PR attempted to do (Multithreading with Worklets for running heavy code in there in parallel) - Check it out: mrousavy/react-native-multithreading |
It's exactly what I'm looking for and dreamed of. It allows not touching native as much as possible. I need this for video recorder app. While I can't help, eagerly waiting for this feature. |
Description
This idea has been postponed due to low priority.
The solution here is dirty, it's more like a POC for the future if we decide to focus on this topic again.
The goal is to be able to run worklets on multiple threads different than JS and UI.
Use cases
Examples
example code