Skip to content

Support Promise<ArrayBuffer> in Java and ObjC TurboModules - #57937

Open
paradowstack wants to merge 1 commit into
react:mainfrom
paradowstack:feat/promise-array-buffer-support
Open

Support Promise<ArrayBuffer> in Java and ObjC TurboModules#57937
paradowstack wants to merge 1 commit into
react:mainfrom
paradowstack:feat/promise-array-buffer-support

Conversation

@paradowstack

Copy link
Copy Markdown
Contributor

Summary:

Promise<ArrayBuffer> was left out of the initial ArrayBuffer TurboModule landing because Android's promise-resolve path serializes through folly::dynamic, which cannot carry raw bytes. Codegen rejected the type on both iOS and Android so a spec that built on one platform could not silently diverge on the other.

This removes that guard and wires up Promise<ArrayBuffer> / Promise<?ArrayBuffer> on both platforms. On Android, codegen sets a per-method promiseResolveSupportsArrayBuffer flag on the JNI host function; when true, the resolve callback is a dedicated JCxxArrayBufferCallbackImpl / CxxArrayBufferCallbackImpl that hands a ByteBuffer (or null) straight to JSI as an ArrayBuffer without going through folly::dynamic. On iOS the resolve path already converted NSMutableData to a zero-copy jsi::ArrayBuffer - only the codegen rejection needed to come out.

Rebase note: This PR is based on main and still uses the landed buffer types (NSMutableData on iOS, ByteBuffer on Android). After the zero-copy follow-ups land (#57879, #57897), this branch should rebase and switch the use those types (RCTArrayBuffer * instead of NSMutableData *, ArrayBuffer instead of ByteBuffer).

Changelog:

[GENERAL] [ADDED] - Add Promise<ArrayBuffer> support for iOS (ObjC) and Android (Java/Kotlin) TurboModules

Test Plan:

  • Codegen Java spec, JNI C++, ObjC header, and .mm snapshot tests updated for promiseArrayBuffer / promiseNullableArrayBuffer.
  • RCTTurboModuleArrayBufferTeststestPromiseResolvesArrayBuffer covers the iOS resolve path end to end.
  • RCTSampleTurboModule / SampleTurboModule add getAsyncBuffer, which resolves a Promise with a native-allocated buffer; SampleTurboModuleExample exercises it from JS.
  • C++ API snapshots regenerated.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 13, 2026
@paradowstack
paradowstack force-pushed the feat/promise-array-buffer-support branch from 3b4953a to a1325b9 Compare August 13, 2026 13:15
@paradowstack
paradowstack force-pushed the feat/promise-array-buffer-support branch from a1325b9 to 5c55393 Compare August 13, 2026 13:47
@paradowstack paradowstack changed the title feat: support Promise<ArrayBuffer> in Java and ObjC TurboModules Support Promise<ArrayBuffer> in Java and ObjC TurboModules Aug 13, 2026
@paradowstack
paradowstack marked this pull request as ready for review August 13, 2026 14:19
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant