Skip to content

Commit 7de3dbe

Browse files
mdvaccameta-codesync[bot]
authored andcommitted
Stub UIViewOperationQueue and remove its usages (facebook#55658)
Summary: Pull Request resolved: facebook#55658 UIViewOperationQueue is part of the Legacy Architecture and is no longer needed. This change stubs out all methods in the class (making them no-ops) and removes all call sites that invoked those methods across the codebase. Specifically: - UIViewOperationQueue: All method bodies replaced with empty stubs, all inner classes removed, all fields removed. The public API signatures are preserved for backward compatibility. - UIImplementation: All calls to mOperationsQueue.enqueue*, dispatchViewUpdates, resumeFrameCallback, pauseFrameCallback, etc. removed. Layout update listener is now called directly instead of through the queue. - UIManagerModule: resolveView() now returns null instead of chaining through the operation queue. - ReactShadowNodeImpl: dispatchUpdates() no longer calls enqueueUpdateLayout on the operation queue. - ARTSurfaceViewShadowNode: Deleted the onCollectExtraUpdates override that called enqueueUpdateExtraData. Reviewed By: NickGerleman Differential Revision: D93069524 fbshipit-source-id: 110f5002ee7c19eb9d778080ee821b7992f405a7
1 parent 4e7b19a commit 7de3dbe

5 files changed

Lines changed: 60 additions & 1066 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -385,27 +385,10 @@ public void dispatchUpdates(
385385
int newScreenWidth = newAbsoluteRight - newAbsoluteLeft;
386386
int newScreenHeight = newAbsoluteBottom - newAbsoluteTop;
387387

388-
boolean layoutHasChanged =
389-
newScreenX != mScreenX
390-
|| newScreenY != mScreenY
391-
|| newScreenWidth != mScreenWidth
392-
|| newScreenHeight != mScreenHeight;
393-
394388
mScreenX = newScreenX;
395389
mScreenY = newScreenY;
396390
mScreenWidth = newScreenWidth;
397391
mScreenHeight = newScreenHeight;
398-
399-
if (layoutHasChanged && getParent() != null) {
400-
uiViewOperationQueue.enqueueUpdateLayout(
401-
getParent().getReactTag(),
402-
getReactTag(),
403-
getScreenX(),
404-
getScreenY(),
405-
getScreenWidth(),
406-
getScreenHeight(),
407-
getLayoutDirection());
408-
}
409392
}
410393
}
411394

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java

Lines changed: 18 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package com.facebook.react.uimanager;
99

10-
import android.os.SystemClock;
1110
import android.view.View;
1211
import android.view.View.MeasureSpec;
1312
import androidx.annotation.Nullable;
@@ -33,6 +32,7 @@
3332
import com.facebook.yoga.YogaDirection;
3433
import java.util.ArrayList;
3534
import java.util.Arrays;
35+
import java.util.HashMap;
3636
import java.util.List;
3737
import java.util.Map;
3838

