From 1e2e07da2c291fb005b05525493720ca49e18d4e Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Wed, 3 Apr 2019 13:19:17 -0700 Subject: [PATCH] TM Android: fixed up JSCallInvoker creation Summary: A previous commit changed the signature of the Instance (the arg to JSCallInvoker) to be a weak ref, so this callsite needs updating. Reviewed By: mmmulani Differential Revision: D14757188 fbshipit-source-id: 1a8663e56a42b26c6202881c57a7caafa71da2ab --- .../main/java/com/facebook/react/turbomodule/core/jni/BUCK | 1 + .../react/turbomodule/core/jni/TurboModuleManager.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK index 5803c6741e28d7..aab5a3f426835d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK @@ -33,6 +33,7 @@ rn_xplat_cxx_library( ], exported_deps = [ "fbsource//xplat/jsi:jsi", + react_native_xplat_target("cxxreact:bridge"), react_native_xplat_target("turbomodule/core:core"), ], ) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/TurboModuleManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/TurboModuleManager.cpp index 4cfc65712c2222..7fbf35eb87298b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/TurboModuleManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/TurboModuleManager.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -56,7 +57,9 @@ void TurboModuleManager::installJSIBindings() { [this](const std::string &name) { const auto moduleInstance = getJavaModule(name); // TODO: Pass in react Instance to JSCallInvoker instead. - const auto jsInvoker = std::make_shared(nullptr); + std::shared_ptr instance = nullptr; + std::weak_ptr weakInstance = instance; + const auto jsInvoker = std::make_shared(weakInstance); return moduleProvider_(name, moduleInstance, jsInvoker); }) );