Java Code Examples for com.facebook.react.bridge.ReactMarker

The following are top voted examples for showing how to use com.facebook.react.bridge.ReactMarker. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RNLearn_Project1   File: LazyReactPackage.java   View source code 6 votes vote down vote up
@Override
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();
  for (ModuleSpec holder : getNativeModules(reactContext)) {
    NativeModule nativeModule;
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
      .arg("module", holder.getType())
      .flush();
    try {
      ReactMarker.logMarker(
        ReactMarkerConstants.CREATE_MODULE_START,
        holder.getType().getSimpleName());
      nativeModule = holder.getProvider().get();
      ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
    } finally {
      Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    }
    modules.add(nativeModule);
  }
  return modules;
}
 
Example 2
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
@Override
protected Result<ReactApplicationContext> doInBackground(ReactContextInitParams... params) {
  // TODO(t11687218): Look over all threading
  // Default priority is Process.THREAD_PRIORITY_BACKGROUND which means we'll be put in a cgroup
  // that only has access to a small fraction of CPU time. The priority will be reset after
  // this task finishes: https://android.googlesource.com/platform/frameworks/base/+/d630f105e8bc0021541aacb4dc6498a49048ecea/core/java/android/os/AsyncTask.java#256
  Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);

  Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
  try {
    JavaScriptExecutor jsExecutor = params[0].getJsExecutorFactory().create();
    ReactApplicationContext reactApplicationContext =
      createReactContext(jsExecutor, params[0].getJsBundleLoader());
    ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
    return Result.of(reactApplicationContext);
  } catch (Exception e) {
    // Pass exception to onPostExecute() so it can be handled on the main thread
    return Result.of(e);
  }
}
 
Example 3
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
/**
 * Uses configured {@link ReactPackage} instances to create all view managers.
 */
public List<ViewManager> createAllViewManagers(
    ReactApplicationContext catalystApplicationContext) {
  ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers");
  try {
    List<ViewManager> allViewManagers = new ArrayList<>();
    for (ReactPackage reactPackage : mPackages) {
      allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext));
    }
    return allViewManagers;
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END);
  }
}
 
Example 4
Project: RNLearn_Project1   File: ModuleHolder.java   View source code 6 votes vote down vote up
private NativeModule create() {
  SoftAssertions.assertCondition(mModule == null, "Creating an already created module.");
  ReactMarker.logMarker(CREATE_MODULE_START, mName);
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
    .arg("name", mName)
    .flush();
  NativeModule module = assertNotNull(mProvider).get();
  mProvider = null;
  if (mInitializeNeeded) {
    doInitialize(module);
    mInitializeNeeded = false;
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(CREATE_MODULE_END);
  return module;
}
 
Example 5
Project: RNLearn_Project1   File: NativeModuleRegistry.java   View source code 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.initialize();
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_END);
  }
}
 
Example 6
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 6 votes vote down vote up
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
  try {
    List<ViewManager> viewManagersList = mReactInstanceManager.createAllViewManagers(
      reactContext);
    return new UIManagerModule(
      reactContext,
      viewManagersList,
      mUIImplementationProvider,
      mLazyViewManagersEnabled);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
  }
}
 
Example 7
Project: RNLearn_Project1   File: LazyReactPackage.java   View source code 6 votes vote down vote up
@Override
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();
  for (ModuleSpec holder : getNativeModules(reactContext)) {
    NativeModule nativeModule;
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
      .arg("module", holder.getType())
      .flush();
    try {
      ReactMarker.logMarker(
        ReactMarkerConstants.CREATE_MODULE_START,
        holder.getType().getSimpleName());
      nativeModule = holder.getProvider().get();
      ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
    } finally {
      Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    }
    modules.add(nativeModule);
  }
  return modules;
}
 
Example 8
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
@Override
protected Result<ReactApplicationContext> doInBackground(ReactContextInitParams... params) {
  // TODO(t11687218): Look over all threading
  // Default priority is Process.THREAD_PRIORITY_BACKGROUND which means we'll be put in a cgroup
  // that only has access to a small fraction of CPU time. The priority will be reset after
  // this task finishes: https://android.googlesource.com/platform/frameworks/base/+/d630f105e8bc0021541aacb4dc6498a49048ecea/core/java/android/os/AsyncTask.java#256
  Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);

  Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
  try {
    JavaScriptExecutor jsExecutor = params[0].getJsExecutorFactory().create();
    ReactApplicationContext reactApplicationContext =
      createReactContext(jsExecutor, params[0].getJsBundleLoader());
    ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
    return Result.of(reactApplicationContext);
  } catch (Exception e) {
    // Pass exception to onPostExecute() so it can be handled on the main thread
    return Result.of(e);
  }
}
 
