@@ -91,10 +91,9 @@ void ComponentDescriptorRegistry::add(
9191 _registryByName[componentDescriptorProvider.name ] = sharedComponentDescriptor;
9292}
9393
94+ // Callers must hold the mutex
9495void ComponentDescriptorRegistry::registerComponentDescriptor (
9596 const SharedComponentDescriptor& componentDescriptor) const {
96- std::unique_lock lock (mutex_);
97-
9897 ComponentHandle componentHandle = componentDescriptor->getComponentHandle ();
9998 _registryByHandle[componentHandle] = componentDescriptor;
10099
@@ -128,12 +127,15 @@ const ComponentDescriptor& ComponentDescriptorRegistry::at(
128127
129128 if (it == _registryByName.end ()) {
130129 if (ReactNativeFeatureFlags::useFabricInterop ()) {
130+ lock.unlock ();
131131 // When interop is enabled, if the component is not found we rely on
132132 // UnstableLegacyViewManagerAutomaticComponentDescriptor to support legacy
133133 // components in new architecture.
134134 auto componentDescriptor = std::make_shared<
135135 const UnstableLegacyViewManagerAutomaticComponentDescriptor>(
136136 parameters_, unifiedComponentName);
137+
138+ std::unique_lock writeLock (mutex_);
137139 registerComponentDescriptor (componentDescriptor);
138140 return *_registryByName.find (unifiedComponentName)->second ;
139141 } else {
@@ -186,6 +188,7 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt(
186188
187189void ComponentDescriptorRegistry::setFallbackComponentDescriptor (
188190 const SharedComponentDescriptor& descriptor) {
191+ std::unique_lock lock (mutex_);
189192 _fallbackComponentDescriptor = descriptor;
190193 registerComponentDescriptor (descriptor);
191194}
0 commit comments