The Wire · Showcase
React Native kills the ArrayBuffer copy tax
By RepoJournal · Filed · About Meta
React Native just made TurboModule ArrayBuffer crossing zero-copy on both iOS and Android, and the borrow contract is now enforced in Java.
React Native shipped a pair of zero-copy classes that eliminate the per-crossing `ArrayBuffer` copy on iOS `NSData` and Android `ByteBuffer` [1][2]. The new `RCTArrayBuffer` carries an `isOwningBytes` flag, and the follow-up Java hardening [3] enforces the borrow contract so borrowed JS-heap bytes can't outlive the call that lent them. "Follow-up hardening for the Android `ArrayBuffer` TurboModule type" [3] is exactly what this is: three distinct problems fixed, including a synchronous method handing the module a `ByteBuffer` aliasing JS memory. Work is also in progress to run the ReactAndroid JNI gtests as instrumentation tests [4], since the current host-binary setup can't even load without `/system/bin/linker64`. Over in Jest, `jest-haste-map` gets three correctness fixes [5][6][7]: duplicated mock names survive a file deletion in watch mode, locked files on Windows (like `git maintenance` touching `.git/index.lock`) no longer abort the crawl, and the cache key now separates its 11 concatenated fields. With 12 commits and 3 PRs across both repos, the focus is clearly on shaving cross-language overhead and hardening the edge cases that only manifest in production.
One email a day. Unsubscribe in one click.
Keep up with Meta in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Upgrade React Native to a nightly with #57879 and #57982 to get zero-copy ArrayBuffer and the borrow contract enforcement facebook/react-native [plan]
- → Update Jest to include #16360 fix if you rely on duplicated mock names in watch mode facebook/jest [plan]
- → Test Jest on Windows after #16358 to confirm locked-file tolerance works with your tooling facebook/jest [monitor]
References
- [1] RCTArrayBuffer zero-copy class for ObjC TM (#57879) facebook/react-native
- [2] JArrayBuffer zero-copy class for Java TM (#57897) facebook/react-native
- [3] Enforce the ArrayBuffer borrow contract for Java TurboModules (#57982) facebook/react-native
- [4] Run the ReactAndroid JNI gtests as instrumentation tests (#57976) facebook/react-native
- [5] fix(jest-haste-map): keep a duplicated mock name alive when its file goes ↗ facebook/jest
- [6] fix(jest-haste-map): tolerate a locked file while indexing on Windows ↗ facebook/jest
- [7] fix(jest-haste-map): tighten the cache key and the watched-extension match ↗ facebook/jest