From 7503721c2c27f6a701ecd1f8d520b1eeed362f9f Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 7 May 2026 15:13:36 +0100 Subject: [PATCH 1/2] Remove legacy Hermes C++ code and HERMES_V1_ENABLED compile definition Legacy Hermes support is no longer needed since 0.86 branch has been cut. This removes all dead code behind `!defined(HERMES_V1_ENABLED)` guards and the CMake infrastructure that set the HERMES_V1_ENABLED compile definition. --- .../ReactAndroid/src/main/jni/CMakeLists.txt | 2 +- .../cmake-utils/react-native-flags.cmake | 4 +- .../hermes/executor/HermesExecutorFactory.cpp | 65 +------- .../chrome/ConnectionDemux.cpp | 143 ----------------- .../inspector-modern/chrome/ConnectionDemux.h | 55 ------- .../inspector-modern/chrome/Registration.cpp | 78 --------- .../inspector-modern/chrome/Registration.h | 39 ----- .../chrome/tests/ConnectionDemuxTests.cpp | 148 ------------------ .../react/runtime/hermes/HermesInstance.cpp | 89 ----------- 9 files changed, 5 insertions(+), 618 deletions(-) delete mode 100644 packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp delete mode 100644 packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.h delete mode 100644 packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.cpp delete mode 100644 packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.h delete mode 100644 packages/react-native/ReactCommon/hermes/inspector-modern/chrome/tests/ConnectionDemuxTests.cpp diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 01742cce7f07..7fb0a1184782 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -22,7 +22,7 @@ file(TO_CMAKE_PATH "${REACT_ANDROID_DIR}" REACT_ANDROID_DIR) file(TO_CMAKE_PATH "${REACT_BUILD_DIR}" REACT_BUILD_DIR) file(TO_CMAKE_PATH "${REACT_COMMON_DIR}" REACT_COMMON_DIR) -set(HERMES_V1_ENABLED OFF CACHE BOOL "Build with support for Hermes v1") +set(HERMES_V1_ENABLED ON CACHE BOOL "Build with support for Hermes v1") # If you have ccache installed, we're going to honor it. find_program(CCACHE_FOUND ccache) diff --git a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake index b8a420af216d..160e9da55d8f 100644 --- a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake +++ b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake @@ -32,7 +32,5 @@ function(target_compile_reactnative_options target_name scope) if(ANDROID) target_compile_definitions(${target_name} ${scope} RN_SERIALIZABLE_STATE) endif() - if(HERMES_V1_ENABLED) - target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) - endif() + target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) endfunction() diff --git a/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp b/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp index d83803fc4274..23ceb3f8f58f 100644 --- a/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +++ b/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp @@ -17,11 +17,6 @@ #include -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) -#include -#include -#endif - using namespace facebook::hermes; using namespace facebook::jsi; @@ -29,43 +24,6 @@ namespace facebook::react { namespace { -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - -class HermesExecutorRuntimeAdapter - : public facebook::hermes::inspector_modern::RuntimeAdapter { - public: - HermesExecutorRuntimeAdapter( - std::shared_ptr runtime, - std::shared_ptr thread) - : runtime_(runtime), thread_(std::move(thread)) {} - - virtual ~HermesExecutorRuntimeAdapter() = default; - - HermesRuntime& getRuntime() override { - return *runtime_; - } - - void tickleJs() override { - thread_->runOnQueue( - [weakRuntime = std::weak_ptr(runtime_)]() { - auto runtime = weakRuntime.lock(); - if (!runtime) { - return; - } - jsi::Function func = - runtime->global().getPropertyAsFunction(*runtime, "__tickleJs"); - func.call(*runtime); - }); - } - - private: - std::shared_ptr runtime_; - - std::shared_ptr thread_; -}; - -#endif // defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - struct ReentrancyCheck { // This is effectively a very subtle and complex assert, so only // include it in builds which would include asserts. @@ -149,26 +107,13 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator { const std::string& debuggerName) : jsi::WithRuntimeDecorator(*runtime, reentrancyCheck_), runtime_(std::move(runtime)) { -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - enableDebugger_ = enableDebugger; - if (enableDebugger_) { - std::shared_ptr rt(runtime_, &hermesRuntime); - auto adapter = - std::make_unique(rt, jsQueue); - debugToken_ = facebook::hermes::inspector_modern::chrome::enableDebugging( - std::move(adapter), debuggerName); - } -#else + (void)hermesRuntime; (void)jsQueue; -#endif // HERMES_ENABLE_DEBUGGER + (void)enableDebugger; + (void)debuggerName; } ~DecoratedRuntime() { -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - if (enableDebugger_) { - facebook::hermes::inspector_modern::chrome::disableDebugging(debugToken_); - } -#endif // HERMES_ENABLE_DEBUGGER } private: @@ -181,10 +126,6 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator { std::shared_ptr runtime_; ReentrancyCheck reentrancyCheck_; -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - bool enableDebugger_; - facebook::hermes::inspector_modern::chrome::DebugSessionToken debugToken_; -#endif // HERMES_ENABLE_DEBUGGER }; } // namespace diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp deleted file mode 100644 index ad07660ae18c..000000000000 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "ConnectionDemux.h" - -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - -#include -#include - -#include - -#include - -namespace facebook::hermes::inspector_modern::chrome { - -using ::facebook::react::jsinspector_modern::ILocalConnection; -using ::facebook::react::jsinspector_modern::IRemoteConnection; - -namespace { - -class LocalConnection : public ILocalConnection { - public: - LocalConnection( - std::shared_ptr conn, - std::shared_ptr> inspectedContexts); - ~LocalConnection() override; - - void sendMessage(std::string message) override; - void disconnect() override; - - private: - std::shared_ptr conn_; - std::shared_ptr> inspectedContexts_; -}; - -LocalConnection::LocalConnection( - std::shared_ptr conn, - std::shared_ptr> inspectedContexts) - : conn_(conn), inspectedContexts_(std::move(inspectedContexts)) { - inspectedContexts_->insert(conn->getTitle()); -} - -LocalConnection::~LocalConnection() = default; - -void LocalConnection::sendMessage(std::string message) { - conn_->handle(std::move(message)); -} - -void LocalConnection::disconnect() { - inspectedContexts_->erase(conn_->getTitle()); - conn_->unregisterCallbacks(); -} - -} // namespace - -ConnectionDemux::ConnectionDemux( - facebook::react::jsinspector_modern::IInspector& inspector) - : globalInspector_(inspector), - inspectedContexts_(std::make_shared>()) {} - -ConnectionDemux::~ConnectionDemux() = default; - -DebugSessionToken ConnectionDemux::enableDebugging( - std::unique_ptr adapter, - const std::string& title) { - std::scoped_lock lock(mutex_); - - // TODO(#22976087): workaround for ComponentScript contexts never being - // destroyed. - // - // After a reload, the old ComponentScript VM instance stays alive. When we - // register the new CS VM instance, check for any previous CS VM (via strcmp - // of title) and remove them. - std::vector pagesToDelete; - for (auto& conn : conns_) { - if (conn.second->getTitle() == title) { - pagesToDelete.push_back(conn.first); - } - } - - for (auto pageId : pagesToDelete) { - removePage(pageId); - } - - auto waitForDebugger = - (inspectedContexts_->find(title) != inspectedContexts_->end()); - return addPage( - hermes::inspector_modern::chrome::CDPHandler::create( - std::move(adapter), title, waitForDebugger)); -} - -void ConnectionDemux::disableDebugging(DebugSessionToken session) { - std::scoped_lock lock(mutex_); - if (conns_.find(session) == conns_.end()) { - return; - } - removePage(session); -} - -int ConnectionDemux::addPage( - std::shared_ptr conn) { - auto connectFunc = [conn, this](std::unique_ptr remoteConn) - -> std::unique_ptr { - // This cannot be unique_ptr as std::function is copyable but unique_ptr - // isn't. TODO: Change the CDPHandler API to accommodate this and not - // require a copyable callback? - std::shared_ptr sharedConn = std::move(remoteConn); - if (!conn->registerCallbacks( - [sharedConn](const std::string& message) { - sharedConn->onMessage(message); - }, - [sharedConn]() { sharedConn->onDisconnect(); })) { - return nullptr; - } - - return std::make_unique(conn, inspectedContexts_); - }; - - int pageId = globalInspector_.addPage( - conn->getTitle(), "Hermes", std::move(connectFunc)); - conns_[pageId] = std::move(conn); - - return pageId; -} - -void ConnectionDemux::removePage(int pageId) { - globalInspector_.removePage(pageId); - - auto conn = conns_.at(pageId); - std::string title = conn->getTitle(); - inspectedContexts_->erase(title); - conn->unregisterCallbacks(); - conns_.erase(pageId); -} - -} // namespace facebook::hermes::inspector_modern::chrome - -#endif // defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.h b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.h deleted file mode 100644 index cc8dae74f8a4..000000000000 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace facebook::hermes::inspector_modern::chrome { - -/* - * ConnectionDemux keeps track of all debuggable Hermes runtimes (called - * "pages" in the higher-level React Native API) in this process. See - * Registration.h for documentation of the public API. - */ -class ConnectionDemux { - public: - explicit ConnectionDemux(facebook::react::jsinspector_modern::IInspector &inspector); - ~ConnectionDemux(); - - ConnectionDemux(const ConnectionDemux &) = delete; - ConnectionDemux &operator=(const ConnectionDemux &) = delete; - - DebugSessionToken enableDebugging(std::unique_ptr adapter, const std::string &title); - void disableDebugging(DebugSessionToken session); - - private: - int addPage(std::shared_ptr conn); - void removePage(int pageId); - - facebook::react::jsinspector_modern::IInspector &globalInspector_; - - std::mutex mutex_; - std::unordered_map> conns_; - std::shared_ptr> inspectedContexts_; -}; - -} // namespace facebook::hermes::inspector_modern::chrome - -#endif // defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.cpp b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.cpp deleted file mode 100644 index 3274cba4f592..000000000000 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "Registration.h" -#include "ConnectionDemux.h" - -#if defined(HERMES_ENABLE_DEBUGGER) - -#include - -#if !defined(HERMES_V1_ENABLED) - -namespace facebook::hermes::inspector_modern::chrome { -namespace { - -ConnectionDemux& demux() { - static ConnectionDemux instance{ - facebook::react::jsinspector_modern::getInspectorInstance()}; - return instance; -} - -} // namespace - -DebugSessionToken enableDebugging( - std::unique_ptr adapter, - const std::string& title) { - return demux().enableDebugging(std::move(adapter), title); -} - -void disableDebugging(DebugSessionToken session) { - demux().disableDebugging(session); -} - -} // namespace facebook::hermes::inspector_modern::chrome - -#else - -namespace facebook::hermes::inspector_modern { -class RuntimeAdapter { - // Backwards compatibility definition fallback for libraries that are compiled - // without `HERMES_V1_ENABLED` but are linked against React Native with - // `HERMES_V1_ENABLED` which doesn't provide this symbol. - public: - virtual ~RuntimeAdapter() = 0; - virtual HermesRuntime& getRuntime() = 0; - virtual void tickleJs(); -}; - -namespace chrome { - -using DebugSessionToken = int; - -DebugSessionToken enableDebugging( - std::unique_ptr, - const std::string&) { - // Backwards compatibility fallback for libraries that are compiled without - // `HERMES_V1_ENABLED` but are linked against React Native with - // `HERMES_V1_ENABLED` which doesn't provide this symbol. - return -1; -}; - -void disableDebugging(DebugSessionToken) { - // Backwards compatibility fallback for libraries that are compiled without - // `HERMES_V1_ENABLED` but are linked against React Native with - // `HERMES_V1_ENABLED` which doesn't provide this symbol. -} - -} // namespace chrome - -} // namespace facebook::hermes::inspector_modern - -#endif // !defined(HERMES_V1_ENABLED) - -#endif // defined(HERMES_ENABLE_DEBUGGER) diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.h b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.h deleted file mode 100644 index 2b60c27a6ee6..000000000000 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/Registration.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - -#include -#include - -#include -#include - -namespace facebook::hermes::inspector_modern::chrome { - -using DebugSessionToken = int; - -/* - * enableDebugging adds this runtime to the list of debuggable JS targets - * (called "pages" in the higher-level React Native API) in this process. It - * should be called before any JS runs in the runtime. The returned token - * can be used to disable debugging for this runtime. - */ -extern DebugSessionToken enableDebugging(std::unique_ptr adapter, const std::string &title); - -/* - * disableDebugging removes this runtime from the list of debuggable JS targets - * in this process. The runtime to remove is identified by the token returned - * from enableDebugging. - */ -extern void disableDebugging(DebugSessionToken session); - -} // namespace facebook::hermes::inspector_modern::chrome - -#endif // defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/tests/ConnectionDemuxTests.cpp b/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/tests/ConnectionDemuxTests.cpp deleted file mode 100644 index 0e652e207b18..000000000000 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/chrome/tests/ConnectionDemuxTests.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace facebook { -namespace hermes { -namespace inspector_modern { -namespace chrome { - -using ::facebook::react::jsinspector_modern::IInspector; -using ::facebook::react::jsinspector_modern::InspectorPageDescription; -using ::facebook::react::jsinspector_modern::IRemoteConnection; - -namespace { - -std::unordered_map makePageMap( - const std::vector& pages) { - std::unordered_map pageMap; - - for (auto& page : pages) { - pageMap[page.id] = page.title; - } - - return pageMap; -} - -void expectPages( - IInspector& inspector, - const std::unordered_map& expected) { - auto pages = makePageMap(inspector.getPages()); - EXPECT_EQ(pages, expected); -} - -class TestRemoteConnection : public IRemoteConnection { - public: - class Data { - public: - void expectDisconnected() { - std::unique_lock lock(mutex_); - cv_.wait_for( - lock, std::chrono::milliseconds(2500), [&] { return !connected_; }); - EXPECT_FALSE(connected_); - } - - void setDisconnected() { - std::scoped_lock lock(mutex_); - connected_ = false; - cv_.notify_one(); - } - - private: - std::mutex mutex_; - std::condition_variable cv_; - bool connected_{true}; - }; - - TestRemoteConnection() : data_(std::make_shared()) {} - ~TestRemoteConnection() {} - - void onMessage(std::string message) override {} - - void onDisconnect() override { - data_->setDisconnected(); - } - - std::shared_ptr getData() { - return data_; - } - - private: - std::shared_ptr data_; -}; - -}; // namespace - -TEST(ConnectionDemuxTests, TestEnableDisable) { - std::shared_ptr runtime1( - facebook::hermes::makeHermesRuntime()); - std::shared_ptr runtime2( - facebook::hermes::makeHermesRuntime()); - auto inspector = - facebook::react::jsinspector_modern::makeTestInspectorInstance(); - - ConnectionDemux demux{*inspector}; - - int id1 = demux.enableDebugging( - std::make_unique(runtime1), "page1"); - int id2 = demux.enableDebugging( - std::make_unique(runtime2), "page2"); - - expectPages(*inspector, {{id1, "page1"}, {id2, "page2"}}); - - auto remoteConn1 = std::make_unique(); - auto remoteData1 = remoteConn1->getData(); - auto localConn1 = inspector->connect(id1, std::move(remoteConn1)); - EXPECT_NE(localConn1.get(), nullptr); - - { - // If we connect to the same page id again without disconnecting, we should - // get null - auto remoteConn = std::make_unique(); - auto localConn = inspector->connect(id1, std::move(remoteConn)); - EXPECT_EQ(localConn.get(), nullptr); - } - - auto remoteConn2 = std::make_unique(); - auto remoteData2 = remoteConn2->getData(); - auto localConn2 = inspector->connect(id2, std::move(remoteConn2)); - EXPECT_NE(localConn2.get(), nullptr); - - // Disable debugging on runtime2. This should remove its page from the list - // and call onDisconnect on its remoteConn - demux.disableDebugging(id2); - expectPages(*inspector, {{id1, "page1"}}); - remoteData2->expectDisconnected(); - - // Disconnect conn1. Its page should still be in the page list and - // onDisconnect should be called. - localConn1->disconnect(); - remoteData1->expectDisconnected(); - - { - // Should still be able to reconnect after disconnecting - auto remoteConn = std::make_unique(); - auto localConn = inspector->connect(id1, std::move(remoteConn)); - EXPECT_NE(localConn.get(), nullptr); - } -} - -} // namespace chrome -} // namespace inspector_modern -} // namespace hermes -} // namespace facebook diff --git a/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp b/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp index b308cfd42082..d843a8338aeb 100644 --- a/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp @@ -12,90 +12,11 @@ #include #include -#ifdef HERMES_ENABLE_DEBUGGER -#include - -#ifndef HERMES_V1_ENABLED -#include -#endif - -#include -#endif - using namespace facebook::hermes; using namespace facebook::jsi; namespace facebook::react { -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - -// Wrapper that strongly retains the HermesRuntime for on device debugging. -// -// HermesInstanceRuntimeAdapter needs to strongly retain the HermesRuntime. Why: -// - facebook::hermes::inspector_modern::chrome::Connection::Impl owns the -// Adapter -// - facebook::hermes::inspector_modern::chrome::Connection::Impl also owns -// jsi:: objects -// - jsi:: objects need to be deleted before the Runtime. -// -// If Adapter doesn't share ownership over jsi::Runtime, the runtime can be -// deleted before Connection::Impl cleans up all its jsi:: Objects. This will -// lead to a runtime crash. -class HermesInstanceRuntimeAdapter : public inspector_modern::RuntimeAdapter { - public: - HermesInstanceRuntimeAdapter( - std::shared_ptr hermesRuntime, - std::shared_ptr msgQueueThread) - : hermesRuntime_(std::move(hermesRuntime)), - messageQueueThread_(std::move(msgQueueThread)) {} - virtual ~HermesInstanceRuntimeAdapter() = default; - - HermesRuntime& getRuntime() override { - return *hermesRuntime_; - } - - void tickleJs() override { - std::weak_ptr weakRuntime(hermesRuntime_); - messageQueueThread_->runOnQueue([weakRuntime]() { - auto runtime = weakRuntime.lock(); - if (!runtime) { - return; - } - jsi::Function func = - runtime->global().getPropertyAsFunction(*runtime, "__tickleJs"); - func.call(*runtime); - }); - } - - private: - std::shared_ptr hermesRuntime_; - std::shared_ptr messageQueueThread_; -}; - -class DecoratedRuntime : public jsi::RuntimeDecorator { - public: - DecoratedRuntime( - std::unique_ptr runtime, - std::shared_ptr msgQueueThread) - : RuntimeDecorator(*runtime), runtime_(std::move(runtime)) { - auto adapter = std::make_unique( - runtime_, msgQueueThread); - - debugToken_ = inspector_modern::chrome::enableDebugging( - std::move(adapter), "Hermes Bridgeless React Native"); - } - - ~DecoratedRuntime() { - inspector_modern::chrome::disableDebugging(debugToken_); - } - - private: - std::shared_ptr runtime_; - inspector_modern::chrome::DebugSessionToken debugToken_; -}; - -#endif // defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - class HermesJSRuntime : public JSRuntime { public: HermesJSRuntime( @@ -164,17 +85,7 @@ std::unique_ptr HermesInstance::createJSRuntime( .getPropertyAsObject(*hermesRuntime, "prototype"); errorPrototype.setProperty(*hermesRuntime, "jsEngine", "hermes"); -#if defined(HERMES_ENABLE_DEBUGGER) && !defined(HERMES_V1_ENABLED) - auto& inspectorFlags = jsinspector_modern::InspectorFlags::getInstance(); - if (!inspectorFlags.getFuseboxEnabled()) { - std::unique_ptr decoratedRuntime = - std::make_unique( - std::move(hermesRuntime), msgQueueThread); - return std::make_unique(std::move(decoratedRuntime)); - } -#else (void)msgQueueThread; -#endif HermesRuntime& hermesRuntimeRef = *hermesRuntime; return std::make_unique( From 88909e29f2543c23a4b42f9a473f494d4c476bf8 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 7 May 2026 15:24:58 +0100 Subject: [PATCH 2/2] Remove hermesV1Enabled Gradle property and simplify Hermes version resolution Since legacy Hermes is no longer supported, remove the hermesV1Enabled toggle from the Gradle plugin, version.properties, and all build scripts. HERMES_V1_VERSION_NAME is renamed to HERMES_VERSION_NAME as the single Hermes version. CMake flags like HERMESVM_HEAP_HV_MODE are now unconditional. --- build.gradle.kts | 12 +- gradle.properties | 3 - .../kotlin/com/facebook/react/ReactPlugin.kt | 8 +- .../react/internal/PrivateReactExtension.kt | 3 - .../facebook/react/utils/DependencyUtils.kt | 23 +- .../com/facebook/react/utils/ProjectUtils.kt | 21 -- .../com/facebook/react/utils/PropertyUtils.kt | 5 - .../react/utils/DependencyUtilsTest.kt | 196 +----------------- .../facebook/react/utils/ProjectUtilsTest.kt | 27 --- .../ReactAndroid/build.gradle.kts | 7 +- .../hermes-engine/build.gradle.kts | 14 +- .../sdks/hermes-engine/version.properties | 3 +- packages/react-native/settings.gradle.kts | 2 +- private/react-native-fantom/build.gradle.kts | 8 +- 14 files changed, 25 insertions(+), 307 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0858b5cb2917..945398e88db7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -118,7 +118,7 @@ if (project.findProperty("react.internal.useHermesStable")?.toString()?.toBoolea val hermesVersionPropertiesFile = rootProject.file("./packages/react-native/sdks/hermes-engine/version.properties") hermesVersionPropertiesFile.inputStream().use { hermesVersions.load(it) } - val selectedHermesVersion = hermesVersions["HERMES_V1_VERSION_NAME"] as String + val selectedHermesVersion = hermesVersions["HERMES_VERSION_NAME"] as String hermesSubstitution = selectedHermesVersion to "Users opted to use stable hermes release" } else if ( @@ -137,15 +137,7 @@ if (project.findProperty("react.internal.useHermesStable")?.toString()?.toBoolea ) } - val hermesV1Enabled = project.findProperty("hermesV1Enabled")?.toString()?.toBoolean() ?: true - // Hermes V1 stable releases are published without the -SNAPSHOT suffix. - // Legacy nightly builds use -SNAPSHOT. - val resolvedVersion = - if (hermesV1Enabled) hermesCompilerVersion else "$hermesCompilerVersion-SNAPSHOT" - val reason = - if (hermesV1Enabled) "Users opted to use hermes V1 stable" - else "Users opted to use hermes nightly" - hermesSubstitution = resolvedVersion to reason + hermesSubstitution = hermesCompilerVersion to "Users opted to use hermes stable" } else { logger.warn( """ diff --git a/gradle.properties b/gradle.properties index d7c39175371a..4c1f11da8041 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,3 @@ react.internal.useHermesStable=false # Controls whether to use Hermes from nightly builds. This will speed up builds # but should NOT be turned on for CI or release builds. react.internal.useHermesNightly=true - -# Controls whether to use Hermes 1.0. Clean and rebuild when changing. -hermesV1Enabled=true diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index e7859ff6ad0b..bf8f28952695 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -28,7 +28,6 @@ import com.facebook.react.utils.DependencyUtils.readVersionAndGroupStrings import com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains import com.facebook.react.utils.JsonUtils import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk -import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson import com.facebook.react.utils.findPackageJsonFile import java.io.File @@ -55,10 +54,6 @@ class ReactPlugin : Plugin { project, ) - if (!project.rootProject.isHermesV1Enabled) { - rootExtension.hermesV1Enabled.set(false) - } - // App Only Configuration project.pluginManager.withPlugin("com.android.application") { // We wire the root extension with the values coming from the app (either user populated or @@ -75,8 +70,7 @@ class ReactPlugin : Plugin { File(reactNativeDir, "sdks/hermes-engine/version.properties") val versionAndGroupStrings = readVersionAndGroupStrings(project, propertiesFile, hermesVersionPropertiesFile) - val hermesV1Enabled = rootExtension.hermesV1Enabled.get() - configureDependencies(project, versionAndGroupStrings, hermesV1Enabled) + configureDependencies(project, versionAndGroupStrings) configureRepositories(project, versionAndGroupStrings.isNightly) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt index 26174c0ce0de..0c993f59c607 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt @@ -11,7 +11,6 @@ import javax.inject.Inject import org.gradle.api.Project import org.gradle.api.file.DirectoryProperty import org.gradle.api.provider.ListProperty -import org.gradle.api.provider.Property /** * A private extension we set on the rootProject to make easier to share values at execution time @@ -58,6 +57,4 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) { val codegenDir: DirectoryProperty = objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen")) - - val hermesV1Enabled: Property = objects.property(Boolean::class.java).convention(true) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index c5f42cfdb43d..f685772c7019 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -13,7 +13,6 @@ import com.facebook.react.utils.PropertyUtils.EXCLUSIVE_ENTEPRISE_REPOSITORY import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY_DEFAULT import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_PUBLISHING_GROUP -import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_V1_VERSION_NAME import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_VERSION_NAME import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_PUBLISHING_GROUP @@ -32,7 +31,6 @@ internal object DependencyUtils { internal data class Coordinates( val versionString: String, val hermesVersionString: String, - val hermesV1VersionString: String, val reactGroupString: String = DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP, val hermesGroupString: String = DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP, private val isHermesNightly: Boolean = false, @@ -114,19 +112,12 @@ internal object DependencyUtils { * party libraries which are auto-linked. Specifically it takes care of: * - Forcing the react-android/hermes-android version to the one specified in the package.json * - Substituting `react-native` with `react-android` and `hermes-engine` with `hermes-android` - * - Selecting between the classic Hermes and Hermes V1 */ fun configureDependencies( project: Project, coordinates: Coordinates, - hermesV1Enabled: Boolean = true, ) { - if ( - coordinates.versionString.isBlank() || - (!hermesV1Enabled && coordinates.hermesVersionString.isBlank()) || - (hermesV1Enabled && coordinates.hermesV1VersionString.isBlank()) - ) - return + if (coordinates.versionString.isBlank() || coordinates.hermesVersionString.isBlank()) return project.rootProject.allprojects { eachProject -> eachProject.configurations.all { configuration -> // Here we set a dependencySubstitution for both react-native and hermes-engine as those @@ -134,7 +125,7 @@ internal object DependencyUtils { // This allows users to import libraries that are still using // implementation("com.facebook.react:react-native:+") and resolve the right dependency. configuration.resolutionStrategy.dependencySubstitution { - getDependencySubstitutions(coordinates, hermesV1Enabled).forEach { (module, dest, reason) + getDependencySubstitutions(coordinates).forEach { (module, dest, reason) -> it.substitute(it.module(module)).using(it.module(dest)).because(reason) } @@ -146,7 +137,7 @@ internal object DependencyUtils { // Contributors only: The hermes-engine version is forced only if the user has // not opted into using nightlies for local development. configuration.resolutionStrategy.force( - "${coordinates.hermesGroupString}:hermes-android:${if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString}" + "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesVersionString}" ) } } @@ -155,12 +146,9 @@ internal object DependencyUtils { internal fun getDependencySubstitutions( coordinates: Coordinates, - hermesV1Enabled: Boolean = true, ): List> { val dependencySubstitution = mutableListOf>() - val hermesVersion = - if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString - val hermesVersionString = "${coordinates.hermesGroupString}:hermes-android:${hermesVersion}" + val hermesVersionString = "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesVersionString}" dependencySubstitution.add( Triple( "com.facebook.react:react-native", @@ -245,14 +233,11 @@ internal object DependencyUtils { hermesVersionString } - val hermesV1Version = - (hermesVersionProperties[INTERNAL_HERMES_V1_VERSION_NAME] as? String).orEmpty() val isHermesNightly = (project.findProperty(INTERNAL_USE_HERMES_NIGHTLY) as? String).toBoolean() return Coordinates( versionString, hermesVersion, - hermesV1Version, reactGroupString, hermesGroupString, isHermesNightly, diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt index 805b9f92dd57..02ef854b3a1e 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt @@ -13,11 +13,9 @@ import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat import com.facebook.react.utils.PropertyUtils.EDGE_TO_EDGE_ENABLED import com.facebook.react.utils.PropertyUtils.HERMES_ENABLED -import com.facebook.react.utils.PropertyUtils.HERMES_V1_ENABLED import com.facebook.react.utils.PropertyUtils.REACT_NATIVE_ARCHITECTURES import com.facebook.react.utils.PropertyUtils.SCOPED_EDGE_TO_EDGE_ENABLED import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_ENABLED -import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_V1_ENABLED import com.facebook.react.utils.PropertyUtils.SCOPED_REACT_NATIVE_ARCHITECTURES import com.facebook.react.utils.PropertyUtils.SCOPED_USE_THIRD_PARTY_JSC import com.facebook.react.utils.PropertyUtils.USE_THIRD_PARTY_JSC @@ -29,8 +27,6 @@ internal object ProjectUtils { const val HERMES_FALLBACK = true - const val HERMES_V1_ENABLED_FALLBACK = true - internal fun Project.isNewArchEnabled(): Boolean = true internal val Project.isHermesEnabled: Boolean @@ -73,23 +69,6 @@ internal object ProjectUtils { (project.hasProperty(SCOPED_USE_THIRD_PARTY_JSC) && project.property(SCOPED_USE_THIRD_PARTY_JSC).toString().toBoolean()) - internal val Project.isHermesV1Enabled: Boolean - get() = - if ( - project.hasProperty(HERMES_V1_ENABLED) || project.hasProperty(SCOPED_HERMES_V1_ENABLED) - ) { - (project.hasProperty(HERMES_V1_ENABLED) && - project.property(HERMES_V1_ENABLED).toString().toBoolean()) || - (project.hasProperty(SCOPED_HERMES_V1_ENABLED) && - project.property(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) || - (project.extraProperties.has(HERMES_V1_ENABLED) && - project.extraProperties.get(HERMES_V1_ENABLED).toString().toBoolean()) || - (project.extraProperties.has(SCOPED_HERMES_V1_ENABLED) && - project.extraProperties.get(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) - } else { - HERMES_V1_ENABLED_FALLBACK - } - internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean { val parsedPackageJson = readPackageJsonFile(this, rootProperty) return needsCodegenFromPackageJson(parsedPackageJson) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt index a52e4177fd0c..54b82fbad687 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt @@ -18,10 +18,6 @@ object PropertyUtils { const val HERMES_ENABLED = "hermesEnabled" const val SCOPED_HERMES_ENABLED = "react.hermesEnabled" - /** Public property that toggles Hermes V1 */ - const val HERMES_V1_ENABLED = "hermesV1Enabled" - const val SCOPED_HERMES_V1_ENABLED = "react.hermesV1Enabled" - /** Public property that toggles edge-to-edge */ const val EDGE_TO_EDGE_ENABLED = "edgeToEdgeEnabled" const val SCOPED_EDGE_TO_EDGE_ENABLED = "react.edgeToEdgeEnabled" @@ -92,5 +88,4 @@ object PropertyUtils { * are stored in sdks/hermes-engine/version.properties */ const val INTERNAL_HERMES_VERSION_NAME = "HERMES_VERSION_NAME" - const val INTERNAL_HERMES_V1_VERSION_NAME = "HERMES_V1_VERSION_NAME" } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index 0454b5ece333..5c57bb296fa4 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -291,97 +291,48 @@ class DependencyUtilsTest { fun configureDependencies_withEmptyVersion_doesNothing() { val project = createProject() - configureDependencies(project, DependencyUtils.Coordinates("", "", "")) + configureDependencies(project, DependencyUtils.Coordinates("", "")) assertThat(project.configurations.first().resolutionStrategy.forcedModules.isEmpty()).isTrue() } @Test - fun configureDependencies_withVersionString_appliesResolutionStrategy_withClassicHermes() { + fun configureDependencies_withVersionString_appliesResolutionStrategy() { val project = createProject() - configureDependencies(project, DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9")) + configureDependencies(project, DependencyUtils.Coordinates("1.2.3", "4.5.6")) val forcedModules = project.configurations.first().resolutionStrategy.forcedModules assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) - .isFalse() - assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() } @Test - fun configureDependencies_withVersionString_appliesResolutionStrategy_withHermesV1() { - val project = createProject() - - configureDependencies( - project, - DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"), - hermesV1Enabled = true, - ) - - val forcedModules = project.configurations.first().resolutionStrategy.forcedModules - assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) - .isTrue() - assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) - .isTrue() - } - - @Test - fun configureDependencies_withVersionString_appliesOnAllProjects_withClassicHermes() { + fun configureDependencies_withVersionString_appliesOnAllProjects() { val rootProject = ProjectBuilder.builder().build() val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() appProject.plugins.apply("com.android.application") libProject.plugins.apply("com.android.library") - configureDependencies(appProject, DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9")) + configureDependencies(appProject, DependencyUtils.Coordinates("1.2.3", "4.5.6")) val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) - .isFalse() - assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) - .isFalse() - assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) - .isTrue() - } - - @Test - fun configureDependencies_withVersionString_appliesOnAllProjects_withHermesV1() { - val rootProject = ProjectBuilder.builder().build() - val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() - val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() - appProject.plugins.apply("com.android.application") - libProject.plugins.apply("com.android.library") - - configureDependencies( - appProject, - DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"), - hermesV1Enabled = true, - ) - - val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules - val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules - assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) - .isTrue() - assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) - .isTrue() - assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) - .isTrue() - assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() } @Test - fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects_withClassicHermes() { + fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects() { val rootProject = ProjectBuilder.builder().build() val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() @@ -393,7 +344,6 @@ class DependencyUtilsTest { DependencyUtils.Coordinates( "1.2.3", "4.5.6", - "7.8.9", "io.github.test", "io.github.test.hermes", ), @@ -406,63 +356,19 @@ class DependencyUtilsTest { assertThat( appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } ) - .isFalse() - assertThat( - appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } - ) .isTrue() assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) .isTrue() assertThat( libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } ) - .isFalse() - assertThat( - libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } - ) - .isTrue() - } - - @Test - fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects_withHermesV1() { - val rootProject = ProjectBuilder.builder().build() - val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() - val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() - appProject.plugins.apply("com.android.application") - libProject.plugins.apply("com.android.library") - - configureDependencies( - appProject, - DependencyUtils.Coordinates( - "1.2.3", - "4.5.6", - "7.8.9", - "io.github.test", - "io.github.test.hermes", - ), - hermesV1Enabled = true, - ) - - val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules - val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules - assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) - .isTrue() - assertThat( - appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } - ) - .isTrue() - assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) - .isTrue() - assertThat( - libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } - ) .isTrue() } @Test - fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withHermesV1() { + fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly() { val dependencySubstitutions = - getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0")) + getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0")) assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) assertThat("com.facebook.react:react-android:0.42.0") @@ -472,7 +378,7 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("com.facebook.hermes:hermes-android:0.43.0") + assertThat("com.facebook.hermes:hermes-android:0.42.0") .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." @@ -481,85 +387,17 @@ class DependencyUtilsTest { } @Test - fun getDependencySubstitutions_withDefaultGroupAndFallback_substitutesCorrectly_withClassicHermes() { - val dependencySubstitutions = - getDependencySubstitutions( - DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0"), - hermesV1Enabled = true, - ) - - assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) - assertThat("com.facebook.react:react-android:0.42.0") - .isEqualTo(dependencySubstitutions[0].second) - assertThat( - "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[0].third) - assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("com.facebook.hermes:hermes-android:0.43.0") - .isEqualTo(dependencySubstitutions[1].second) - assertThat( - "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[1].third) - } - - @Test - fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withHermesV1() { + fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly() { val dependencySubstitutions = getDependencySubstitutions( DependencyUtils.Coordinates( "0.42.0", "0.42.0", - "0.43.0", "io.github.test", "io.github.test.hermes", ) ) - assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) - assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second) - assertThat( - "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[0].third) - assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("io.github.test.hermes:hermes-android:0.43.0") - .isEqualTo(dependencySubstitutions[1].second) - assertThat( - "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[1].third) - assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first) - assertThat("io.github.test.hermes:hermes-android:0.43.0") - .isEqualTo(dependencySubstitutions[2].second) - assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.") - .isEqualTo(dependencySubstitutions[2].third) - assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[3].first) - assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[3].second) - assertThat("The react-android dependency was modified to use the correct Maven group.") - .isEqualTo(dependencySubstitutions[3].third) - assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first) - assertThat("io.github.test.hermes:hermes-android:0.43.0") - .isEqualTo(dependencySubstitutions[4].second) - assertThat("The hermes-android dependency was modified to use the correct Maven group.") - .isEqualTo(dependencySubstitutions[4].third) - } - - @Test - fun getDependencySubstitutions_withCustomGroupAndFallbackToClassicHermes_substitutesCorrectly_withClassicHermes() { - val dependencySubstitutions = - getDependencySubstitutions( - DependencyUtils.Coordinates( - "0.42.0", - "0.42.0", - "0.43.0", - "io.github.test", - "io.github.test.hermes", - ), - hermesV1Enabled = false, - ) - assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second) assertThat( @@ -607,7 +445,6 @@ class DependencyUtilsTest { writeText( """ HERMES_VERSION_NAME=1000.0.0 - HERMES_V1_VERSION_NAME=1000.0.0 ANOTHER_PROPERTY=true """ .trimIndent() @@ -618,11 +455,9 @@ class DependencyUtilsTest { val strings = readVersionAndGroupStrings(project, propertiesFile, hermesVersionFile) val versionString = strings.versionString val hermesVersionString = strings.hermesVersionString - val hermesV1VersionString = strings.hermesV1VersionString assertThat(versionString).isEqualTo("1000.0.0") assertThat(hermesVersionString).isEqualTo("1000.0.0") - assertThat(hermesV1VersionString).isEqualTo("1000.0.0") } @Test @@ -633,7 +468,6 @@ class DependencyUtilsTest { """ VERSION_NAME=0.0.0-20221101-2019-cfe811ab1 HERMES_VERSION_NAME=0.12.0-commitly-20221101-2019-cfe811ab1 - HERMES_V1_VERSION_NAME=250829098.0.0-stable ANOTHER_PROPERTY=true """ .trimIndent() @@ -645,7 +479,6 @@ class DependencyUtilsTest { writeText( """ HERMES_VERSION_NAME=0.14.0 - HERMES_V1_VERSION_NAME=250829098.0.0-stable ANOTHER_PROPERTY=true """ .trimIndent() @@ -656,11 +489,9 @@ class DependencyUtilsTest { val strings = readVersionAndGroupStrings(project, propertiesFile, hermesVersionFile) val versionString = strings.versionString val hermesVersionString = strings.hermesVersionString - val hermesV1VersionString = strings.hermesV1VersionString assertThat(versionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT") assertThat(hermesVersionString).isEqualTo("0.14.0") - assertThat(hermesV1VersionString).isEqualTo("250829098.0.0-stable") } @Test @@ -689,10 +520,8 @@ class DependencyUtilsTest { val strings = readVersionAndGroupStrings(project, propertiesFile, hermesVersionFile) val versionString = strings.versionString val hermesVersionString = strings.hermesVersionString - val hermesV1VersionString = strings.hermesV1VersionString assertThat(versionString).isEqualTo("") assertThat(hermesVersionString).isEqualTo("") - assertThat(hermesV1VersionString).isEqualTo("") } @Test @@ -713,7 +542,6 @@ class DependencyUtilsTest { writeText( """ HERMES_VERSION_NAME= - HERMES_V1_VERSION_NAME= ANOTHER_PROPERTY=true """ .trimIndent() @@ -724,10 +552,8 @@ class DependencyUtilsTest { val strings = readVersionAndGroupStrings(project, propertiesFile, hermesVersionFile) val versionString = strings.versionString val hermesVersionString = strings.hermesVersionString - val hermesV1VersionString = strings.hermesV1VersionString assertThat(versionString).isEqualTo("") assertThat(hermesVersionString).isEqualTo("") - assertThat(hermesV1VersionString).isEqualTo("") } @Test @@ -749,7 +575,6 @@ class DependencyUtilsTest { writeText( """ HERMES_VERSION_NAME= - HERMES_V1_VERSION_NAME= ANOTHER_PROPERTY=true """ .trimIndent() @@ -782,7 +607,6 @@ class DependencyUtilsTest { writeText( """ HERMES_VERSION_NAME= - HERMES_V1_VERSION_NAME= ANOTHER_PROPERTY=true """ .trimIndent() diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt index f4ec2a40acf7..54a3016e9616 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt @@ -14,7 +14,6 @@ import com.facebook.react.tests.createProject import com.facebook.react.utils.ProjectUtils.getReactNativeArchitectures import com.facebook.react.utils.ProjectUtils.isEdgeToEdgeEnabled import com.facebook.react.utils.ProjectUtils.isHermesEnabled -import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled import com.facebook.react.utils.ProjectUtils.isNewArchEnabled import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson import java.io.File @@ -116,32 +115,6 @@ class ProjectUtilsTest { assertThat(project.isEdgeToEdgeEnabled).isFalse() } - @Test - fun isHermesV1Enabled_returnsTrueByDefault() { - assertThat(createProject().isHermesV1Enabled).isTrue() - } - - @Test - fun isHermesV1Enabled_withDisabledViaProperty_returnsFalse() { - val project = createProject() - project.extensions.extraProperties.set("hermesV1Enabled", "false") - assertThat(project.isHermesV1Enabled).isFalse() - } - - @Test - fun isHermesV1Enabled_withEnabledViaProperty_returnsTrue() { - val project = createProject() - project.extensions.extraProperties.set("hermesV1Enabled", "true") - assertThat(project.isHermesV1Enabled).isTrue() - } - - @Test - fun isHermesV1Enabled_withInvalidViaProperty_returnsFalse() { - val project = createProject() - project.extensions.extraProperties.set("hermesV1Enabled", "¯\\_(ツ)_/¯") - assertThat(project.isHermesV1Enabled).isFalse() - } - @Test fun needsCodegenFromPackageJson_withCodegenConfigInPackageJson_returnsTrue() { val project = createProject() diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 99e05410f8c1..304b5343e60a 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -39,9 +39,6 @@ val downloadsDir = val thirdPartyNdkDir = File("$buildDir/third-party-ndk") val reactNativeRootDir = projectDir.parent -val hermesV1Enabled = - rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get() - // We put the publishing version from gradle.properties inside ext. so other // subprojects can access it as well. extra["publishing_version"] = project.findProperty("VERSION_NAME")?.toString()!! @@ -583,9 +580,7 @@ android { "-DCMAKE_POLICY_DEFAULT_CMP0069=NEW", ) - if (hermesV1Enabled) { - arguments("-DHERMES_V1_ENABLED=1") - } + arguments("-DHERMES_V1_ENABLED=1") targets( "reactnative", diff --git a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts index faf4e4f9d1ff..18731ccdfec9 100644 --- a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts +++ b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts @@ -50,8 +50,6 @@ fun getSDKManagerPath(): String { } } -val hermesV1Enabled = - rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get() val reactNativeRootDir = project(":packages:react-native:ReactAndroid").projectDir.parent val customDownloadDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR") val downloadsDir = @@ -82,11 +80,11 @@ val hermesBuildOutputFileTree = .include("**/*.cmake", "**/*.marks", "**/compiler_depends.ts", "**/Makefile", "**/link.txt") val hermesVersionProvider: Provider = providers.provider { - var hermesVersion = if (hermesV1Enabled) "250829098.0.0-stable" else "main" + var hermesVersion = "250829098.0.0-stable" val hermesVersionFile = File( reactNativeRootDir, - if (hermesV1Enabled) "sdks/.hermesv1version" else "sdks/.hermesversion", + "sdks/.hermesversion", ) if (hermesVersionFile.exists()) { @@ -172,9 +170,7 @@ fun configureBuildForHermesCommandLineArgs( if (Os.isFamily(Os.FAMILY_WINDOWS)) { cmakeCommandLine = cmakeCommandLine + "-GNMake Makefiles" } - if (hermesV1Enabled) { - cmakeCommandLine = cmakeCommandLine + "-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32" - } + cmakeCommandLine = cmakeCommandLine + "-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32" return cmakeCommandLine } @@ -358,9 +354,7 @@ android { "-DHERMES_ENABLE_INTL=True", ) - if (hermesV1Enabled) { - arguments("-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32") - } + arguments("-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32") targets("hermesvm") } diff --git a/packages/react-native/sdks/hermes-engine/version.properties b/packages/react-native/sdks/hermes-engine/version.properties index e5d8f2e9a530..a71f2edb838a 100644 --- a/packages/react-native/sdks/hermes-engine/version.properties +++ b/packages/react-native/sdks/hermes-engine/version.properties @@ -1,2 +1 @@ -HERMES_VERSION_NAME=1000.0.0 -HERMES_V1_VERSION_NAME=250829098.0.12 +HERMES_VERSION_NAME=250829098.0.12 diff --git a/packages/react-native/settings.gradle.kts b/packages/react-native/settings.gradle.kts index 62527f0149f2..7da5cf675c32 100644 --- a/packages/react-native/settings.gradle.kts +++ b/packages/react-native/settings.gradle.kts @@ -45,7 +45,7 @@ project(":packages:react-native").projectDir = file("/tmp") // and apply relevant properties to the :react-native project. buildscript { val properties = java.util.Properties() - val propertiesToInherit = listOf("hermesV1Enabled", "react.hermesV1Enabled") + val propertiesToInherit = emptyList() // We cannot assume that the node_modules are next to the android project, for example // in monorepos, they might get hoisted. diff --git a/private/react-native-fantom/build.gradle.kts b/private/react-native-fantom/build.gradle.kts index 55d6a92d9dff..f23992c64692 100644 --- a/private/react-native-fantom/build.gradle.kts +++ b/private/react-native-fantom/build.gradle.kts @@ -6,7 +6,6 @@ */ import com.android.build.gradle.internal.tasks.factory.dependsOn -import com.facebook.react.internal.PrivateReactExtension import com.facebook.react.tasks.internal.* import com.facebook.react.tasks.internal.utils.* import de.undercouch.gradle.tasks.download.Download @@ -16,9 +15,6 @@ plugins { alias(libs.plugins.download) } -val hermesV1Enabled = - rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get() - // This is the version of CMake we're requesting to the Android SDK to use. // If missing it will be downloaded automatically. Only CMake versions shipped with the // Android SDK are supported (you can find them listed in the SDK Manager of Android Studio). @@ -203,9 +199,7 @@ val configureFantomTester by "-DRN_ENABLE_DEBUG_STRING_CONVERTIBLE=ON", ) - if (hermesV1Enabled) { - cmdArgs.add("-DHERMES_V1_ENABLED=1") - } + cmdArgs.add("-DHERMES_V1_ENABLED=1") commandLine(cmdArgs) standardOutputFile.set(project.file("$buildDir/reports/configure-fantom_tester.log"))