Java Code Examples for com.facebook.systrace.Systrace#isTracing()

The following examples show how to use com.facebook.systrace.Systrace#isTracing() . 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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void onRequestSuccess(ImageRequest request, String requestId, 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 9
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void onRequestCancellation(String requestId) {
  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 10
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
@ThreadConfined(UI)
private void recreateReactContextInBackgroundInner() {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackgroundInner()");
  PrinterHolder.getPrinter()
      .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: recreateReactContextInBackground");
  UiThreadUtil.assertOnUiThread();

  if (mUseDeveloperSupport
      && mJSMainModulePath != null
      && !Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) {
    final DeveloperSettings devSettings = mDevSupportManager.getDevSettings();

    // If remote JS debugging is enabled, load from dev server.
    if (mDevSupportManager.hasUpToDateJSBundleInCache() &&
        !devSettings.isRemoteJSDebugEnabled()) {
      // If there is a up-to-date bundle downloaded from server,
      // with remote JS debugging disabled, always use that.
      onJSBundleLoadedFromServer(null);
    } else if (mBundleLoader == null) {
      mDevSupportManager.handleReloadJS();
    } else {
      mDevSupportManager.isPackagerRunning(
          new PackagerStatusCallback() {
            @Override
            public void onPackagerStatusFetched(final boolean packagerIsRunning) {
              UiThreadUtil.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (packagerIsRunning) {
                        mDevSupportManager.handleReloadJS();
                      } else {
                        // If dev server is down, disable the remote JS debugging.
                        devSettings.setRemoteJSDebugEnabled(false);
                        recreateReactContextInBackgroundFromBundleLoader();
                      }
                    }
                  });
            }
          });
    }
    return;
  }

  recreateReactContextInBackgroundFromBundleLoader();
}
 
Example 11
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
/**
 * @return instance of {@link ReactContext} configured a {@link CatalystInstance} set
 */
private ReactApplicationContext createReactContext(
    JavaScriptExecutor jsExecutor,
    JSBundleLoader jsBundleLoader) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.createReactContext()");
  ReactMarker.logMarker(CREATE_REACT_CONTEXT_START, jsExecutor.getName());
  final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext);

  NativeModuleCallExceptionHandler exceptionHandler = mNativeModuleCallExceptionHandler != null
      ? mNativeModuleCallExceptionHandler
      : mDevSupportManager;
  reactContext.setNativeModuleCallExceptionHandler(exceptionHandler);

  NativeModuleRegistry nativeModuleRegistry = processPackages(reactContext, mPackages, false);

  CatalystInstanceImpl.Builder catalystInstanceBuilder = new CatalystInstanceImpl.Builder()
    .setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
    .setJSExecutor(jsExecutor)
    .setRegistry(nativeModuleRegistry)
    .setJSBundleLoader(jsBundleLoader)
    .setNativeModuleCallExceptionHandler(exceptionHandler);

  ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_START);
  // CREATE_CATALYST_INSTANCE_END is in JSCExecutor.cpp
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstance");
  final CatalystInstance catalystInstance;
  try {
    catalystInstance = catalystInstanceBuilder.build();
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_END);
  }
  if (mJSIModulePackage != null) {
    catalystInstance.addJSIModules(mJSIModulePackage
      .getJSIModules(reactContext, catalystInstance.getJavaScriptContextHolder()));
  }

  if (mBridgeIdleDebugListener != null) {
    catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
  }
  if (Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) {
    catalystInstance.setGlobalVariable("__RCTProfileIsProfiling", "true");
  }
  ReactMarker.logMarker(ReactMarkerConstants.PRE_RUN_JS_BUNDLE_START);
  catalystInstance.runJSBundle();
  reactContext.initializeWithInstance(catalystInstance);

  return reactContext;
}