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: D14026379

fbshipit-source-id: 2dbe93ab32b611fae942468e7812b78afeaf34fc
This commit is contained in:
David Vacca 2019-02-11 14:45:02 -08:00 committed by Facebook Github Bot
parent c6c5a173bc
commit 17e1694076
1 changed files with 4 additions and 0 deletions

View File

@ -191,6 +191,10 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
@DoNotStrip
private void preallocateView(final int rootTag, final String componentName) {
if (UiThreadUtil.isOnUiThread()) {
// There is no reason to allocate views ahead of time on the main thread.
return;
}
synchronized (mPreMountItemsLock) {
ThemedReactContext context =
Assertions.assertNotNull(mReactContextForRootTag.get(rootTag));