Example 9
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
/**
 * Uses configured {@link ReactPackage} instances to create all view managers.
 */
public List<ViewManager> createAllViewManagers(
    ReactApplicationContext catalystApplicationContext) {
  ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers");
  try {
    List<ViewManager> allViewManagers = new ArrayList<>();
    for (ReactPackage reactPackage : mPackages) {
      allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext));
    }
    return allViewManagers;
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END);
  }
}
 
Example 10
Project: RNLearn_Project1   File: ModuleHolder.java   View source code 6 votes vote down vote up
private NativeModule create() {
  SoftAssertions.assertCondition(mModule == null, "Creating an already created module.");
  ReactMarker.logMarker(CREATE_MODULE_START, mName);
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
    .arg("name", mName)
    .flush();
  NativeModule module = assertNotNull(mProvider).get();
  mProvider = null;
  if (mInitializeNeeded) {
    doInitialize(module);
    mInitializeNeeded = false;
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(CREATE_MODULE_END);
  return module;
}
 
Example 11
Project: RNLearn_Project1   File: JavaModuleWrapper.java   View source code 6 votes vote down vote up
@DoNotStrip
public NativeArray getConstants() {
  BaseJavaModule baseJavaModule = getModule();
  ReactMarker.logMarker(GET_CONSTANTS_START, getName());
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
    .arg("moduleName", getName())
    .flush();
  Map<String, Object> map = baseJavaModule.getConstants();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);

  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants")
    .arg("moduleName", getName())
    .flush();
  ReactMarker.logMarker(CONVERT_CONSTANTS_START, getName());
  WritableNativeMap writableNativeMap;
  try {
    writableNativeMap = Arguments.makeNativeMap(map);
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  }
  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(writableNativeMap);
  ReactMarker.logMarker(CONVERT_CONSTANTS_END);
  ReactMarker.logMarker(GET_CONSTANTS_END);
  return array;
}
 
Example 12
Project: RNLearn_Project1   File: NativeModuleRegistry.java   View source code 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.initialize();
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_END);
  }
}
 
Example 13
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 6 votes vote down vote up
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
  try {
    List<ViewManager> viewManagersList = mReactInstanceManager.createAllViewManagers(
      reactContext);
    return new UIManagerModule(
      reactContext,
      viewManagersList,
      mUIImplementationProvider,
      mLazyViewManagersEnabled);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
  }
}
 
Example 14
Project: Ironman   File: XReactInstanceManagerImpl.java   View source code 6 votes vote down vote up
/**
 * Uses configured {@link ReactPackage} instances to create all view managers
 */
@Override
public List<ViewManager> createAllViewManagers(
    ReactApplicationContext catalystApplicationContext) {
  ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers");
  try {
    List<ViewManager> allViewManagers = new ArrayList<>();
    for (ReactPackage reactPackage : mPackages) {
      allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext));
    }
    return allViewManagers;
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END);
  }
}
 
Example 15
Project: Ironman   File: ModuleHolder.java   View source code 6 votes vote down vote up
private NativeModule create() {
  boolean isEagerModule = mInfo instanceof LegacyModuleInfo;
  String name = isEagerModule ? ((LegacyModuleInfo) mInfo).mType.getSimpleName() : mInfo.name();
  if (!isEagerModule) {
    ReactMarker.logMarker(CREATE_MODULE_START);
  }
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
    .arg("name", name)
    .flush();
  NativeModule module = assertNotNull(mProvider).get();
  if (mInitializeNeeded) {
    doInitialize(module);
    mInitializeNeeded = false;
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  if (!isEagerModule) {
    ReactMarker.logMarker(CREATE_MODULE_END);
  }
  return module;
}
 
Example 16
Project: Ironman   File: NativeModuleRegistry.java   View source code 6 votes vote down vote up
void notifyCatalystInstanceInitialized() {
  UiThreadUtil.assertOnUiThread();

  ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_START);
  Systrace.beginSection(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      "NativeModuleRegistry_notifyCatalystInstanceInitialized");
  try {
    for (ModuleHolder module : mModules.values()) {
      module.initialize();
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_END);
  }
}
 
