From 529c24ad92a667f3a76fb99ad4fb0e2d5074fd00 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Wed, 26 Mar 2025 22:14:50 -0700 Subject: [PATCH] Fixing Fabric Interop layer bug defaulting to UnstableLegacyViewManagerAutomaticComponentDescriptor irrespective of feature flag (#50186) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50186 When `useFabricInterop` is disabled, deleting component descriptors in Component Registry is failing since https://github.com/facebook/react-native/pull/47321 removed the Fabric Interop check from the ComponentDescriptorRegistry.cpp which was added earlier in https://github.com/facebook/react-native/pull/42294 Adding back the logic of Fallback component descriptor and error for the same. **Changelog:** [General][Fixed] Fixing Fabric Interop layer bug defaulting to UnstableLegacyViewManagerAutomaticComponentDescriptor irrespective of feature flags. **Facebook:** Upon deleting component descriptors in [CatalystRegistry](https://www.internalfb.com/code/fbsource/fbandroid/java/com/facebook/fbreact/fabric/components/jni/CatalystRegistry.cpp) D71426627 & [TwilightRegistry](https://www.internalfb.com/code/fbsource/fbandroid/java/com/oculus/twilight/crossapp/reactpackage/fabric/components/jni/TwilightRegistry.cpp) D71206103 the apps weren't erroring or causing crash as expected even upon disabling `useFabricInterop` and this was because D65192744 removed the Fabric Interop check from the ComponentDescriptorRegistry.cpp which was added earlier in D52663244 Reviewed By: cipolleschi Differential Revision: D71582553 fbshipit-source-id: 0e87a789e5f0f8acba1958f74f9552dba1fe95c0 --- .../ComponentDescriptorRegistry.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index 3c5487b240d..e8b4616f62e 100644 --- a/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -10,6 +10,7 @@ #include "componentNameByReactViewName.h" #include +#include #include #include #include @@ -83,11 +84,21 @@ const ComponentDescriptor& ComponentDescriptorRegistry::at( } if (it == _registryByName.end()) { - auto componentDescriptor = std::make_shared< - const UnstableLegacyViewManagerAutomaticComponentDescriptor>( - parameters_, unifiedComponentName); - registerComponentDescriptor(componentDescriptor); - return *_registryByName.find(unifiedComponentName)->second; + if (ReactNativeFeatureFlags::useFabricInterop()) { + auto componentDescriptor = std::make_shared< + const UnstableLegacyViewManagerAutomaticComponentDescriptor>( + parameters_, unifiedComponentName); + registerComponentDescriptor(componentDescriptor); + return *_registryByName.find(unifiedComponentName)->second; + } else { + if (_fallbackComponentDescriptor == nullptr) { + throw std::invalid_argument( + ("Unable to find componentDescriptor for " + unifiedComponentName) + .c_str()); + } else { + return *_fallbackComponentDescriptor.get(); + } + } } return *it->second;