@@ -58,7 +58,6 @@ public class UIImplementation {
5858
private final UIViewOperationQueue mOperationsQueue;
5959
private final int[] mMeasureBuffer = new int[4];
6060

61-
private long mLastCalculateLayoutTime = 0;
6261
protected @Nullable LayoutUpdateListener mLayoutUpdateListener;
6362

6463
/**
@@ -167,16 +166,12 @@ public void run() {
167166
mShadowNodeRegistry.addRootNode(rootCSSNode);
168167
}
169168
});
170-
171-
// register it within NativeViewHierarchyManager
172-
mOperationsQueue.addRootView(tag, rootView);
173169
}
174170
}
175171

176172
/** Unregisters a root node with a given tag. */
177173
public void removeRootView(int rootViewTag) {
178174
removeRootShadowNode(rootViewTag);
179-
mOperationsQueue.enqueueRemoveRootView(rootViewTag);
180175
}
181176

182177
/**
@@ -185,7 +180,7 @@ public void removeRootView(int rootViewTag) {
185180
* @return The num of root view
186181
*/
187182
public int getRootViewNum() {
188-
return mOperationsQueue.getNativeViewHierarchyManager().getRootViewNum();
183+
return 0;
189184
}
190185

191186
/** Unregisters a root node with a given tag from the shadow node registry */
@@ -238,12 +233,10 @@ public void setViewLocalData(int tag, Object data) {
238233
dispatchViewUpdatesIfNeeded();
239234
}
240235

241-
public void profileNextBatch() {
242-
mOperationsQueue.profileNextBatch();
243-
}
236+
public void profileNextBatch() {}
244237

245238
public Map<String, Long> getProfiledBatchPerfCounters() {
246-
return mOperationsQueue.getProfiledBatchPerfCounters();
239+
return new HashMap<>();
247240
}
248241

249242
/** Invoked by React to create a new node with a given tag, class name and properties. */
@@ -274,12 +267,7 @@ public void createView(int tag, String className, int rootViewTag, ReadableMap p
274267
}
275268

276269
protected void handleCreateView(
277-
ReactShadowNode cssNode, int rootViewTag, @Nullable ReactStylesDiffMap styles) {
278-
if (!cssNode.isVirtual()) {
279-
mOperationsQueue.enqueueCreateView(
280-
cssNode.getThemedContext(), cssNode.getReactTag(), cssNode.getViewClass(), styles);
281-
}
282-
}
270+
ReactShadowNode cssNode, int rootViewTag, @Nullable ReactStylesDiffMap styles) {}
283271

