This plugin is the platform-specific backend implementation for RN Ottrelite Core. On Android, it utilizes ATrace (Android tracing API), on iOS it utilizes the OSSignposter API.
This backend is designed for system-level analysis using familiar tools that are already part of your development environment. It leverages the native profiling APIs built into Android and iOS platforms, allowing you to use the debugging tools you're already comfortable with.
Use Platform Backend when you want:
This backend is not designed for production use cases and should not be installed in production builds. See the backends introduction for guidance on excluding backends from production builds.
| Feature | Android Support | iOS Support |
|---|---|---|
synchronous traces ({begin,end}Event) | API level ≥ 23 (Android M) | iOS 15+ |
asynchronous traces ({begin,end}AsyncEvent) | API level ≥ 29 (Android Q) | iOS 15+ |
counter events (counterEvent) | API level ≥ 29 (Android Q) | iOS 15+ |
The support levels above mean that the application must be compiled with at least the given minSdkVersion. This is because those APIs are not available on older Android versions and therefore it is not possible to compile the native code against older SDKs.
To use this package, you need to install it in your React Native project:
And register the backend with Ottrelite Core in your entrypoint file (e.g. index.js):
You can record and view traces in two ways:
perfetto CLI tool, which is distributed as part of the Android OS onboard most modern devices. More details can be found in the documentation; the resulting file can be viewed in Perfetto UI; this method works only on a physical device
Make sure that the app you are profiling is profileable by placing an appropriate element within your AndroidManifest.xml's <application> element: <profileable android:shell="true" />
If using the Perfetto CLI via the record_android_trace script, make sure to adjust the --app argument to match your app's package. We discovered that on some devices it is needed to set it, otherwise some userspace events may be missing.
Some devices allow to pass an additional tracing category, app, which can also be considered in such cases. An example invocation might look like the following:
You can view the traces in Xcode Instruments, as per the documentation.
The traces will be signpost-ed using the OSSignposter API, using the default OS_LOG_DEFAULT logger.