Example 17
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 5 votes vote down vote up
private void runCreateReactContextOnNewThread(final ReactContextInitParams initParams) {
  if (mCurrentReactContext != null) {
    tearDownReactContext(mCurrentReactContext);
    mCurrentReactContext = null;
  }

  mCreateReactContextThread = new Thread(new Runnable() {
    @Override
    public void run() {
      try {
        final ReactApplicationContext reactApplicationContext = createReactContext(
          initParams.getJsExecutorFactory().create(),
          initParams.getJsBundleLoader());
        ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
        UiThreadUtil.runOnUiThread(new Runnable() {
          @Override
          public void run() {
            mCreateReactContextThread = null;
            try {
              setupReactContext(reactApplicationContext);
            } catch (Exception e) {
              mDevSupportManager.handleException(e);
            }

            if (mPendingReactContextInitParams != null) {
              runCreateReactContextOnNewThread(mPendingReactContextInitParams);
              mPendingReactContextInitParams = null;
            }
          }
        });
      } catch (Exception e) {
        mDevSupportManager.handleException(e);
      }
    }
  });
  mCreateReactContextThread.setPriority(Thread.MAX_PRIORITY);
  mCreateReactContextThread.start();
}
 
Example 18
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 5 votes vote down vote up
private void setupReactContext(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_END);
}
 
Example 19
Project: RNLearn_Project1   File: UIManagerModule.java   View source code 5 votes vote down vote up
private static Map<String, Object> createConstants(
  List<ViewManager> viewManagerList,
  boolean lazyViewManagersEnabled) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants");
  try {
    return UIManagerModuleConstantsHelper.createConstants(
      viewManagerList,
      lazyViewManagersEnabled);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END);
  }
}
 
Example 20
Project: RNLearn_Project1   File: ModuleHolder.java   View source code 5 votes vote down vote up
private void doInitialize(NativeModule module) {
  SystraceMessage.Builder section =
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initialize");
  if (module instanceof CxxModuleWrapper) {
    section.arg("className", module.getClass().getSimpleName());
  } else {
    section.arg("name", mName);
  }
  section.flush();
  ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName);
  module.initialize();
  ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END);
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 21
Project: RNLearn_Project1   File: JavaModuleWrapper.java   View source code 5 votes vote down vote up
@DoNotStrip
public @Nullable NativeArray getConstants() {
  if (!mModuleHolder.getHasConstants()) {
    return null;
  }
  BaseJavaModule baseJavaModule = getModule();
  ReactMarker.logMarker(GET_CONSTANTS_START, getName());
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
    .arg("moduleName", getName())
    .flush();
  Map<String, Object> map = baseJavaModule.getConstants();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);

  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants")
    .arg("moduleName", getName())
    .flush();
  ReactMarker.logMarker(CONVERT_CONSTANTS_START, getName());
  WritableNativeMap writableNativeMap;
  try {
    writableNativeMap = Arguments.makeNativeMap(map);
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  }
  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(writableNativeMap);
  ReactMarker.logMarker(CONVERT_CONSTANTS_END);
  ReactMarker.logMarker(GET_CONSTANTS_END);
  return array;
}
 
Example 22
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 5 votes vote down vote up
@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
  ReactMarker.logMarker(
    ReactMarkerConstants.CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START);
  // This has to be done via reflection or we break open source.
  ReactModuleInfoProvider reactModuleInfoProvider =
    LazyReactPackage.getReactModuleInfoProviderViaReflection(this);
  ReactMarker.logMarker(
    ReactMarkerConstants.CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END);
  return reactModuleInfoProvider;
}
 
Example 23
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 5 votes vote down vote up
private void runCreateReactContextOnNewThread(final ReactContextInitParams initParams) {
  if (mCurrentReactContext != null) {
    tearDownReactContext(mCurrentReactContext);
    mCurrentReactContext = null;
  }

  mCreateReactContextThread = new Thread(new Runnable() {
    @Override
    public void run() {
      try {
        final ReactApplicationContext reactApplicationContext = createReactContext(
          initParams.getJsExecutorFactory().create(),
          initParams.getJsBundleLoader());
        ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
        UiThreadUtil.runOnUiThread(new Runnable() {
          @Override
          public void run() {
            mCreateReactContextThread = null;
            try {
              setupReactContext(reactApplicationContext);
            } catch (Exception e) {
              mDevSupportManager.handleException(e);
            }

            if (mPendingReactContextInitParams != null) {
              runCreateReactContextOnNewThread(mPendingReactContextInitParams);
              mPendingReactContextInitParams = null;
            }
          }
        });
      } catch (Exception e) {
        mDevSupportManager.handleException(e);
      }
    }
  });
  mCreateReactContextThread.setPriority(Thread.MAX_PRIORITY);
  mCreateReactContextThread.start();
}
 
