Threads: keep the caller responsive
Prerequisites: 03-fabric-path, 05-expo-module-contract
Threads: keep the caller responsive — mechanism
Mental model verified
The JS thread runs application logic and usually render work; the UI thread alone manipulates host views. React Native may schedule some rendering on the UI thread. Expo Function runs on JS; AsyncFunction can dispatch to a native queue, with .runOnQueue(.main) when UI access is required.
[S02] [S07]Worked example synthesis
For a document picker: start platform UI on main, perform file reading away from main, resolve the Promise with a URI and metadata, then update React state on JS. Avoid sending the whole file through a JS value when a URI suffices.
[S02] [S07]Engineering choice synthesis
Bound synchronous work, use async for I/O, and isolate native state touched from multiple queues. Keep main-thread sections short and check cancellation when an activity or view goes away.
[S07] [S12]Pitfall and next step synthesis
A Promise can still hide blocking native work if its implementation uses the main queue for CPU-heavy processing. Trace queue hops with profiling and measure both JS and UI frames in a release build.
[S07] [S12]Check yourself: Why can a native synchronous method cause a dropped JS frame?
It executes on the JS caller thread and prevents JS work from progressing until it returns.