diff --git a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp index 3503be401f48c5..71fe98f3e75e8a 100644 --- a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp +++ b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp @@ -367,11 +367,7 @@ static void jni_YGNodeCalculateLayoutJNI( void* layoutContext = nullptr; auto map = PtrJNodeMapVanilla{}; if (nativePointers) { - size_t nativePointersSize = env->GetArrayLength(nativePointers); - jlong result[nativePointersSize]; - env->GetLongArrayRegion(nativePointers, 0, nativePointersSize, result); - - map = PtrJNodeMapVanilla{result, nativePointersSize, javaNodes}; + map = PtrJNodeMapVanilla{nativePointers, javaNodes}; layoutContext = ↦ } diff --git a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJTypesVanilla.h b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJTypesVanilla.h index 8f8c778609ba90..d1202b755fa7bf 100644 --- a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJTypesVanilla.h +++ b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJTypesVanilla.h @@ -20,11 +20,15 @@ class PtrJNodeMapVanilla { public: PtrJNodeMapVanilla() : ptrsToIdxs_{}, javaNodes_{} {} - PtrJNodeMapVanilla( - jlong* nativePointers, - size_t nativePointersSize, - jobjectArray javaNodes) + PtrJNodeMapVanilla(jlongArray javaNativePointers, jobjectArray javaNodes) : javaNodes_{javaNodes} { + + JNIEnv* env = getCurrentEnv(); + size_t nativePointersSize = env->GetArrayLength(javaNativePointers); + std::vector nativePointers(nativePointersSize); + env->GetLongArrayRegion( + javaNativePointers, 0, nativePointersSize, nativePointers.data()); + for (size_t i = 0; i < nativePointersSize; ++i) { ptrsToIdxs_[(YGNodeRef) nativePointers[i]] = i; }