Backout D2677289 [react_native] View recycling in JS

Summary: public

We're seeing related crashes. The diff has no tests, the perf tests weren't conclusive, and the person who'd be supporting it no longer is available to work on it. We can try this again later in a less rushed manner with proper perf testing.

Reviewed By: davidaurelio

Differential Revision: D2696615

fb-gh-sync-id: 3b6814ac12af19516146d5c42d2add8321b10db5
This commit is contained in:
Andy Street
2015-11-26 08:36:02 -08:00
committed by facebook-github-bot-0
parent bb11e05c33
commit a636ddd9f0
12 changed files with 27 additions and 345 deletions

View File

@@ -351,7 +351,7 @@ import com.facebook.react.touch.JSResponderHandler;
viewsToAdd,
tagsToDelete));
}
detachView(viewToDestroy);
dropView(viewToDestroy);
}
}
}
@@ -380,15 +380,10 @@ import com.facebook.react.touch.JSResponderHandler;
view.setId(tag);
}
public void dropView(int tag) {
mTagsToViews.remove(tag);
mTagsToViewManagers.remove(tag);
}
/**
* Releases all references to given native View.
*/
private void detachView(View view) {
private void dropView(View view) {
UiThreadUtil.assertOnUiThread();
if (!mRootTags.get(view.getId())) {
// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
@@ -403,11 +398,13 @@ import com.facebook.react.touch.JSResponderHandler;
for (int i = viewGroupManager.getChildCount(viewGroup) - 1; i >= 0; i--) {
View child = viewGroupManager.getChildAt(viewGroup, i);
if (mTagsToViews.get(child.getId()) != null) {
detachView(child);
dropView(child);
}
}
viewGroupManager.removeAllViews(viewGroup);
}
mTagsToViews.remove(view.getId());
mTagsToViewManagers.remove(view.getId());
}
public void removeRootView(int rootViewTag) {
@@ -417,7 +414,7 @@ import com.facebook.react.touch.JSResponderHandler;
"View with tag " + rootViewTag + " is not registered as a root view");
}
View rootView = mTagsToViews.get(rootViewTag);
detachView(rootView);
dropView(rootView);
mRootTags.delete(rootViewTag);
mRootViewsContext.remove(rootViewTag);
}

View File

@@ -90,10 +90,6 @@ public class NativeViewHierarchyOptimizer {
}
}
public void handleDropViews(int[] viewTagsToDrop, int length) {
mUIViewOperationQueue.enqueueDropViews(viewTagsToDrop, length);
}
/**
* Handles native children cleanup when css node is removed from hierarchy
*/

View File

@@ -124,22 +124,6 @@ public class UIImplementation {
}
}
public void dropViews(ReadableArray viewTags) {
int size = viewTags.size(), realViewsCount = 0;
int realViewTags[] = new int[size];
for (int i = 0; i < size; i++) {
int tag = viewTags.getInt(i);
ReactShadowNode cssNode = mShadowNodeRegistry.getNode(tag);
if (!cssNode.isVirtual()) {
realViewTags[realViewsCount++] = tag;
}
mShadowNodeRegistry.removeNode(tag);
}
if (realViewsCount > 0) {
mNativeViewHierarchyOptimizer.handleDropViews(realViewTags, realViewsCount);
}
}
/**
* Invoked by React to create a new node with a given tag has its properties changed.
*/
@@ -509,6 +493,7 @@ public class UIImplementation {
private void removeShadowNode(ReactShadowNode nodeToRemove) {
mNativeViewHierarchyOptimizer.handleRemoveNode(nodeToRemove);
mShadowNodeRegistry.removeNode(nodeToRemove.getReactTag());
for (int i = nodeToRemove.getChildCount() - 1; i >= 0; i--) {
removeShadowNode(nodeToRemove.getChildAt(i));
}

View File

@@ -202,11 +202,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
mUIImplementation.createView(tag, className, rootViewTag, props);
}
@ReactMethod
public void dropViews(ReadableArray viewTags) {
mUIImplementation.dropViews(viewTags);
}
@ReactMethod
public void updateView(int tag, String className, ReadableMap props) {
mUIImplementation.updateView(tag, className, props);

View File

@@ -154,12 +154,4 @@ import com.facebook.react.uimanager.events.TouchEventType;
return constants;
}
public static Map<String, Object> getLayoutOnlyPropsConstants() {
HashMap<String, Object> constants = new HashMap<>();
for (String propName : ViewProps.LAYOUT_ONLY_PROPS) {
constants.put(propName, Boolean.TRUE);
}
return constants;
}
}

View File

@@ -25,7 +25,6 @@ import com.facebook.react.common.MapBuilder;
private static final String CUSTOM_BUBBLING_EVENT_TYPES_KEY = "customBubblingEventTypes";
private static final String CUSTOM_DIRECT_EVENT_TYPES_KEY = "customDirectEventTypes";
private static final String LAYOUT_ONLY_PROPS = "layoutOnlyProps";
/**
* Generates map of constants that is then exposed by {@link UIManagerModule}. The constants map
@@ -76,7 +75,6 @@ import com.facebook.react.common.MapBuilder;
constants.put(CUSTOM_BUBBLING_EVENT_TYPES_KEY, bubblingEventTypesConstants);
constants.put(CUSTOM_DIRECT_EVENT_TYPES_KEY, directEventTypesConstants);
constants.put(LAYOUT_ONLY_PROPS, UIManagerModuleConstants.getLayoutOnlyPropsConstants());
return constants;
}

View File

@@ -147,25 +147,6 @@ public class UIViewOperationQueue {
}
}
private final class DropViewsOperation extends ViewOperation {
private final int[] mViewTagsToDrop;
private final int mArrayLength;
public DropViewsOperation(int[] viewTagsToDrop, int length) {
super(-1);
mViewTagsToDrop = viewTagsToDrop;
mArrayLength = length;
}
@Override
public void execute() {
for (int i = 0; i < mArrayLength; i++) {
mNativeViewHierarchyManager.dropView(mViewTagsToDrop[i]);
}
}
}
private final class ManageChildrenOperation extends ViewOperation {
private final @Nullable int[] mIndicesToRemove;
@@ -556,10 +537,6 @@ public class UIViewOperationQueue {
initialProps));
}
public void enqueueDropViews(int[] viewTagsToDrop, int length) {
mOperations.add(new DropViewsOperation(viewTagsToDrop, length));
}
public void enqueueUpdateProperties(int reactTag, String className, CatalystStylesDiffMap props) {
mOperations.add(new UpdatePropertiesOperation(reactTag, props));
}

View File

@@ -84,7 +84,7 @@ public class ViewProps {
Spacing.BOTTOM
};
/*package*/ static final HashSet<String> LAYOUT_ONLY_PROPS = new HashSet<>(
private static final HashSet<String> LAYOUT_ONLY_PROPS = new HashSet<>(
Arrays.asList(
ALIGN_SELF,
ALIGN_ITEMS,