From d7beeb5eedcc4115d1b6a654fc08964b1b16ce4b Mon Sep 17 00:00:00 2001 From: Brad Anderson Date: Sat, 25 Jan 2025 11:22:40 -0500 Subject: [PATCH] fix: TypedArray cache cleanup --- android/src/main/cpp/Tflite.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/android/src/main/cpp/Tflite.cpp b/android/src/main/cpp/Tflite.cpp index 357b9e86..13bf0ae1 100644 --- a/android/src/main/cpp/Tflite.cpp +++ b/android/src/main/cpp/Tflite.cpp @@ -30,6 +30,16 @@ struct TfliteModule : public jni::JavaClass { } auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker(); + + // Adds the PropNameIDCache object to the Runtime. If the Runtime gets + // destroyed, the Object gets destroyed and the cache gets invalidated. + auto propNameIdCache = std::make_shared(runtime); + runtime.global().setProperty( + runtime, + "tfPluginPropNameIdCache", + jsi::Object::createFromHostObject(runtime, propNameIdCache) + ); + auto fetchByteDataFromUrl = [](std::string url) { // Attaching Current Thread to JVM JNIEnv* env = nullptr;