Example 24
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 5 votes vote down vote up
private void setupReactContext(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_END);
}
 
Example 25
Project: RNLearn_Project1   File: UIManagerModule.java   View source code 5 votes vote down vote up
private static Map<String, Object> createConstants(
  List<ViewManager> viewManagerList,
  boolean lazyViewManagersEnabled) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants");
  try {
    return UIManagerModuleConstantsHelper.createConstants(
      viewManagerList,
      lazyViewManagersEnabled);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END);
  }
}
 
Example 26
Project: RNLearn_Project1   File: ModuleHolder.java   View source code 5 votes vote down vote up
private void doInitialize(NativeModule module) {
  SystraceMessage.Builder section =
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initialize");
  if (module instanceof CxxModuleWrapper) {
    section.arg("className", module.getClass().getSimpleName());
  } else {
    section.arg("name", mName);
  }
  section.flush();
  ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName);
  module.initialize();
  ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END);
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 27
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 5 votes vote down vote up
@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
  ReactMarker.logMarker(
    ReactMarkerConstants.CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START);
  // This has to be done via reflection or we break open source.
  ReactModuleInfoProvider reactModuleInfoProvider =
    LazyReactPackage.getReactModuleInfoProviderViaReflection(this);
  ReactMarker.logMarker(
    ReactMarkerConstants.CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END);
  return reactModuleInfoProvider;
}
 
Example 28
Project: Ironman   File: UIManagerModule.java   View source code 5 votes vote down vote up
private static Map<String, Object> createConstants(List<ViewManager> viewManagerList) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants");
  try {
    return UIManagerModuleConstantsHelper.createConstants(viewManagerList);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END);
  }
}
 
Example 29
Project: Ironman   File: XReactInstanceManagerImpl.java   View source code 5 votes vote down vote up
private void setupReactContext(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_END);
}
 
Example 30
Project: Ironman   File: CoreModulesPackage.java   View source code 5 votes vote down vote up
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
  try {
    List<ViewManager> viewManagersList = mReactInstanceManager.createAllViewManagers(
      reactContext);
    return new UIManagerModule(
      reactContext,
      viewManagersList,
      mUIImplementationProvider);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
  }
}
 
Example 31
Project: RNLearn_Project1   File: NativeModuleRegistryBuilder.java   View source code 4 votes vote down vote up
public void processPackage(ReactPackage reactPackage) {
  if (mLazyNativeModulesEnabled) {
    if (!(reactPackage instanceof LazyReactPackage)) {
      throw new IllegalStateException("Lazy native modules requires all ReactPackage to " +
        "inherit from LazyReactPackage");
    }

    LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
    List<ModuleSpec> moduleSpecs = lazyReactPackage.getNativeModules(mReactApplicationContext);
    Map<Class, ReactModuleInfo> reactModuleInfoMap = lazyReactPackage.getReactModuleInfoProvider()
      .getReactModuleInfos();

    for (ModuleSpec moduleSpec : moduleSpecs) {
      Class<? extends NativeModule> type = moduleSpec.getType();
      ReactModuleInfo reactModuleInfo = reactModuleInfoMap.get(type);
      ModuleHolder moduleHolder;
      if (reactModuleInfo == null) {
        if (BaseJavaModule.class.isAssignableFrom(type)) {
          throw new IllegalStateException("Native Java module " + type.getSimpleName() +
            " should be annotated with @ReactModule and added to a @ReactModuleList.");
        }
        ReactMarker.logMarker(
          ReactMarkerConstants.CREATE_MODULE_START,
          moduleSpec.getType().getName());
        NativeModule module = moduleSpec.getProvider().get();
        ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
        moduleHolder = new ModuleHolder(module);
      } else {
        moduleHolder = new ModuleHolder(
          reactModuleInfo.name(),
          reactModuleInfo.canOverrideExistingModule(),
          reactModuleInfo.supportsWebWorkers(),
          reactModuleInfo.needsEagerInit(),
          reactModuleInfo.hasConstants(),
          moduleSpec.getProvider());
      }

      String name = moduleHolder.getName();
      if (namesToType.containsKey(name)) {
        Class<? extends NativeModule> existingNativeModule = namesToType.get(name);
        if (!moduleHolder.getCanOverrideExistingModule()) {
          throw new IllegalStateException("Native module " + type.getSimpleName() +
            " tried to override " + existingNativeModule.getSimpleName() + " for module name " +
            name + ". If this was your intention, set canOverrideExistingModule=true");
        }

        mModules.remove(existingNativeModule);
      }

      namesToType.put(name, type);
      mModules.put(type, moduleHolder);
    }
  } else {
    FLog.d(
      ReactConstants.TAG,
      reactPackage.getClass().getSimpleName() +
        " is not a LazyReactPackage, falling back to old version.");
    List<NativeModule> nativeModules;
    if (reactPackage instanceof ReactInstancePackage) {
      ReactInstancePackage reactInstancePackage = (ReactInstancePackage) reactPackage;
      nativeModules = reactInstancePackage.createNativeModules(
          mReactApplicationContext,
          mReactInstanceManager);
    } else {
      nativeModules = reactPackage.createNativeModules(mReactApplicationContext);
    }
    for (NativeModule nativeModule : nativeModules) {
      addNativeModule(nativeModule);
    }
  }
}
 
