fix: Improve C++ safety by attaching Cache Invalidator to jsi::Runtime
's lifecycle (#1488)
* fix: fix C++ lint * fix: attach `InvalidateCacheOnDestroy` to `jsi::Runtime`
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "JSIJNIConversion.h"
|
||||
#include "java-bindings/JImageProxy.h"
|
||||
#include "java-bindings/JFrameProcessorPlugin.h"
|
||||
#include "JSITypedArray.h"
|
||||
|
||||
namespace vision {
|
||||
|
||||
@@ -151,6 +152,12 @@ void FrameProcessorRuntimeManager::installJSIBindings() {
|
||||
|
||||
auto& jsiRuntime = *_jsRuntime;
|
||||
|
||||
// HostObject that attaches the cache to the lifecycle of the Runtime. On Runtime destroy, we destroy the cache.
|
||||
auto propNameCacheObject = std::make_shared<vision::InvalidateCacheOnDestroy>(jsiRuntime);
|
||||
jsiRuntime.global().setProperty(jsiRuntime,
|
||||
"__visionCameraPropNameCache",
|
||||
jsi::Object::createFromHostObject(jsiRuntime, propNameCacheObject));
|
||||
|
||||
auto setFrameProcessor = JSI_HOST_FUNCTION_LAMBDA {
|
||||
__android_log_write(ANDROID_LOG_INFO, TAG, "Setting new Frame Processor...");
|
||||
|
||||
|
@@ -45,7 +45,7 @@ class FrameProcessorRuntimeManager : public jni::HybridClass<FrameProcessorRunti
|
||||
void registerPlugin(alias_ref<JFrameProcessorPlugin::javaobject> plugin);
|
||||
void logErrorToJS(const std::string& message);
|
||||
|
||||
void setFrameProcessor(jsi::Runtime& runtime, // NOLINT(runtime/references)
|
||||
void setFrameProcessor(jsi::Runtime& runtime,
|
||||
int viewTag,
|
||||
const jsi::Value& frameProcessor);
|
||||
void unsetFrameProcessor(int viewTag);
|
||||
|
@@ -14,9 +14,9 @@ namespace JSIJNIConversion {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
jobject convertJSIValueToJNIObject(jsi::Runtime& runtime, const jsi::Value& value); // NOLINT(runtime/references)
|
||||
jobject convertJSIValueToJNIObject(jsi::Runtime& runtime, const jsi::Value& value);
|
||||
|
||||
jsi::Value convertJNIObjectToJSIValue(jsi::Runtime& runtime, const jni::local_ref<jobject>& object); // NOLINT(runtime/references)
|
||||
jsi::Value convertJNIObjectToJSIValue(jsi::Runtime& runtime, const jni::local_ref<jobject>& object);
|
||||
|
||||
} // namespace JSIJNIConversion
|
||||
|
||||
|
Reference in New Issue
Block a user