Multithreading support for Expo with JSI
A
Ansh Nanda
It would be great if we could run tasks on other threads in Expo using this package for example: https://github.com/mrousavy/react-native-multithreading
Brent Vatne
you can use this package with development builds: https://docs.expo.dev/development/introduction/
A
Ansh Nanda
Brent Vatne: Expo Module API is not out yet so JSI is not supported yet.
Brent Vatne
Ansh Nanda: sorry i don't understand what you mean. we have been using JSI in expo-gl for a long time. reanimated v2 uses JSI. etc.
ccheever
interesting. what kinds of tasks would you want to multithread?
A
Ansh Nanda
ccheever: Generally speaking I think the use-cases will be very similar to web workers.
Specifically, I have the following use-cases in my app:
- Running a queue + worker model to offload intensive tasks to a different thread. For example, my current company needs to actively fetch, parse, and edit a lot of data in the background (hundreds of MBs of JSON) ideally without impacting the user's current task. Not currently possible without multithreading.
- CPU intensive parsing. Changing property in largely nested objects and arrays (I'm talking multiple MB objects)
- CPU intensive computation of values that can't be memoized. Bad example but calculating a large prime number would be one.
- Implementing any "background" tasks while the app is open in a non-blocking manner.
- Can just generally help speed things up.
ccheever
Ansh Nanda: Thanks for sharing your use cases. That's helpful!