Skip to content

Commit bf58ba9

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Stop preallocation views on the main thread
Summary: There is no reason to allocate views ahead of time on the main thread. There is a chance that this view will not be mounted and we are not saving any time because it's a sequential process anyway (because we are doing it on the main thread). Moreover, the switching context can only slowdown JS execution. Reviewed By: JoshuaGross Differential Revision: D14019433 fbshipit-source-id: 83ac05a91e4b70cb382a55d6687752480984404e
1 parent 392e896 commit bf58ba9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

React/Fabric/Mounting/RCTMountingManager.mm

+5
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ - (void)_performMountItems:(NSArray<RCTMountItemProtocol> *)mountItems
178178

179179
- (void)optimisticallyCreateComponentViewWithComponentHandle:(ComponentHandle)componentHandle
180180
{
181+
if (RCTIsMainQueue()) {
182+
// There is no reason to allocate views ahead of time on the main thread.
183+
return;
184+
}
185+
181186
RCTExecuteOnMainQueue(^{
182187
[self->_componentViewRegistry optimisticallyCreateComponentViewWithComponentHandle:componentHandle];
183188
});

0 commit comments

Comments
 (0)