[core][Android] Improve JavaScriptArrayBuffer support#41404
Merged
Conversation
Collaborator
|
The Pull Request introduced fingerprint changes against the base commit: 1ac84d3 Fingerprint diff[
{
"op": "changed",
"beforeSource": {
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoAutolinkingIos"
],
"hash": "7a7c1d05c6b0afcac921753a366523e572ec704e"
},
"afterSource": {
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoAutolinkingIos"
],
"hash": "e0c39816859f2e6e263c3ecdbba9b0f988110d80"
}
}
]Generated by PR labeler 🤖 |
Contributor
|
Subscribed to pull request
Generated by CodeMention |
lukmccall
approved these changes
Dec 4, 2025
| - Add types for `process.env.EXPO_DOM_HOST_OS`. ([#40382](https://github.com/expo/expo/pull/40382) by [@EvanBacon](https://github.com/EvanBacon)) | ||
| - [Android] Add `ComposableScope` for compose Content functions. ([#39155](https://github.com/expo/expo/pull/39155) by [@aleqsio](https://github.com/aleqsio)) | ||
| - [Android] Adds support for `ArrayBuffer`. ([#39943](https://github.com/expo/expo/pull/39943) by [@lukmccall](https://github.com/lukmccall)) | ||
| - [Android] Adds support for `ArrayBuffer`. ([#39943](https://github.com/expo/expo/pull/39943) by [@lukmccall](https://github.com/lukmccall), [#41404](https://github.com/expo/expo/pull/41404) by [@barthap](https://github.com/barthap)) |
Contributor
There was a problem hiding this comment.
I would put it as a separate entry
3 tasks
aleqsio
pushed a commit
that referenced
this pull request
Dec 5, 2025
# Why Follow up #39943, added support for returning array buffers from functions, and obtaining direct `ByteBuffer` for it # How - added `JavaScriptArrayBuffer.toDirectBuffer()` - added JNI to JSI converter # Test Plan - unit tests ✅ # Checklist - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
3 tasks
barthap
added a commit
that referenced
this pull request
Dec 11, 2025
# Why Follow up #41404 In addition to accepting ArrayBuffers from JS as arguments, add possibility to create them in native code. Such native buffers are safe to use on non-JS threads. Also add possibility to copy JS buffer into native buffer. # How - Introduced `NativeArrayBuffer` type, that is backed by Java direct `ByteBuffer`: - Can be created in native code, either by allocating memory of given size, wrapping existing `ByteBuffer` or copying an existing `JavaScriptArrayBuffer`. - Can be passed as function argument - it creates a copy of the original buffer (in contrast to `JavaScriptArrayBuffer` which references original memory) - Can be returned to JS, thanks to the `jsi::ArrayBuffer(rt, jsi::MutableBuffer&)` constructor. This allows zero-copy passing allocated memory to JS (in contrast to the existing `ByteArray` converter) - Introduced `ArrayBuffer` interface for operations common for both JS and native buffers - useful for APIs that can work with either buffer type. # Test Plan - Unit tests ✅ - Manual testing in NCL # Checklist - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) --------- Co-authored-by: Łukasz Kosmaty <kosmatylukasz@gmail.com>
aleqsio
pushed a commit
that referenced
this pull request
Dec 22, 2025
# Why Follow up #41404 In addition to accepting ArrayBuffers from JS as arguments, add possibility to create them in native code. Such native buffers are safe to use on non-JS threads. Also add possibility to copy JS buffer into native buffer. # How - Introduced `NativeArrayBuffer` type, that is backed by Java direct `ByteBuffer`: - Can be created in native code, either by allocating memory of given size, wrapping existing `ByteBuffer` or copying an existing `JavaScriptArrayBuffer`. - Can be passed as function argument - it creates a copy of the original buffer (in contrast to `JavaScriptArrayBuffer` which references original memory) - Can be returned to JS, thanks to the `jsi::ArrayBuffer(rt, jsi::MutableBuffer&)` constructor. This allows zero-copy passing allocated memory to JS (in contrast to the existing `ByteArray` converter) - Introduced `ArrayBuffer` interface for operations common for both JS and native buffers - useful for APIs that can work with either buffer type. # Test Plan - Unit tests ✅ - Manual testing in NCL # Checklist - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) --------- Co-authored-by: Łukasz Kosmaty <kosmatylukasz@gmail.com>
barthap
added a commit
that referenced
this pull request
Jan 12, 2026
# Why Follow up #41404 and #41415 for Android. Adds support for `JavaScriptArrayBuffer` and `NativeArrayBuffer` in Expo modules. # How - Similarly to Android version, created two types of ArrayBuffers: - `JavaScriptArrayBuffer` that wraps JSI ArrayBuffer object - `NativeArrayBuffer` that manages direct memory, is thread safe, can be created on native side. When used as argument type, a JS buffer is copied. Then, zero-copy JSI ArrayBuffer is created upon returning. - Both inherit the `ArrayBuffer` class which contains some utilities for working with `Unsafe[...]Pointer`s and `Data`. I tried to keep code organized similarly to the typed arrays implementation, to keep it somehow consistent. # Test Plan - Created native unit test specs for the APIs. - Manual testing in NCL # Checklist - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) --------- Co-authored-by: Łukasz Kosmaty <kosmatylukasz@gmail.com>
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.
Why
Follow up #39943, added support for returning array buffers from functions, and obtaining direct
ByteBufferfor itHow
JavaScriptArrayBuffer.toDirectBuffer()Test Plan
Checklist
changelog.mdentry and rebuilt the package sources according to this short guidenpx expo prebuild& EAS Build (eg: updated a module plugin).