Skip to content

Commit 887543c

Browse files
authored
docs: update documentation (first part)
1 parent 28b2f2c commit 887543c

28 files changed

+993
-726
lines changed

docs/docs/docs/_meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"name": "introduction.mdx",
55
"label": "Introduction"
66
},
7+
{
8+
"type": "file",
9+
"name": "quick-start.mdx",
10+
"label": "Quick Start"
11+
},
712
{
813
"type": "dir",
914
"name": "core",

docs/docs/docs/backends/_meta.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
[
2+
{
3+
"type": "file",
4+
"name": "introduction.mdx",
5+
"label": "Introduction"
6+
},
27
{
38
"type": "file",
49
"name": "backend-platform.mdx",
5-
"label": "Platform Backend"
10+
"label": "Platform"
611
},
712
{
813
"type": "file",
9-
"name": "backend-wrapper-tracy.mdx",
10-
"label": "Tracy Wrapper Backend"
14+
"name": "backend-tracy.mdx",
15+
"label": "Tracy"
1116
}
1217
]
Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,73 @@
1-
import Readme from '../../../../packages/backend-platform/README.md';
1+
# @ottrelite/backend-platform
22

3-
# Platform Backend
3+
This plugin is the platform-specific backend implementation for RN Ottrelite Core. On Android, it utilizes [ATrace](https://developer.android.com/ndk/reference/group/tracing) (Android tracing API), on iOS it utilizes the [OSSignposter API](https://developer.apple.com/documentation/os/ossignposter).
44

5-
<Readme />
5+
## When to use this backend?
6+
7+
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.
8+
9+
Use Platform Backend when you want:
10+
- **Familiar tooling** - Work with Android Studio Profiler and Xcode Instruments that you already know
11+
- **System-level insights** - Analyze app performance alongside system metrics and other processes
12+
- **No additional setup** - Uses built-in platform APIs without requiring external profiling tools
13+
14+
:::important
15+
This backend is not designed for production use cases and should not be installed in production builds. See the [backends introduction](/docs/backends/introduction#production-builds) for guidance on excluding backends from production builds.
16+
:::
17+
18+
## Supported features
19+
20+
| Feature | Android Support | iOS Support |
21+
| --------------------------------------------- | --------------- | ----------- |
22+
| synchronous traces (`{begin,end}Event`) | API level ≥ 23 (Android M) | iOS 15+ |
23+
| asynchronous traces (`{begin,end}AsyncEvent`) | API level ≥ 29 (Android Q) | iOS 15+ |
24+
| counter events (`counterEvent`) | API level ≥ 29 (Android Q) | iOS 15+ |
25+
26+
:::note
27+
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.
28+
:::
29+
30+
## Installation
31+
32+
To use this package, you need to install it in your React Native project:
33+
34+
```bash
35+
npm install @ottrelite/backend-platform
36+
```
37+
38+
And register the backend with Ottrelite Core in your entrypoint file (e.g. `index.js`):
39+
40+
```typescript
41+
import { OttreliteBackendPlatform } from '@ottrelite/backend-platform';
42+
import { Ottrelite } from '@ottrelite/core';
43+
44+
Ottrelite.install([OttreliteBackendPlatform]);
45+
```
46+
47+
## Recording the trace
48+
49+
### Android
50+
51+
You can record and view traces in two ways:
52+
- using Android Studio's Profiler's 'Capture System Activities' option, as per the [documentation](https://developer.android.com/studio/profile); this method works both on physical devices & the Android emulator
53+
- using the `perfetto` CLI tool, which is distributed as part of the Android OS onboard most modern devices. More details can be found in the [documentation](https://perfetto.dev/docs/getting-started/system-tracing); the resulting file can be viewed in [Perfetto UI](https://ui.perfetto.dev/); this method works only on a physical device
54+
55+
:::important
56+
Make sure that the app you are profiling is `profileable` by placing an [appropriate element](https://developer.android.com/guide/topics/manifest/profileable-element) within your `AndroidManifest.xml`'s `<application>` element: `<profileable android:shell="true" />`
57+
:::
58+
59+
#### Perfetto CLI
60+
61+
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.
62+
63+
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:
64+
65+
```bash
66+
./record_android_trace --app=com.callstack.ottrelite.demo -o trace_file.perfetto-trace -t 40s -b 64mb sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory rs app
67+
```
68+
69+
### iOS
70+
71+
You can view the traces in Xcode Instruments, as per the [documentation](https://developer.apple.com/documentation/os/recording-performance-data#Review-Signposts-in-Instruments).
72+
73+
The traces will be signpost-ed using the `OSSignposter` API, using the default `OS_LOG_DEFAULT` logger.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# @ottrelite/backend-wrapper-tracy
2+
3+
This plugin is a wrapper around the [open-source Tracy profiler](https://github.com/wolfpld/tracy) client, which brings tracing using Tracy to Ottrelite.
4+
5+
## When to use this backend?
6+
7+
The Tracy backend is designed for **real-time development profiling** and provides immediate visual feedback as your React Native app runs. Unlike the Platform backend which requires recording sessions and post-analysis, Tracy gives you live insights into your app's performance.
8+
9+
Use Tracy when you want:
10+
- **Real-time feedback** - See performance data as it happens, perfect for iterative optimization
11+
- **Frame-by-frame analysis** - Detailed timing information for each frame of your app
12+
- **Cross-platform consistency** - Same profiling experience across iOS and Android
13+
- **Memory tracking** - Visual representation of memory usage patterns
14+
- **Interactive exploration** - Zoom, filter, and analyze traces dynamically
15+
16+
:::important
17+
This backend is not designed for production use cases and should not be installed in production builds. See the [backends introduction](/docs/backends/introduction#production-builds) for guidance on excluding backends from production builds.
18+
:::
19+
20+
## Supported features
21+
22+
| Feature | Support level |
23+
| --------------------------------------------- | -------------------------------------------------------------------------- |
24+
| synchronous traces (`{begin,end}Event`) | Supported |
25+
| asynchronous traces (`{begin,end}AsyncEvent`) | Unsupported (see [tracy#149](https://github.com/wolfpld/tracy/issues/149)) |
26+
| counter events (`counterEvent`) | Supported |
27+
28+
## Installation
29+
30+
To use this package, you need to install it in your React Native project:
31+
32+
```bash
33+
npm install @ottrelite/backend-wrapper-tracy
34+
```
35+
36+
And register the backend with Ottrelite Core in your entrypoint file (e.g. `index.js`):
37+
38+
```typescript
39+
import { OttreliteBackendTracy } from '@ottrelite/backend-wrapper-tracy';
40+
import { Ottrelite } from '@ottrelite/core';
41+
42+
Ottrelite.install([OttreliteBackendTracy]);
43+
```
44+
45+
:::important
46+
Remember to give attribution to the Tracy Profiler in your application, as in the [last section](#additional-information).
47+
:::
48+
49+
## Recording the trace
50+
51+
To record the trace, you must use the Tracy Profiler tool. For Windows, there are releases containg `.7z` archives with prebuilt binaries, for other platforms you must follow the [documentation](https://github.com/wolfpld/tracy/releases/latest/download/tracy.pdf) to build it yourself.
52+
53+
In short, the instructions to build the Tracy Profiler tool locally are as follows:
54+
55+
```bash
56+
git clone -b v0.12.2 https://github.com/wolfpld/tracy
57+
cd tracy
58+
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release
59+
cmake --build profiler/build --config Release --parallel
60+
cd profiler/build
61+
# on Windows, you can now run tracy-profiler.exe from this directory.
62+
# on macOS & Linux, you can run ./tracy-profiler from this directory.
63+
./tracy-profiler
64+
```
65+
66+
In case of Android, simply forward the port used by Tracy (default is `8086`) to your device/emulator, e.g. using `adb` for Android:
67+
68+
```bash
69+
adb forward tcp:8086 tcp:8086
70+
```
71+
72+
## Limitations
73+
74+
The `tracy::Profiler::PlotData` function that handles counter events assumes that the counter's name is persisted (it does not copy the string data, just a pointer to it). This is valid for C++ usage where the data is hardcoded in the code (static), yet here (e.g. from JS) it is dynamic. Therefore, this backend keeps the strings passed to the `counterEvent` function in an `std::unordered_set` to ensure that the strings are not deallocated whenever Tracy would try to access them. This means that the counter names will be kept in memory for the lifetime of the backend instance, so be careful with the number of unique counter names you use - using an enormous number of unique counter names (or of enormous lengths) may lead to increased memory usage.
75+
76+
Since Tracy does not support async events, OTEL APIs data will not be visible here. This is because the closest equivalent of OTEL's `Span`s are async events, which are not supported by this backend.
77+
78+
## Additional information
79+
80+
This package utilizes the Tracy Profiler client API under the hood. Please remember to give proper attribution to the Tracy Profiler in your application, as per the [Tracy Profiler license](https://github.com/wolfpld/tracy/blob/master/LICENSE).
81+
82+
Many thanks to the author & contributors of the [Tracy Profiler](https://github.com/wolfpld/tracy).

docs/docs/docs/backends/backend-wrapper-tracy.mdx

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Visualization Backends
2+
3+
Visualization backends are the "display layer" of Ottrelite that transform your trace data into actionable insights. They take raw performance data from your React Native app and present it in different tools and formats to help you quickly identify bottlenecks and optimization opportunities.
4+
5+
## What are Backends?
6+
7+
Backends in Ottrelite are plugins that handle how and where your tracing data is visualized. Each backend connects to different profiling tools and provides unique perspectives on your app's performance. You can use multiple backends simultaneously to get comprehensive insights from different angles.
8+
9+
Think of backends as different "viewers" for the same performance data - some excel at real-time analysis, others integrate with tools you're already familiar with, and some provide specialized visualizations for specific use cases.
10+
11+
## Available Backends
12+
13+
| Backend | Package | Best For | What It Does |
14+
|---------|---------|----------|--------------|
15+
| **Platform** | `@ottrelite/backend-platform` | System-level analysis with familiar tools | Integrates with Android Studio Profiler, Xcode Instruments, and Perfetto using native platform APIs |
16+
| **Tracy** | `@ottrelite/backend-wrapper-tracy` | Real-time development profiling | Frame-by-frame analysis with live trace visualization, memory tracking, and cross-platform support |
17+
18+
### Platform Backend
19+
20+
The Platform backend leverages native tracing APIs that you're likely already familiar with:
21+
- **Android**: Uses ATrace API, viewable in Android Studio Profiler or Perfetto
22+
- **iOS**: Uses OSSignposter API, viewable in Xcode Instruments
23+
24+
This backend is ideal when you want to use the profiling tools built into your development environment.
25+
26+
### Tracy Backend
27+
28+
The Tracy backend wraps the open-source Tracy profiler, providing real-time profiling capabilities:
29+
- Live trace visualization as your app runs
30+
- Frame-by-frame performance analysis
31+
- Memory tracking and visualization
32+
- Cross-platform consistency
33+
34+
This backend is perfect for iterative development where you want immediate feedback on performance changes.
35+
36+
## Production Builds
37+
38+
Backends are designed for development use only and should not be included in production builds.
39+
40+
To exclude backends from production builds:
41+
42+
1. **Conditional installation** - Install backends only when a development feature flag is set:
43+
44+
```typescript
45+
import { Ottrelite } from '@ottrelite/core';
46+
47+
if (__DEV__ || isProfilingEnabled) {
48+
const { OttreliteBackendPlatform } = require('@ottrelite/backend-platform');
49+
Ottrelite.install([OttreliteBackendPlatform]);
50+
}
51+
```
52+
53+
2. **Build-time exclusion** - Use `react-native.config.js` to exclude backend packages from specific build types:
54+
55+
```javascript
56+
module.exports = {
57+
dependencies: {
58+
'@ottrelite/backend-platform': {
59+
platforms: {
60+
android: {
61+
buildTypes: ['debug'], // Only include in debug builds
62+
},
63+
ios: {
64+
configurations: ['Debug'], // Only include in debug builds
65+
},
66+
},
67+
},
68+
},
69+
};
70+
```
71+
72+
:::important
73+
If you've created a separate optimized configuration for performance profiling (as recommended in the [installation guide](/docs/core/introduction#configuring)), make sure to include that configuration in your build-time exclusion list as well to prevent it from being shipped to production.
74+
:::

docs/docs/docs/core/_meta.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"name": "quick-start.mdx",
55
"label": "Quick Start"
66
},
7-
{
8-
"type": "file",
9-
"name": "react-api.mdx",
10-
"label": "React API"
11-
},
127
{
138
"type": "file",
149
"name": "react-native-internals.mdx",

docs/docs/docs/core/contributing.mdx

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)