com.facebook.systrace.Systrace Java Examples

The following examples show how to use com.facebook.systrace.Systrace. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onProducerFinishWithSuccess(
    String requestId,
    String producerName,
    Map<String, String> extraMap) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  if (mProducerID.containsKey(requestId)) {
    Pair<Integer, String> entry = mProducerID.get(requestId);
    Systrace.endAsyncSection(
        Systrace.TRACE_TAG_REACT_FRESCO,
        entry.second,
        entry.first);
    mProducerID.remove(requestId);
  }
}
 
Example #2
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void attachRootViewToInstance(
    final ReactRootView rootView) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance");
  UIManager uiManagerModule = UIManagerHelper.getUIManager(mCurrentReactContext, rootView.getUIManagerType());
  final int rootTag = uiManagerModule.addRootView(rootView);
  rootView.setRootViewTag(rootTag);
  rootView.runApplication();
  Systrace.beginAsyncSection(
    TRACE_TAG_REACT_JAVA_BRIDGE,
    "pre_rootView.onAttachedToReactInstance",
    rootTag);
  UiThreadUtil.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      Systrace.endAsyncSection(
        TRACE_TAG_REACT_JAVA_BRIDGE,
        "pre_rootView.onAttachedToReactInstance",
        rootTag);
      rootView.onAttachedToReactInstance();
    }
  });
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example #3
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Uses configured {@link ReactPackage} instances to create all view managers.
 */
public List<ViewManager> getOrCreateViewManagers(
    ReactApplicationContext catalystApplicationContext) {
  ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers");
  try {
    if (mViewManagers == null) {
      synchronized (mPackages) {
        if (mViewManagers == null) {
          mViewManagers = new ArrayList<>();
          for (ReactPackage reactPackage : mPackages) {
            mViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext));
          }
          return mViewManagers;
        }
      }
    }
    return mViewManagers;
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END);
  }
}
 
Example #4
Source File: UIViewOperationQueue.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void doFrameGuarded(long frameTimeNanos) {
  if (mIsInIllegalUIState) {
    FLog.w(
      ReactConstants.TAG,
      "Not flushing pending UI operations because of previously thrown Exception");
    return;
  }

  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "dispatchNonBatchedUIOperations");
  try {
    dispatchPendingNonBatchedOperations(frameTimeNanos);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }

  flushPendingBatches();

  ReactChoreographer.getInstance().postFrameCallback(
    ReactChoreographer.CallbackType.DISPATCH_UI, this);
}
 
Example #5
Source File: UIImplementation.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Invoked at the end of the transaction to commit any updates to the node hierarchy.
 */
