From a3c7102d5c03e623b0967e62dc0be30cd706928f Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Mon, 19 Jun 2023 20:00:03 -0700 Subject: [PATCH] Add a separate HermesInstance for internal (#37968) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37968 Currently we have 2 versions of JSITracing: - [Internal](https://www.internalfb.com/code/fbsource/[06c0641fed51160887cdaec18d22dd39d11ee1c0]/xplat/ReactNative/react/jsi/JSITracing.h) - [OSS](https://www.internalfb.com/code/fbsource/[06c0641fed51160887cdaec18d22dd39d11ee1c0]/xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/executor/JSITracing.h) After talking with rubennorte it's expected that the OSS version has empty implementation and we want to keep it this way for Bridgeless as well. To include both OSS and internal JSITracing for Bridgeless, in this diff a duplicate internal HermesInstance is created, after this change: - Internal HermesInstance will use existed internal JSITracing - OSS HermesInstance will use existed OSS JSITracing The newly created internal HermesInstance will be located in existed internal Hermes folder which was created for the Bridge. **Is there a better way to solve this issue?** - I thought about including both versions of JSITracing in ReactInstance.cpp but couldn't find a way to unify the including paths for JSITracing.h inside ReactInstance.cpp Changelog: [Internal] Reviewed By: cortinico Differential Revision: D46527522 fbshipit-source-id: 7d2c14a6313e89bf5daaf668867cae31442e81b1 --- .../ReactCommon/react/bridgeless/ReactInstance.cpp | 4 ---- .../ReactCommon/react/bridgeless/hermes/HermesInstance.cpp | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/react/bridgeless/ReactInstance.cpp b/packages/react-native/ReactCommon/react/bridgeless/ReactInstance.cpp index 07edae1f8dc..4f0b96e4106 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/bridgeless/ReactInstance.cpp @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include #include @@ -321,8 +319,6 @@ void defineReactInstanceFlags( ReactInstance::JSRuntimeFlags options) noexcept { defineReadOnlyGlobal(runtime, "RN$Bridgeless", jsi::Value(true)); - jsi::addNativeTracingHooks(runtime); - if (options.isProfiling) { defineReadOnlyGlobal(runtime, "__RCTProfileIsProfiling", jsi::Value(true)); } diff --git a/packages/react-native/ReactCommon/react/bridgeless/hermes/HermesInstance.cpp b/packages/react-native/ReactCommon/react/bridgeless/hermes/HermesInstance.cpp index 6b73c1a91c4..5a2fd57c060 100644 --- a/packages/react-native/ReactCommon/react/bridgeless/hermes/HermesInstance.cpp +++ b/packages/react-native/ReactCommon/react/bridgeless/hermes/HermesInstance.cpp @@ -7,6 +7,7 @@ #include "HermesInstance.h" +#include #include #ifdef HERMES_ENABLE_DEBUGGER @@ -115,6 +116,8 @@ std::unique_ptr HermesInstance::createJSRuntime( return decoratedRuntime; #endif + jsi::addNativeTracingHooks(*hermesRuntime); + return hermesRuntime; }