Repository navigation
JArrayBuffer zero-copy class for Java TM - #57897
Closed
paradowstack wants to merge 1 commit into
Closed
paradowstack wants to merge 1 commit into
paradowstack wants to merge 1 commit into
Conversation
paradowstack
force-pushed
the
feat/zero-copy-array-buffers-java
branch
from
August 12, 2026 13:06
eb9740a to
fab3a9f
Compare
paradowstack
force-pushed
the
feat/zero-copy-array-buffers-java
branch
from
August 12, 2026 13:18
fab3a9f to
44046b3
Compare
paradowstack
marked this pull request as ready for review
August 12, 2026 13:38
|
@christophpurrer has imported this pull request. If you are a Meta employee, you can view this in D115755247. |
|
@christophpurrer merged this pull request in 5bb9639. |
tvinhas
pushed a commit
to tvinhas/react-native-macos
that referenced
this pull request
Oct 21, 2026
Summary: Android TurboModules mapped a JS `ArrayBuffer` to `java.nio.ByteBuffer`, copying every argument into a direct buffer — and `ByteBuffer` carries no ownership contract, so there was no way to express aliased or borrowed bytes for synchronous in-place access. This adds `ArrayBuffer` (`packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ArrayBuffer.kt`) as the Java representation of an `ArrayBuffer`. It carries an `isOwningBytes` flag: an owning buffer can be stored and returned to JS, a non-owning one aliases bytes valid only for the synchronous call that produced it. Codegen now emits `ArrayBuffer` for `ArrayBufferTypeAnnotation` params (was `ByteBuffer`) and returns (was `ByteBuffer`). ## Changelog: [ANDROID] [ADDED] - Add `ArrayBuffer`, the Java representation of a JS `ArrayBuffer` for TurboModules, with an explicit byte-ownership contract Pull Request resolved: react#57897 Test Plan: - Codegen Java spec and JNI C++ snapshot tests updated for `ArrayBuffer` param/return signatures. - `SampleTurboModule` doubles its sync argument in place and returns the same buffer, covering the zero-copy path end to end; `createNativeBuffer` allocates via `ArrayBuffer`. - C++ API snapshots regenerated. Reviewed By: javache Differential Revision: D115755247 Pulled By: christophpurrer fbshipit-source-id: de067789ad145b7202da721a02f838358c82f4d8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Android TurboModules mapped a JS
ArrayBuffertojava.nio.ByteBuffer, copying every argument into a direct buffer — andByteBuffercarries no ownership contract, so there was no way to express aliased or borrowed bytes for synchronous in-place access.This adds
ArrayBuffer(packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ArrayBuffer.kt) as the Java representation of anArrayBuffer. It carries anisOwningBytesflag: an owning buffer can be stored and returned to JS, a non-owning one aliases bytes valid only for the synchronous call that produced it.Codegen now emits
ArrayBufferforArrayBufferTypeAnnotationparams (wasByteBuffer) and returns (wasByteBuffer).Changelog:
[ANDROID] [ADDED] - Add
ArrayBuffer, the Java representation of a JSArrayBufferfor TurboModules, with an explicit byte-ownership contractTest Plan:
ArrayBufferparam/return signatures.SampleTurboModuledoubles its sync argument in place and returns the same buffer, covering the zero-copy path end to end;createNativeBufferallocates viaArrayBuffer.