Make sure shadow node that we set JSResponder to mounts to a View
Summary: When setJSResponder() is called on a shadow node that doesn't mount to a View, React runtime will crash in NativeViewHierarchyManager because it will fail to find a corresponding View. To fix the issue, make sure we forceMountToView() before we call enqueueSetJSResponder(). Reviewed By: ahmedre Differential Revision: D2779523
This commit is contained in:
parent
12023b7953
commit
f6b4dc68de
|
@ -355,6 +355,25 @@ public class FlatUIImplementation extends UIImplementation {
|
|||
mStateBuilder.applyUpdates(eventDispatcher, rootNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJSResponder(int possiblyVirtualReactTag, boolean blockNativeResponder) {
|
||||
ReactShadowNode node = resolveShadowNode(possiblyVirtualReactTag);
|
||||
while (node.isVirtual()) {
|
||||
node = node.getParent();
|
||||
}
|
||||
|
||||
FlatShadowNode nonVirtualNode = (FlatShadowNode) node;
|
||||
int nonVirtualTag = nonVirtualNode.getReactTag();
|
||||
nonVirtualNode.forceMountToView();
|
||||
mStateBuilder.ensureBackingViewIsCreated(nonVirtualNode, nonVirtualTag, null);
|
||||
|
||||
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
|
||||
operationsQueue.enqueueSetJSResponder(
|
||||
nonVirtualTag,
|
||||
possiblyVirtualReactTag,
|
||||
blockNativeResponder);
|
||||
}
|
||||
|
||||
private static @Nullable ReactImageManager findReactImageManager(List<ViewManager> viewManagers) {
|
||||
for (int i = 0, size = viewManagers.size(); i != size; ++i) {
|
||||
if (viewManagers.get(i) instanceof ReactImageManager) {
|
||||
|
|
|
@ -52,6 +52,10 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
|||
mOperationsQueue = operationsQueue;
|
||||
}
|
||||
|
||||
/* package */ FlatUIViewOperationQueue getOperationsQueue() {
|
||||
return mOperationsQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a root of the laid-out shadow node hierarchy, walks the tree and generates an array of
|
||||
* DrawCommands that will then mount in UI thread to a root FlatViewGroup so that it can draw.
|
||||
|
|
Loading…
Reference in New Issue