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;