fix: Fix SharedArray JSI constructor allocating a new array instead of wrapping (#2444)

This commit is contained in:
Marc Rousavy 2024-01-26 12:05:00 +01:00 committed by GitHub
parent 7f4e037f25
commit c911d25727
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ jni::local_ref<JSharedArray::javaobject> JSharedArray::create(jsi::Runtime& runt
JSharedArray::JSharedArray(jsi::Runtime& runtime, std::shared_ptr<jsi::ArrayBuffer> arrayBuffer) { JSharedArray::JSharedArray(jsi::Runtime& runtime, std::shared_ptr<jsi::ArrayBuffer> arrayBuffer) {
size_t size = arrayBuffer->size(runtime); size_t size = arrayBuffer->size(runtime);
__android_log_print(ANDROID_LOG_INFO, TAG, "Wrapping JSI ArrayBuffer with size %zu...", size); __android_log_print(ANDROID_LOG_INFO, TAG, "Wrapping JSI ArrayBuffer with size %zu...", size);
jni::local_ref<JByteBuffer> byteBuffer = JByteBuffer::allocateDirect(size); jni::local_ref<JByteBuffer> byteBuffer = JByteBuffer::wrapBytes(arrayBuffer->data(runtime), size);
_arrayBuffer = arrayBuffer; _arrayBuffer = arrayBuffer;
_byteBuffer = jni::make_global(byteBuffer); _byteBuffer = jni::make_global(byteBuffer);