Example 32
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 4 votes vote down vote up
@Override
public void startProcessPackage() {
  ReactMarker.logMarker(PROCESS_CORE_REACT_PACKAGE_START);
}
 
Example 33
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 4 votes vote down vote up
@Override
public void endProcessPackage() {
  ReactMarker.logMarker(PROCESS_CORE_REACT_PACKAGE_END);
}
 
Example 34
Project: RNLearn_Project1   File: NativeModuleRegistryBuilder.java   View source code 4 votes vote down vote up
public void processPackage(ReactPackage reactPackage) {
  if (mLazyNativeModulesEnabled) {
    if (!(reactPackage instanceof LazyReactPackage)) {
      throw new IllegalStateException("Lazy native modules requires all ReactPackage to " +
        "inherit from LazyReactPackage");
    }

    LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
    List<ModuleSpec> moduleSpecs = lazyReactPackage.getNativeModules(mReactApplicationContext);
    Map<Class, ReactModuleInfo> reactModuleInfoMap = lazyReactPackage.getReactModuleInfoProvider()
      .getReactModuleInfos();

    for (ModuleSpec moduleSpec : moduleSpecs) {
      Class<? extends NativeModule> type = moduleSpec.getType();
      ReactModuleInfo reactModuleInfo = reactModuleInfoMap.get(type);
      ModuleHolder moduleHolder;
      if (reactModuleInfo == null) {
        if (BaseJavaModule.class.isAssignableFrom(type)) {
          throw new IllegalStateException("Native Java module " + type.getSimpleName() +
            " should be annotated with @ReactModule and added to a @ReactModuleList.");
        }
        ReactMarker.logMarker(
          ReactMarkerConstants.CREATE_MODULE_START,
          moduleSpec.getType().getName());
        NativeModule module = moduleSpec.getProvider().get();
        ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
        moduleHolder = new ModuleHolder(module);
      } else {
        moduleHolder = new ModuleHolder(
          reactModuleInfo.name(),
          reactModuleInfo.canOverrideExistingModule(),
          reactModuleInfo.supportsWebWorkers(),
          reactModuleInfo.needsEagerInit(),
          moduleSpec.getProvider());
      }

      String name = moduleHolder.getName();
      if (namesToType.containsKey(name)) {
        Class<? extends NativeModule> existingNativeModule = namesToType.get(name);
        if (!moduleHolder.getCanOverrideExistingModule()) {
          throw new IllegalStateException("Native module " + type.getSimpleName() +
            " tried to override " + existingNativeModule.getSimpleName() + " for module name " +
            name + ". If this was your intention, set canOverrideExistingModule=true");
        }

        mModules.remove(existingNativeModule);
      }

      namesToType.put(name, type);
      mModules.put(type, moduleHolder);
    }
  } else {
    FLog.d(
      ReactConstants.TAG,
      reactPackage.getClass().getSimpleName() +
        " is not a LazyReactPackage, falling back to old version.");
    List<NativeModule> nativeModules;
    if (reactPackage instanceof ReactInstancePackage) {
      ReactInstancePackage reactInstancePackage = (ReactInstancePackage) reactPackage;
      nativeModules = reactInstancePackage.createNativeModules(
          mReactApplicationContext,
          mReactInstanceManager);
    } else {
      nativeModules = reactPackage.createNativeModules(mReactApplicationContext);
    }
    for (NativeModule nativeModule : nativeModules) {
      addNativeModule(nativeModule);
    }
  }
}
 
Example 35
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 4 votes vote down vote up
@Override
public void startProcessPackage() {
  ReactMarker.logMarker(PROCESS_CORE_REACT_PACKAGE_START);
}
 
Example 36
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 4 votes vote down vote up
@Override
public void endProcessPackage() {
  ReactMarker.logMarker(PROCESS_CORE_REACT_PACKAGE_END);
}