284272
/** Invoked by React to create a new node with a given tag has its properties changed. */
285273
public void updateView(int tag, String className, ReadableMap props) {
@@ -311,15 +299,10 @@ public void updateView(int tag, String className, ReadableMap props) {
311299
*/
312300
public void synchronouslyUpdateViewOnUIThread(int tag, ReactStylesDiffMap props) {
313301
UiThreadUtil.assertOnUiThread();
314-
mOperationsQueue.getNativeViewHierarchyManager().updateProperties(tag, props);
315302
}
316303

317304
protected void handleUpdateView(
318-
ReactShadowNode cssNode, String className, ReactStylesDiffMap styles) {
319-
if (!cssNode.isVirtual()) {
320-
mOperationsQueue.enqueueUpdateProperties(cssNode.getReactTag(), className, styles);
321-
}
322-
}
305+
ReactShadowNode cssNode, String className, ReactStylesDiffMap styles) {}
323306

324307
/**
325308
* Invoked when there is a mutation in a node tree.
@@ -434,9 +417,6 @@ public void manageChildren(
434417
cssNodeToManage.addChildAt(cssNodeToAdd, viewAtIndex.mIndex);
435418
}
436419

437-
mOperationsQueue.enqueueManageChildren(
438-
cssNodeToManage.getReactTag(), indicesToRemove, viewsToAdd, tagsToDelete);
439-
440420
for (int i = 0; i < tagsToDelete.length; i++) {
441421
removeShadowNode(mShadowNodeRegistry.getNode(tagsToDelete[i]));
442422
}
@@ -470,8 +450,6 @@ public void setChildren(int viewTag, ReadableArray childrenTags) {
470450
}
471451
cssNodeToManage.addChildAt(cssNodeToAdd, i);
472452
}
473-
474-
mOperationsQueue.enqueueSetChildren(cssNodeToManage.getReactTag(), childrenTags);
475453
}
476454
}
477455

@@ -522,9 +500,7 @@ public void replaceExistingNonRootView(int oldTag, int newTag) {
522500
* @param callback will be called if with the identified child view react ID, and measurement
523501
* info. If no view was found, callback will be invoked with no data.
524502
*/
525-
public void findSubviewIn(int reactTag, float targetX, float targetY, Callback callback) {
526-
mOperationsQueue.enqueueFindTargetForTouch(reactTag, targetX, targetY, callback);
527-
}
503+
public void findSubviewIn(int reactTag, float targetX, float targetY, Callback callback) {}
528504

529505
/**
530506
* Check if the first shadow node is the descendant of the second shadow node
@@ -551,12 +527,6 @@ public void measure(int reactTag, Callback callback) {
551527
if (!mViewOperationsEnabled) {
552528
return;
553529
}
554-
555-
// This method is called by the implementation of JS touchable interface (see Touchable.js for
556-
// more details) at the moment of touch activation. That is after user starts the gesture from
557-
// a touchable view with a given reactTag, or when user drag finger back into the press
558-
// activation area of a touchable view that have been activated before.
559-
mOperationsQueue.enqueueMeasure(reactTag, callback);
560530
}
561531

562532
/**
@@ -568,8 +538,6 @@ public void measureInWindow(int reactTag, Callback callback) {
568538
if (!mViewOperationsEnabled) {
569539
return;
570540
}
571-
572-
mOperationsQueue.enqueueMeasureInWindow(reactTag, callback);
573541
}
574542

575543
/**
@@ -622,24 +590,15 @@ public void dispatchViewUpdates(int batchId) {
622590
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "UIImplementation.dispatchViewUpdates")
623591
.arg("batchId", batchId)
624592
.flush();
625-
final long commitStartTime = SystemClock.uptimeMillis();
626593
try {
627594
updateViewHierarchy();
628-
mOperationsQueue.dispatchViewUpdates(batchId, commitStartTime, mLastCalculateLayoutTime);
629595
} finally {
630596
Systrace.endSection(Systrace.TRACE_TAG_REACT);
631597
}
632598
}
633599

634600
private void dispatchViewUpdatesIfNeeded() {
635-
// If we are in the middle of a batch update, any additional changes
636-
// will automatically be dispatched at the end of the batch.
637-
// If we are not, we have to initiate new batch update.
638-
// As all batches are executed as a single runnable on the event queue
639-
// this should always be empty, but that calling architecture is an implementation detail.
640-
if (mOperationsQueue.isEmpty()) {
641-
dispatchViewUpdates(-1); // "-1" means "no associated batch id"
642-
}
601+
dispatchViewUpdates(-1);
643602
}
644603

645604
protected void updateViewHierarchy() {
@@ -684,8 +643,8 @@ protected void updateViewHierarchy() {
684643
Systrace.endSection(Systrace.TRACE_TAG_REACT);
685644
}
686645

687-
if (mLayoutUpdateListener != null) {
688-
mOperationsQueue.enqueueLayoutUpdateFinished(cssRoot, mLayoutUpdateListener);
646+
if (mLayoutUpdateListener != null && cssRoot != null) {
647+
mLayoutUpdateListener.onLayoutUpdated(cssRoot);
689648
}
690649
}
691650
}
@@ -705,9 +664,7 @@ protected void updateViewHierarchy() {
705664
*
706665
* @param enabled whether layout animation is enabled or not
707666
*/
708-
public void setLayoutAnimationEnabledExperimental(boolean enabled) {
709-
mOperationsQueue.enqueueSetLayoutAnimationEnabled(enabled);
710-
}
667+
public void setLayoutAnimationEnabledExperimental(boolean enabled) {}
711668

712669
/**
713670
* Configure an animation to be used for the native layout changes, and native views creation. The
@@ -721,26 +678,17 @@ public void setLayoutAnimationEnabledExperimental(boolean enabled) {
721678
* interrupted. In this case, callback parameter will be false.
722679
* @param error will be called if there was an error processing the animation
723680
*/
724-
public void configureNextLayoutAnimation(ReadableMap config, Callback success) {
725-
mOperationsQueue.enqueueConfigureLayoutAnimation(config, success);
726-
}
681+
public void configureNextLayoutAnimation(ReadableMap config, Callback success) {}
727682

728683
public void setJSResponder(int reactTag, boolean blockNativeResponder) {
729684
ReactShadowNode node = mShadowNodeRegistry.getNode(reactTag);
730685

731686
if (node == null) {
732-
// TODO: this should only happen when using Fabric renderer. This is a temporary approach
733-
// and it will be refactored when fabric supports JS Responder.
734687
return;
735688
}
736-
737-
// While loop removed due to NativeKind removal
738-
mOperationsQueue.enqueueSetJSResponder(node.getReactTag(), reactTag, blockNativeResponder);
739689
}
740690

741-
public void clearJSResponder() {
742-
mOperationsQueue.enqueueClearJSResponder();
743-
}
691+
public void clearJSResponder() {}
744692

745693
@Deprecated
746694
public void dispatchViewManagerCommand(
@@ -750,8 +698,6 @@ public void dispatchViewManagerCommand(
750698
if (!viewExists) {
751699
return;
752700
}
753-
754-
mOperationsQueue.enqueueDispatchCommand(reactTag, commandId, commandArgs);
755701
}
756702

757703
public void dispatchViewManagerCommand(
@@ -761,21 +707,13 @@ public void dispatchViewManagerCommand(
761707
if (!viewExists) {
762708
return;
763709
}
764-
765-
mOperationsQueue.enqueueDispatchCommand(reactTag, commandId, commandArgs);
766710
}
767711

768-
public void sendAccessibilityEvent(int tag, int eventType) {
769-
mOperationsQueue.enqueueSendAccessibilityEvent(tag, eventType);
770-
}
712+
public void sendAccessibilityEvent(int tag, int eventType) {}
771713

772-
public void onHostResume() {
773-
mOperationsQueue.resumeFrameCallback();
774-
}
714+
public void onHostResume() {}
775715

776-
public void onHostPause() {
777-
mOperationsQueue.pauseFrameCallback();
778-
}
716+
public void onHostPause() {}
779717

780718
public void onHostDestroy() {}
781719

@@ -918,7 +856,6 @@ protected void calculateRootLayout(ReactShadowNode cssRoot) {
918856
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "cssRoot.calculateLayout")
919857
.arg("rootTag", cssRoot.getReactTag())
920858
.flush();
921-
long startTime = SystemClock.uptimeMillis();
922859
try {
923860
int widthSpec = cssRoot.getWidthMeasureSpec();
924861
int heightSpec = cssRoot.getHeightMeasureSpec();
@@ -931,7 +868,6 @@ protected void calculateRootLayout(ReactShadowNode cssRoot) {
931868
: MeasureSpec.getSize(heightSpec));
932869
} finally {
933870
Systrace.endSection(Systrace.TRACE_TAG_REACT);
934-
mLastCalculateLayoutTime = SystemClock.uptimeMillis() - startTime;
935871
}
936872
}
937873

@@ -966,13 +902,9 @@ protected void applyUpdatesRecursive(
966902
cssNode.markUpdateSeen();
967903
}
968904

969-
public void addUIBlock(UIBlock block) {
970-
mOperationsQueue.enqueueUIBlock(block);
971-
}
905+
public void addUIBlock(UIBlock block) {}
972906

973-
public void prependUIBlock(UIBlock block) {
974-
mOperationsQueue.prependUIBlock(block);
975-
}
907+
public void prependUIBlock(UIBlock block) {}
976908

977909
public int resolveRootTagFromReactTag(int reactTag) {
978910
if (mShadowNodeRegistry.isRootNode(reactTag)) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,9 @@ public void onLowMemory() {}
778778
}
779779

780780
@Override
781-
public View resolveView(int tag) {
781+
public @Nullable View resolveView(int tag) {
782782
UiThreadUtil.assertOnUiThread();
783-
return mUIImplementation
784-
.getUIViewOperationQueue()
785-
.getNativeViewHierarchyManager()
786-
.resolveView(tag);
783+
return null;
787784
}
788785

789786
@Override

0 commit comments

Comments
 (0)