Fabric: Fixed threading issues in RCTSurfacePresenter

Summary: RCTComponentViewRegistry is not a thread-safe class and must be accessed only from the main thread.

Reviewed By: JoshuaGross

Differential Revision: D15296475

fbshipit-source-id: 67192abd6290191f3b8119972efc41cec48a793a
This commit is contained in:
Valentin Shergin
2019-05-10 15:31:00 -07:00
committed by Facebook Github Bot
parent 55db1d05fb
commit 9e3856fd99
+13 -7
View File
@@ -250,8 +250,11 @@ using namespace facebook::react;
- (void)_startSurface:(RCTFabricSurface *)surface
{
[_mountingManager.componentViewRegistry dequeueComponentViewWithComponentHandle:RootShadowNode::Handle()
tag:surface.rootTag];
RCTMountingManager *mountingManager = _mountingManager;
RCTExecuteOnMainQueue(^{
[mountingManager.componentViewRegistry dequeueComponentViewWithComponentHandle:RootShadowNode::Handle()
tag:surface.rootTag];
});
LayoutContext layoutContext = {
.pointScaleFactor = RCTScreenScale()
@@ -273,11 +276,14 @@ using namespace facebook::react;
{
[self._scheduler stopSurfaceWithSurfaceId:surface.rootTag];
UIView<RCTComponentViewProtocol> *rootView =
[_mountingManager.componentViewRegistry componentViewByTag:surface.rootTag];
[_mountingManager.componentViewRegistry enqueueComponentViewWithComponentHandle:RootShadowNode::Handle()
tag:surface.rootTag
componentView:rootView];
RCTMountingManager *mountingManager = _mountingManager;
RCTExecuteOnMainQueue(^{
UIView<RCTComponentViewProtocol> *rootView =
[mountingManager.componentViewRegistry componentViewByTag:surface.rootTag];
[mountingManager.componentViewRegistry enqueueComponentViewWithComponentHandle:RootShadowNode::Handle()
tag:surface.rootTag
componentView:rootView];
});
[surface _unsetStage:(RCTSurfaceStagePrepared | RCTSurfaceStageMounted)];
}