public void dispatchViewUpdates(int batchId) {
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "UIImplementation.dispatchViewUpdates")
    .arg("batchId", batchId)
    .flush();
  final long commitStartTime = SystemClock.uptimeMillis();
  try {
    updateViewHierarchy();
    mNativeViewHierarchyOptimizer.onBatchComplete();
    mOperationsQueue.dispatchViewUpdates(batchId, commitStartTime, mLastCalculateLayoutTime);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #6
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Appends the child {@link ReactShadowNode} to the children set of the parent {@link
 * ReactShadowNode}.
 */
@Nullable
@DoNotStrip
public void appendChild(ReactShadowNode parent, ReactShadowNode child) {
  if (DEBUG) {
    FLog.d(TAG, "appendChild \n\tparent: " + parent + "\n\tchild: " + child);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.appendChild")
    .flush();
  try {
    // If the child to append was already committed (child.isSealed()),
    // then we add a mutation of it. In the future this will be performed by FabricJS / Fiber.
    //TODO: T27926878 avoid cloning shared child
    if (child.isSealed()) {
      child = child.mutableCopy(child.getInstanceHandle());
    }
    parent.addChildAt(child, parent.getChildCount());
  } catch (Throwable t) {
    handleException(parent, t);
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #7
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node, but its
 *     props will be overridden with the {@link ReadableMap} received by parameter and its
 *     children set will be empty.
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewChildrenAndProps(
    ReactShadowNode node, ReadableNativeMap newProps) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNodeWithNewChildrenAndProps \n\tnode: " + node + "\n\tnewProps: " + newProps);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNodeWithNewChildrenAndProps")
    .flush();
  try {
    ReactShadowNode clone =
        node.mutableCopyWithNewChildrenAndProps(node.getInstanceHandle(),
            newProps == null ? null : new ReactStylesDiffMap(newProps));
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #8
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node, but its
 *     props will be overridden with the {@link ReadableMap} received by parameter.
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewProps(
    ReactShadowNode node, @Nullable ReadableNativeMap newProps) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNodeWithNewProps \n\tnode: " + node + "\n\tprops: " + newProps);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNodeWithNewProps")
    .flush();
  try {
    ReactShadowNode clone = node.mutableCopyWithNewProps(node.getInstanceHandle(),
          newProps == null ? null : new ReactStylesDiffMap(newProps));
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #9
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node, but its
 *     children set will be empty.
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewChildren(ReactShadowNode node) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNodeWithNewChildren \n\tnode: " + node);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNodeWithNewChildren")
    .flush();
  try {
    ReactShadowNode clone = node.mutableCopyWithNewChildren(node.getInstanceHandle());
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #10
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node,
 *     including its children set (note that the children nodes will not be cloned).
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNode(ReactShadowNode node) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNode \n\tnode: " + node);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNode")
    .flush();
  try {
    ReactShadowNode clone = node.mutableCopy(node.getInstanceHandle());
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #11
Source File: EventDispatcher.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Sends the given Event to JS, coalescing eligible events if JS is backed up.
 */
public void dispatchEvent(Event event) {
  Assertions.assertCondition(event.isInitialized(), "Dispatched event hasn't been initialized");

  for (EventDispatcherListener listener : mListeners) {
    listener.onEventDispatch(event);
  }

  synchronized (mEventsStagingLock) {
    mEventStaging.add(event);
    Systrace.startAsyncFlow(
        Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
        event.getEventName(),
        event.getUniqueID());
  }
  if (mReactEventEmitter != null) {
    // If the host activity is paused, the frame callback may not be currently
    // posted. Ensure that it is so that this event gets delivered promptly.
    mCurrentFrameCallback.maybePostFromNonUI();
  } else {
    // No JS application has started yet, or resumed. This can happen when a ReactRootView is
    // added to view hierarchy, but ReactContext creation has not completed yet. In this case, any
    // touch event dispatch will hit this codepath, and we simply queue them so that they
    // are dispatched once ReactContext creation completes and JS app is running.
  }
}
 
Example #12
Source File: NativeModuleRegistry.java    From react-native-GPay with MIT License 6 votes vote down vote up
void notifyJSInstanceInitialized() {
  mReactApplicationContext.assertOnNativeModulesQueueThread("From version React Native v0.44, " +
    "native modules are explicitly not initialized on the UI thread. See " +
    "https://github.com/facebook/react-native/wiki/Breaking-Changes#d4611211-reactnativeandroidbreaking-move-nativemodule-initialization-off-ui-thread---aaachiuuu " +
    " for more details.");
  ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_START);
  Systrace.beginSection(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      "NativeModuleRegistry_notifyJSInstanceInitialized");
  try {
    for (ModuleHolder module : mModules.values()) {
      module.markInitializable();
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_END);
  }
}
 
Example #13
Source File: EventDispatcher.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void doFrame(long frameTimeNanos) {
  UiThreadUtil.assertOnUiThread();

  if (mShouldStop) {
    mIsPosted = false;
  } else {
    post();
  }

  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ScheduleDispatchFrameCallback");
  try {
    moveStagedEventsToDispatchQueue();

    if (!mHasDispatchScheduled) {
      mHasDispatchScheduled = true;
      Systrace.startAsyncFlow(
          Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
          "ScheduleDispatchFrameCallback",
          mHasDispatchScheduledCount.get());
      mReactContext.runOnJSQueueThread(mDispatchEventsRunnable);
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #14
Source File: UIManagerModule.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * To implement the transactional requirement mentioned in the class javadoc, we only commit
 * UI changes to the actual view hierarchy once a batch of JS->Java calls have been completed.
 * We know this is safe because all JS->Java calls that are triggered by a Java->JS call (e.g.
 * the delivery of a touch event or execution of 'renderApplication') end up in a single
 * JS->Java transaction.
 *
 * A better way to do this would be to have JS explicitly signal to this module when a UI
 * transaction is done. Right now, though, this is how iOS does it, and we should probably
 * update the JS and native code and make this change at the same time.
 *
 * TODO(5279396): Make JS UI library explicitly notify the native UI module of the end of a UI
 *                transaction using a standard native call
 */
@Override
public void onBatchComplete() {
  int batchId = mBatchId;
  mBatchId++;

  SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "onBatchCompleteUI")
        .arg("BatchId", batchId)
        .flush();
  for (UIManagerModuleListener listener : mListeners) {
    listener.willDispatchViewUpdates(this);
  }
  try {
    mUIImplementation.dispatchViewUpdates(batchId);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #15
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onProducerFinishWithCancellation(
    String requestId, String producerName, Map<String, String> extraMap) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  if (mProducerID.containsKey(requestId)) {
    Pair<Integer, String> entry = mProducerID.get(requestId);
    Systrace.endAsyncSection(
        Systrace.TRACE_TAG_REACT_FRESCO,
        entry.second,
        entry.first);
    mProducerID.remove(requestId);
  }
}
 
Example #16
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onProducerFinishWithFailure(
    String requestId,
    String producerName,
    Throwable throwable,
    Map<String, String> extraMap) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  if (mProducerID.containsKey(requestId)) {
    Pair<Integer, String> entry = mProducerID.get(requestId);
    Systrace.endAsyncSection(
        Systrace.TRACE_TAG_REACT_FRESCO,
        entry.second,
        entry.first);
    mProducerID.remove(requestId);
  }
}
 
Example #17
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onProducerEvent(String requestId, String producerName, String producerEventName) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  StringBuilder entryName = new StringBuilder();
  entryName.append("FRESCO_PRODUCER_EVENT_");
  entryName.append(requestId.replace(':', '_'));
  entryName.append("_");
  entryName.append(producerName.replace(':', '_'));
  entryName.append("_");
  entryName.append(producerEventName.replace(':', '_'));
  Systrace.traceInstant(
      Systrace.TRACE_TAG_REACT_FRESCO,
      entryName.toString(),
      Systrace.EventScope.THREAD);
}
 
Example #18
Source File: UIManagerModule.java    From react-native-GPay with MIT License 6 votes vote down vote up
@ReactMethod(isBlockingSynchronousMethod = true)
public @Nullable WritableMap getConstantsForViewManager(final String viewManagerName) {
  ViewManager targetView =
      viewManagerName != null ? mUIImplementation.resolveViewManager(viewManagerName) : null;
  if (targetView == null) {
    return null;
  }

  SystraceMessage.beginSection(
          Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIManagerModule.getConstantsForViewManager")
      .arg("ViewManager", targetView.getName())
      .arg("Lazy", true)
      .flush();
  try {
    Map<String, Object> viewManagerConstants =
        UIManagerModuleConstantsHelper.createConstantsForViewManager(
            targetView, null, null, null, mCustomDirectEvents);
    if (viewManagerConstants != null) {
      return Arguments.makeNativeMap(viewManagerConstants);
    }
    return null;
  } finally {
    SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE).flush();
  }
}
 
Example #19
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onRequestStart(
    ImageRequest request,
    Object callerContext,
    String requestId,
    boolean isPrefetch) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  StringBuilder entryName = new StringBuilder();
  entryName.append("FRESCO_REQUEST_");
  entryName.append(request.getSourceUri().toString().replace(':', '_'));

  Pair<Integer,String> requestPair = Pair.create(mCurrentID, entryName.toString());
  Systrace.beginAsyncSection(
      Systrace.TRACE_TAG_REACT_FRESCO,
      requestPair.second,
      mCurrentID);
  mRequestsID.put(requestId, requestPair);
  mCurrentID++;
}
 
Example #20
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onProducerStart(String requestId, String producerName) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  StringBuilder entryName = new StringBuilder();
  entryName.append("FRESCO_PRODUCER_");
  entryName.append(producerName.replace(':', '_'));

  Pair<Integer,String> requestPair = Pair.create(mCurrentID, entryName.toString());
  Systrace.beginAsyncSection(
      Systrace.TRACE_TAG_REACT_FRESCO,
      requestPair.second,
      mCurrentID);
  mProducerID.put(requestId, requestPair);
  mCurrentID++;
}
 
Example #21
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onRequestFailure(
    ImageRequest request,
    String requestId,
    Throwable throwable,
    boolean isPrefetch) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  if (mRequestsID.containsKey(requestId)) {
    Pair<Integer, String> entry = mRequestsID.get(requestId);
    Systrace.endAsyncSection(
        Systrace.TRACE_TAG_REACT_FRESCO,
        entry.second,
        entry.first);
    mRequestsID.remove(requestId);
  }
}
 
Example #22
Source File: CatalystInstanceImpl.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void runJSBundle() {
  Log.d(ReactConstants.TAG, "CatalystInstanceImpl.runJSBundle()");
  Assertions.assertCondition(!mJSBundleHasLoaded, "JS bundle was already loaded!");
  // incrementPendingJSCalls();
  mJSBundleLoader.loadScript(CatalystInstanceImpl.this);

  synchronized (mJSCallsPendingInitLock) {

    // Loading the bundle is queued on the JS thread, but may not have
    // run yet.  It's safe to set this here, though, since any work it
    // gates will be queued on the JS thread behind the load.
    mAcceptCalls = true;

    for (PendingJSCall function : mJSCallsPendingInit) {
      function.call(this);
    }
    mJSCallsPendingInit.clear();
    mJSBundleHasLoaded = true;
  }

  // This is registered after JS starts since it makes a JS call
  Systrace.registerListener(mTraceListener);
}
 
Example #23
Source File: CatalystInstanceImpl.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void incrementPendingJSCalls() {
  int oldPendingCalls = mPendingJSCalls.getAndIncrement();
  boolean wasIdle = oldPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      oldPendingCalls + 1);
  if (wasIdle && !mBridgeIdleListeners.isEmpty()) {
    mNativeModulesQueueThread.runOnQueue(new Runnable() {
      @Override
      public void run() {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeBusy();
        }
      }
    });
  }
}
 
