Back out "[Fabric][C++][Android] update props during pre allocation of views"

Summary:
This is a back-out of D14214844, we noticed that this regressed TTI for Marketplace You screen running in Fabric

Original commit changeset: b81005f2bf49

Reviewed By: JoshuaGross

Differential Revision: D14247897

fbshipit-source-id: de0cea92b437b2fbcd075f0d6a0066156800e3f0
This commit is contained in:
David Vacca
2019-02-28 00:04:09 -08:00
committed by Facebook Github Bot
parent 60c0a60c50
commit b3790d283f
8 changed files with 24 additions and 41 deletions
@@ -188,7 +188,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
}
@DoNotStrip
private void preallocateView(int rootTag, int reactTag, final String componentName, ReadableMap props) {
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;
@@ -198,7 +198,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
Assertions.assertNotNull(mReactContextForRootTag.get(rootTag));
String component = sComponentNames.get(componentName);
Assertions.assertNotNull(component);
mPreMountItems.add(new PreAllocateViewMountItem(context, rootTag, reactTag, component, props));
mPreMountItems.add(new PreAllocateViewMountItem(context, rootTag, component));
}
}
@@ -461,24 +461,16 @@ void Binding::setPixelDensity(float pointScaleFactor) {
void Binding::schedulerDidRequestPreliminaryViewAllocation(
const SurfaceId surfaceId,
const ComponentName componentName,
bool isLayoutable,
const ShadowView &shadowView) {
const ComponentHandle componentHandle) {
if (isLayoutable) {
static auto preallocateView =
jni::findClassStatic(UIManagerJavaDescriptor)
->getMethod<void(jint, jint, jstring, ReadableMap::javaobject)>("preallocateView");
->getMethod<void(jint, jstring)>("preallocateView");
// TODO: T31905686 Experiment to check what is the impact on TTI of pre loading of Images during
// pre-allocation of views
if (shadowView.componentName == "Image") {
local_ref<ReadableMap::javaobject> readableMap =
castReadableMap(ReadableNativeMap::newObjectCxxArgs(shadowView.props->rawProps));
preallocateView(
javaUIManager_, surfaceId, shadowView.tag, make_jstring(shadowView.componentName).get(), readableMap.get());
} else {
preallocateView(
javaUIManager_, surfaceId, shadowView.tag, make_jstring(shadowView.componentName).get(), nullptr);
}
preallocateView(
javaUIManager_, surfaceId, make_jstring(componentName).get());
}
}
@@ -64,8 +64,9 @@ class Binding : public jni::HybridClass<Binding>, public SchedulerDelegate {
void schedulerDidRequestPreliminaryViewAllocation(
const SurfaceId surfaceId,
const ComponentName componentName,
bool isLayoutable,
const ShadowView &shadowView);
const ComponentHandle componentHandle);
void setPixelDensity(float pointScaleFactor);
@@ -172,10 +172,6 @@ public class MountingManager {
UiThreadUtil.assertOnUiThread();
View view = null;
ViewManager viewManager = null;
// This can be possible if the view was already pre-allocated
if (mTagToViewState.get(reactTag) != null) return;
if (!isVirtual) {
viewManager = mViewManagerRegistry.get(componentName);
view = mViewPool.getOrCreateView(componentName, themedReactContext);
@@ -275,15 +271,8 @@ public class MountingManager {
}
@UiThread
public void preallocateView(
ThemedReactContext reactContext,
String componentName,
int reactTag,
ReadableMap props) {
createView(reactContext, componentName, reactTag, false);
if (props != null) {
updateProps(reactTag, props);
}
public void preallocateView(ThemedReactContext reactContext, String componentName) {
mViewPool.createView(reactContext, componentName);
}
@UiThread
@@ -6,7 +6,6 @@
*/
package com.facebook.react.fabric.mounting.mountitems;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.uimanager.ThemedReactContext;
@@ -17,21 +16,17 @@ public class PreAllocateViewMountItem implements MountItem {
private final String mComponent;
private final int mRootTag;
private final int mReactTag;
private final ReadableMap mProps;
private final ThemedReactContext mContext;
public PreAllocateViewMountItem(ThemedReactContext context, int rootTag, int reactTag, String component, ReadableMap props){
public PreAllocateViewMountItem(ThemedReactContext context, int rootTag, String component){
mContext = context;
mComponent = component;
mRootTag = rootTag;
mProps = props;
mReactTag = reactTag;
}
@Override
public void execute(MountingManager mountingManager) {
mountingManager.preallocateView(mContext, mComponent, mReactTag, mProps);
mountingManager.preallocateView(mContext, mComponent);
}
@Override