From b90c1cf6c30454859579278be18ac650c66f516b Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 20 Feb 2018 22:11:51 -0800 Subject: [PATCH] RCTSurface: Optional sync ShadowView/View registing Summary: See the comment in code. If we on the main thread on registering time, we can/will break sequentiality of registering and mounting processes doing registration asynchronously. We need this to make sync mouting eventually possible. Reviewed By: fkgozali Differential Revision: D7014176 fbshipit-source-id: 110ad5e5d86e3422eac15c3b1bdb29ae04acd7e6 --- React/Base/Surface/RCTSurface.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/React/Base/Surface/RCTSurface.mm b/React/Base/Surface/RCTSurface.mm index 80d04b363..f217c66b5 100644 --- a/React/Base/Surface/RCTSurface.mm +++ b/React/Base/Surface/RCTSurface.mm @@ -321,7 +321,9 @@ RCTUIManager *uiManager = batchedBridge.uiManager; - RCTExecuteOnUIManagerQueue(^{ + // If we are on the main queue now, we have to proceed synchronously. + // Otherwise, we cannot perform synchronous waiting for some stages later. + (RCTIsMainQueue() ? RCTUnsafeExecuteOnUIManagerQueueSync : RCTExecuteOnUIManagerQueue)(^{ [uiManager registerRootViewTag:self->_rootViewTag]; RCTSurfaceRootShadowView *rootShadowView =