Example #24
Source File: CatalystInstanceImpl.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void decrementPendingJSCalls() {
  int newPendingCalls = mPendingJSCalls.decrementAndGet();
  // TODO(9604406): handle case of web workers injecting messages to main thread
  //Assertions.assertCondition(newPendingCalls >= 0);
  boolean isNowIdle = newPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      newPendingCalls);

  if (isNowIdle && !mBridgeIdleListeners.isEmpty()) {
    mNativeModulesQueueThread.runOnQueue(new Runnable() {
      @Override
      public void run() {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeIdle();
        }
      }
    });
  }
}
 
Example #25
Source File: UIImplementation.java    From react-native-GPay with MIT License 5 votes vote down vote up
protected void calculateRootLayout(ReactShadowNode cssRoot) {
  SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "cssRoot.calculateLayout")
      .arg("rootTag", cssRoot.getReactTag())
      .flush();
  long startTime = SystemClock.uptimeMillis();
  try {
    cssRoot.calculateLayout();
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    mLastCalculateLayoutTime = SystemClock.uptimeMillis() - startTime;
  }
}
 
Example #26
Source File: CoreModulesPackage.java    From react-native-GPay with MIT License 5 votes vote down vote up
private UIManagerModule createUIManager(final ReactApplicationContext reactContext) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
  try {
    if (mLazyViewManagersEnabled) {
      UIManagerModule.ViewManagerResolver resolver = new UIManagerModule.ViewManagerResolver() {
        @Override
        public @Nullable ViewManager getViewManager(String viewManagerName) {
          return mReactInstanceManager.createViewManager(viewManagerName);
        }
        @Override
        public List<String> getViewManagerNames() {
          return mReactInstanceManager.getViewManagerNames();
        }
      };

      return new UIManagerModule(
          reactContext,
          resolver,
          mMinTimeLeftInFrameForNonBatchedOperationMs);
    } else {
      return new UIManagerModule(
          reactContext,
          mReactInstanceManager.getOrCreateViewManagers(reactContext),
          mMinTimeLeftInFrameForNonBatchedOperationMs);
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
  }
}
 
