Avoid RCTUnsafeExecuteOnMainQueueSync from RCTUIManager

These calls are only needed for a temporary Fabric workaround and would result in a deadlock since we also call `RCTUnsafeExecuteOnUIManagerQueueSync` from the main thread during window resize.

This is needed for now in Fabric only to call the temporary `componentViewName_DO_NOT_USE_THIS_IS_BROKEN` workaround on views, which we don't have on desktop since we're a way off from using Fabric (and hopefully this workaround will be gone then).

It was originally added here ffc7ec992c

At Meta we have disabled these lines since May 2021 to fix crashes in production.
This commit is contained in:
Scott Kyle 2021-05-06 17:22:29 -07:00 коммит произвёл Christoph Purrer
Родитель 84c08634ea
Коммит 371ef593de
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -354,6 +354,8 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
return name; return name;
} }
// Re-enable componentViewName_DO_NOT_USE_THIS_IS_BROKEN once macOS uses Fabric
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
__block RCTPlatformView *view; // TODO(macOS GH#774) __block RCTPlatformView *view; // TODO(macOS GH#774)
RCTUnsafeExecuteOnMainQueueSync(^{ RCTUnsafeExecuteOnMainQueueSync(^{
view = self->_viewRegistry[reactTag]; view = self->_viewRegistry[reactTag];
@ -367,6 +369,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
} }
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif // ]TODO(macOS GH#774)
return nil; return nil;
} }
@ -1135,6 +1138,8 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand
RCTShadowView *shadowView = _shadowViewRegistry[reactTag]; RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
RCTComponentData *componentData = _componentDataByName[shadowView.viewName]; RCTComponentData *componentData = _componentDataByName[shadowView.viewName];
// Re-enable componentViewName_DO_NOT_USE_THIS_IS_BROKEN once macOS uses Fabric
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
// Achtung! Achtung! // Achtung! Achtung!
// This is a remarkably hacky and ugly workaround. // This is a remarkably hacky and ugly workaround.
// We need this only temporary for some testing. We need this hack until Fabric fully implements command-execution // We need this only temporary for some testing. We need this hack until Fabric fully implements command-execution
@ -1152,6 +1157,7 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand
} }
} }
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif // ]TODO(macOS GH#774)
Class managerClass = componentData.managerClass; Class managerClass = componentData.managerClass;
RCTModuleData *moduleData = [_bridge moduleDataForName:RCTBridgeModuleNameForClass(managerClass)]; RCTModuleData *moduleData = [_bridge moduleDataForName:RCTBridgeModuleNameForClass(managerClass)];