diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index edb6972ea2d..adc049828ad 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -7,10 +7,10 @@ #import "RCTSurfacePresenter.h" +#import +#import #import #import -#import -#import #import #import @@ -36,8 +36,8 @@ #import #import "MainRunLoopEventBeat.h" -#import "RuntimeEventBeat.h" #import "RCTConversions.h" +#import "RuntimeEventBeat.h" using namespace facebook::react; @@ -52,9 +52,10 @@ using namespace facebook::react; @implementation RCTSurfacePresenter { std::mutex _schedulerMutex; std::mutex _contextContainerMutex; - RCTScheduler *_Nullable _scheduler; // Thread-safe. Mutation of the instance variable is protected by `_schedulerMutex`. + RCTScheduler + *_Nullable _scheduler; // Thread-safe. Mutation of the instance variable is protected by `_schedulerMutex`. RCTMountingManager *_mountingManager; // Thread-safe. - RCTSurfaceRegistry *_surfaceRegistry; // Thread-safe. + RCTSurfaceRegistry *_surfaceRegistry; // Thread-safe. RCTBridge *_bridge; // Unsafe. We are moving away from Bridge. RCTBridge *_batchedBridge; std::shared_ptr _reactNativeConfig; @@ -123,8 +124,7 @@ using namespace facebook::react; [_surfaceRegistry unregisterSurface:surface]; } -- (void)setProps:(NSDictionary *)props - surface:(RCTFabricSurface *)surface +- (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface { // This implementation is suboptimal indeed but still better than nothing for now. [self _stopSurface:surface]; @@ -140,32 +140,22 @@ using namespace facebook::react; maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface { - LayoutContext layoutContext = { - .pointScaleFactor = RCTScreenScale() - }; + LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; - LayoutConstraints layoutConstraints = { - .minimumSize = RCTSizeFromCGSize(minimumSize), - .maximumSize = RCTSizeFromCGSize(maximumSize) - }; + LayoutConstraints layoutConstraints = {.minimumSize = RCTSizeFromCGSize(minimumSize), + .maximumSize = RCTSizeFromCGSize(maximumSize)}; return [self._scheduler measureSurfaceWithLayoutConstraints:layoutConstraints layoutContext:layoutContext surfaceId:surface.rootTag]; } -- (void)setMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize - surface:(RCTFabricSurface *)surface +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface { - LayoutContext layoutContext = { - .pointScaleFactor = RCTScreenScale() - }; + LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; - LayoutConstraints layoutConstraints = { - .minimumSize = RCTSizeFromCGSize(minimumSize), - .maximumSize = RCTSizeFromCGSize(maximumSize) - }; + LayoutConstraints layoutConstraints = {.minimumSize = RCTSizeFromCGSize(minimumSize), + .maximumSize = RCTSizeFromCGSize(maximumSize)}; [self._scheduler constraintSurfaceLayoutWithLayoutConstraints:layoutConstraints layoutContext:layoutContext @@ -274,14 +264,10 @@ using namespace facebook::react; tag:surface.rootTag]; }); - LayoutContext layoutContext = { - .pointScaleFactor = RCTScreenScale() - }; + LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; - LayoutConstraints layoutConstraints = { - .minimumSize = RCTSizeFromCGSize(surface.minimumSize), - .maximumSize = RCTSizeFromCGSize(surface.maximumSize) - }; + LayoutConstraints layoutConstraints = {.minimumSize = RCTSizeFromCGSize(surface.minimumSize), + .maximumSize = RCTSizeFromCGSize(surface.maximumSize)}; [self._scheduler startSurfaceWithSurfaceId:surface.rootTag moduleName:surface.moduleName diff --git a/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm b/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm index e3b4074eb24..148b95fe166 100644 --- a/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm +++ b/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm @@ -22,12 +22,14 @@ ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) self_ = (__bridge_retained void *)[[RCTImageManager alloc] initWithImageLoader:imageLoader]; } -ImageManager::~ImageManager() { +ImageManager::~ImageManager() +{ CFRelease(self_); self_ = nullptr; } -ImageRequest ImageManager::requestImage(const ImageSource &imageSource) const { +ImageRequest ImageManager::requestImage(const ImageSource &imageSource) const +{ RCTImageManager *imageManager = (__bridge RCTImageManager *)self_; return [imageManager requestImage:imageSource]; } diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index 9b78bdc649e..1029584f9fa 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -138,25 +138,24 @@ void Scheduler::renderTemplateToSurface( void Scheduler::stopSurface(SurfaceId surfaceId) const { SystraceSection s("Scheduler::stopSurface"); - shadowTreeRegistry_.visit( - surfaceId, [](const ShadowTree &shadowTree) { - // As part of stopping the Surface, we have to commit an empty tree. - return shadowTree.tryCommit( - [&](const SharedRootShadowNode &oldRootShadowNode) { - return std::make_shared( - *oldRootShadowNode, - ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .surfaceId = */ - ShadowNodeFragment::surfaceIdPlaceholder(), - /* .props = */ ShadowNodeFragment::propsPlaceholder(), - /* .eventEmitter = */ - ShadowNodeFragment::eventEmitterPlaceholder(), - /* .children = */ - ShadowNode::emptySharedShadowNodeSharedList(), - }); - }); - }); + shadowTreeRegistry_.visit(surfaceId, [](const ShadowTree &shadowTree) { + // As part of stopping the Surface, we have to commit an empty tree. + return shadowTree.tryCommit( + [&](const SharedRootShadowNode &oldRootShadowNode) { + return std::make_shared( + *oldRootShadowNode, + ShadowNodeFragment{ + /* .tag = */ ShadowNodeFragment::tagPlaceholder(), + /* .surfaceId = */ + ShadowNodeFragment::surfaceIdPlaceholder(), + /* .props = */ ShadowNodeFragment::propsPlaceholder(), + /* .eventEmitter = */ + ShadowNodeFragment::eventEmitterPlaceholder(), + /* .children = */ + ShadowNode::emptySharedShadowNodeSharedList(), + }); + }); + }); auto shadowTree = shadowTreeRegistry_.remove(surfaceId); shadowTree->setDelegate(nullptr); @@ -232,21 +231,20 @@ void Scheduler::uiManagerDidFinishTransaction( const SharedShadowNodeUnsharedList &rootChildNodes) { SystraceSection s("Scheduler::uiManagerDidFinishTransaction"); - shadowTreeRegistry_.visit( - surfaceId, [&](const ShadowTree &shadowTree) { - shadowTree.commit([&](const SharedRootShadowNode &oldRootShadowNode) { - return std::make_shared( - *oldRootShadowNode, - ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), - /* .props = */ ShadowNodeFragment::propsPlaceholder(), - /* .eventEmitter = */ - ShadowNodeFragment::eventEmitterPlaceholder(), - /* .children = */ rootChildNodes, - }); - }); - }); + shadowTreeRegistry_.visit(surfaceId, [&](const ShadowTree &shadowTree) { + shadowTree.commit([&](const SharedRootShadowNode &oldRootShadowNode) { + return std::make_shared( + *oldRootShadowNode, + ShadowNodeFragment{ + /* .tag = */ ShadowNodeFragment::tagPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .props = */ ShadowNodeFragment::propsPlaceholder(), + /* .eventEmitter = */ + ShadowNodeFragment::eventEmitterPlaceholder(), + /* .children = */ rootChildNodes, + }); + }); + }); } void Scheduler::uiManagerDidCreateShadowNode(