Example #27
Source File: UIViewOperationQueue.java    From react-native-GPay with MIT License 5 votes vote down vote up
public CreateViewOperation(
    ThemedReactContext themedContext,
    int tag,
    String className,
    @Nullable ReactStylesDiffMap initialProps) {
  super(tag);
  mThemedContext = themedContext;
  mClassName = className;
  mInitialProps = initialProps;
  Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "createView", mTag);
}
 
Example #28
Source File: UIViewOperationQueue.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void execute() {
  Systrace.endAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "createView", mTag);
  mNativeViewHierarchyManager.createView(
      mThemedContext,
      mTag,
      mClassName,
      mInitialProps);
}
 
Example #29
Source File: UIViewOperationQueue.java    From react-native-GPay with MIT License 5 votes vote down vote up
public UpdateLayoutOperation(
    int parentTag,
    int tag,
    int x,
    int y,
    int width,
    int height) {
  super(tag);
  mParentTag = parentTag;
  mX = x;
  mY = y;
  mWidth = width;
  mHeight = height;
  Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "updateLayout", mTag);
}
 
Example #30
Source File: ReactRootView.java    From react-native-GPay with MIT License 5 votes vote down vote up
private void attachToReactInstanceManager() {
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachToReactInstanceManager");
  try {
    if (mIsAttachedToInstance) {
      return;
    }

    mIsAttachedToInstance = true;
    Assertions.assertNotNull(mReactInstanceManager).attachRootView(this);
    getViewTreeObserver().addOnGlobalLayoutListener(getCustomGlobalLayoutListener());
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}