Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,18 @@ - (RCTComponentViewClassDescriptor)_componentViewClassDescriptorFromClass:(Class

- (BOOL)_wasComponentRegistered:(const std::string &)name
{
std::shared_lock lock(_mutex);
auto registrationResult = _registrationStatusMap.find(name);
return registrationResult != _registrationStatusMap.end() && (registrationResult->second);
}

- (void)_registerComponentIfPossible:(const std::string &)name
{
if (_registrationStatusMap.find(name) != _registrationStatusMap.end()) {
return;
{
std::shared_lock lock(_mutex);
if (_registrationStatusMap.find(name) != _registrationStatusMap.end()) {
return;
}
}

// Fallback 1: Call provider function for component view class.
Expand Down Expand Up @@ -177,9 +181,13 @@ - (void)_registerComponentIfPossible:(const std::string &)name
auto provider = ComponentDescriptorProvider{
.handle = componentHandle, .name = componentName, .flavor = flavor, .constructor = constructor};

// Only the map writes take the lock: building a legacy interop descriptor can wait on the
// main queue (a view manager that requires main queue setup), which may itself be waiting
// for this lock in -createComponentViewWithComponentHandle:.
_providerRegistry.add(provider);
_componentViewClasses[componentHandle] =
[self _componentViewClassDescriptorFromClass:[RCTLegacyViewManagerInteropComponentView class]];
auto classDescriptor = [self _componentViewClassDescriptorFromClass:[RCTLegacyViewManagerInteropComponentView class]];
std::unique_lock lock(_mutex);
_componentViewClasses[componentHandle] = classDescriptor;
_registrationStatusMap.insert({provider.name, true});
return;
}
Expand All @@ -194,8 +202,9 @@ - (void)_registerComponentIfPossible:(const std::string &)name
.handle = componentHandle, .name = componentName, .flavor = flavor, .constructor = constructor};

_providerRegistry.add(provider);
_componentViewClasses[componentHandle] =
[self _componentViewClassDescriptorFromClass:[RCTUnimplementedViewComponentView class]];
auto classDescriptor = [self _componentViewClassDescriptorFromClass:[RCTUnimplementedViewComponentView class]];
std::unique_lock lock(_mutex);
_componentViewClasses[componentHandle] = classDescriptor;
_registrationStatusMap.insert({provider.name, false});
}

Expand Down