ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
@DoNotStrip
  @SuppressWarnings("unused")
  @AnyThread
  @ThreadConfined(ANY)
  private void scheduleMountItem(
      @NonNull final MountItem mountItem,
      int commitNumber,
      long commitStartTime,
      long diffStartTime,
      long diffEndTime,
      long layoutStartTime,
      long layoutEndTime,
      long finishTransactionStartTime,
      long finishTransactionEndTime) {
    // TODO T31905686: support multithreading
    // When Binding.cpp calls scheduleMountItems during a commit phase, it always calls with
    // a BatchMountItem. No other sites call into this with a BatchMountItem, and Binding.cpp only
    // calls scheduleMountItems with a BatchMountItem.
    boolean isBatchMountItem = mountItem instanceof BatchMountItem;

    if (isBatchMountItem) {
      mCommitStartTime = commitStartTime;
      mLayoutTime = layoutEndTime - layoutStartTime;
      mFinishTransactionCPPTime = finishTransactionEndTime - finishTransactionStartTime;
      mFinishTransactionTime = SystemClock.uptimeMillis() - finishTransactionStartTime;
      mDispatchViewUpdatesTime = SystemClock.uptimeMillis();
    }

    synchronized (mMountItemsLock) {
      mMountItems.add(mountItem);
    }

    if (UiThreadUtil.isOnUiThread()) {
      // We only read these flags on the UI thread.
      boolean immediateExecutionEnabled =
          !ReactFeatureFlags.allowDisablingImmediateExecutionOfScheduleMountItems
              || mImmediatelyExecutedMountItemsOnUI;
      if (immediateExecutionEnabled) {
        try {
          dispatchMountItems();
        } finally {
          mInDispatch = false;
        }
      }
    }

    // Post markers outside of lock and after sync mounting finishes its execution
    if (isBatchMountItem) {
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_COMMIT_START, null, commitNumber, commitStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_FINISH_TRANSACTION_START,
          null,
          commitNumber,
          finishTransactionStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_FINISH_TRANSACTION_END,
          null,
          commitNumber,
          finishTransactionEndTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_DIFF_START, null, commitNumber, diffStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_DIFF_END, null, commitNumber, diffEndTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_LAYOUT_START, null, commitNumber, layoutStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_LAYOUT_END, null, commitNumber, layoutEndTime);
      ReactMarker.logFabricMarker(ReactMarkerConstants.FABRIC_COMMIT_END, null, commitNumber);
    }
  }
/**
   * This method enqueues UI operations directly to the UI thread. This might change in the future
   * to enforce execution order using {@link ReactChoreographer#CallbackType}.
   */
This method enqueues UI operations directly to the UI thread. This might change in the future
to enforce execution order using  ReactChoreographer#CallbackType.
This method enqueues UI operations directly to the UI thread . This might change in the future to enforce execution order using ReactChoreographer#CallbackType .
@DoNotStrip
  @SuppressWarnings("unused")
  @AnyThread
  @ThreadConfined(ANY)
  private void scheduleMountItem(
      @NonNull final MountItem mountItem,
      int commitNumber,
      long commitStartTime,
      long diffStartTime,
      long diffEndTime,
      long layoutStartTime,
      long layoutEndTime,
      long finishTransactionStartTime,
      long finishTransactionEndTime) {
    boolean isBatchMountItem = mountItem instanceof BatchMountItem;
    if (isBatchMountItem) {
      mCommitStartTime = commitStartTime;
      mLayoutTime = layoutEndTime - layoutStartTime;
      mFinishTransactionCPPTime = finishTransactionEndTime - finishTransactionStartTime;
      mFinishTransactionTime = SystemClock.uptimeMillis() - finishTransactionStartTime;
      mDispatchViewUpdatesTime = SystemClock.uptimeMillis();
    }
    synchronized (mMountItemsLock) {
      mMountItems.add(mountItem);
    }
    if (UiThreadUtil.isOnUiThread()) {
      boolean immediateExecutionEnabled =
          !ReactFeatureFlags.allowDisablingImmediateExecutionOfScheduleMountItems
              || mImmediatelyExecutedMountItemsOnUI;
      if (immediateExecutionEnabled) {
        try {
          dispatchMountItems();
        } finally {
          mInDispatch = false;
        }
      }
    }
    if (isBatchMountItem) {
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_COMMIT_START, null, commitNumber, commitStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_FINISH_TRANSACTION_START,
          null,
          commitNumber,
          finishTransactionStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_FINISH_TRANSACTION_END,
          null,
          commitNumber,
          finishTransactionEndTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_DIFF_START, null, commitNumber, diffStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_DIFF_END, null, commitNumber, diffEndTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_LAYOUT_START, null, commitNumber, layoutStartTime);
      ReactMarker.logFabricMarker(
          ReactMarkerConstants.FABRIC_LAYOUT_END, null, commitNumber, layoutEndTime);
      ReactMarker.logFabricMarker(ReactMarkerConstants.FABRIC_COMMIT_END, null, commitNumber);
    }
  }
@ DoNotStrip @ SuppressWarnings ( "unused" ) @ AnyThread @ ThreadConfined ( ANY ) private void scheduleMountItem ( @ NonNull final MountItem mountItem , int commitNumber , long commitStartTime , long diffStartTime , long diffEndTime , long layoutStartTime , long layoutEndTime , long finishTransactionStartTime , long finishTransactionEndTime ) { boolean isBatchMountItem = mountItem instanceof BatchMountItem ; if ( isBatchMountItem ) { mCommitStartTime = commitStartTime ; mLayoutTime = layoutEndTime - layoutStartTime ; mFinishTransactionCPPTime = finishTransactionEndTime - finishTransactionStartTime ; mFinishTransactionTime = SystemClock . uptimeMillis ( ) - finishTransactionStartTime ; mDispatchViewUpdatesTime = SystemClock . uptimeMillis ( ) ; } synchronized ( mMountItemsLock ) { mMountItems . add ( mountItem ) ; } if ( UiThreadUtil . isOnUiThread ( ) ) { boolean immediateExecutionEnabled = ! ReactFeatureFlags . allowDisablingImmediateExecutionOfScheduleMountItems || mImmediatelyExecutedMountItemsOnUI ; if ( immediateExecutionEnabled ) { try { dispatchMountItems ( ) ; } finally { mInDispatch = false ; } } } if ( isBatchMountItem ) { ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_COMMIT_START , null , commitNumber , commitStartTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_FINISH_TRANSACTION_START , null , commitNumber , finishTransactionStartTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_FINISH_TRANSACTION_END , null , commitNumber , finishTransactionEndTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_DIFF_START , null , commitNumber , diffStartTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_DIFF_END , null , commitNumber , diffEndTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_LAYOUT_START , null , commitNumber , layoutStartTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_LAYOUT_END , null , commitNumber , layoutEndTime ) ; ReactMarker . logFabricMarker ( ReactMarkerConstants . FABRIC_COMMIT_END , null , commitNumber ) ; } }
This method enqueues UI operations directly to the UI thread.
This method enqueues UI operations directly to the UI thread .
// TODO T31905686: support multithreading // When Binding.cpp calls scheduleMountItems during a commit phase, it always calls with // a BatchMountItem. No other sites call into this with a BatchMountItem, and Binding.cpp only // calls scheduleMountItems with a BatchMountItem. // We only read these flags on the UI thread. // Post markers outside of lock and after sync mounting finishes its execution