Skip to content

Commit 0794a8f

Browse files
ayc1facebook-github-bot
authored andcommitted
Append LayoutUpdateListener to UIViewOperationQueue
Summary: There are multiple UI thread passes during the layout process. The first is with all of the operations from React (createView, manageChildren, etc). The second is during onCollectExtraUpdates after the layout pass, when things like Text need to be precomputed before later being sent over to the views. The onLayoutUpdateListener needs to run AFTER onCollectExtraUpdates operations are executed, so this is now queued up in the UIViewOperationQueue Reviewed By: mdvacca Differential Revision: D9416260 fbshipit-source-id: d1a4eaf38a4f6c82d41def34ffb94d303e8f50d4
1 parent c00d6b1 commit 0794a8f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ protected void updateViewHierarchy() {
709709
}
710710

711711
if (mLayoutUpdateListener != null) {
712-
mLayoutUpdateListener.onLayoutUpdated(cssRoot);
712+
mOperationsQueue.enqueueLayoutUpdateFinished(cssRoot, mLayoutUpdateListener);
713713
}
714714
}
715715
}

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,22 @@ public void execute() {
556556
}
557557
}
558558

559+
private final class LayoutUpdateFinishedOperation implements UIOperation {
560+
561+
private final ReactShadowNode mNode;
562+
private final UIImplementation.LayoutUpdateListener mListener;
563+
564+
private LayoutUpdateFinishedOperation(ReactShadowNode node, UIImplementation.LayoutUpdateListener listener) {
565+
mNode = node;
566+
mListener = listener;
567+
}
568+
569+
@Override
570+
public void execute() {
571+
mListener.onLayoutUpdated(mNode);
572+
}
573+
}
574+
559575
private class UIBlockOperation implements UIOperation {
560576
private final UIBlock mBlock;
561577
public UIBlockOperation (UIBlock block) {
@@ -829,6 +845,10 @@ public void enqueueSendAccessibilityEvent(int tag, int eventType) {
829845
mOperations.add(new SendAccessibilityEvent(tag, eventType));
830846
}
831847

848+
public void enqueueLayoutUpdateFinished(ReactShadowNode node, UIImplementation.LayoutUpdateListener listener) {
849+
mOperations.add(new LayoutUpdateFinishedOperation(node, listener));
850+
}
851+
832852
public void enqueueUIBlock(UIBlock block) {
833853
mOperations.add(new UIBlockOperation(block));
834854
}

0 commit comments

Comments
 (0)