Commit 691b232
[0.85] Backport performance debugging improvements (#56637)
* Move base64Encode into react/utils (#55873)
Summary:
Pull Request resolved: #55873
Move `base64Encode` implementation (originally vendored in D58323859) into `ReactCommon/react/utils/` for reuse in other C++ packages.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D95041544
fbshipit-source-id: d71376d03079a8cc4d0a6c3652c40d73374858ea
* Move screenshot Base64 encoding to trace serialization (#55803)
Summary:
Pull Request resolved: #55803
Refactor Android FrameTimings to reduce memory usage in trace buffer. Binary data instead of Base64 should be ~25% smaller, and eliminates string copies during JNI transfer.
Changelog: [Internal]
Reviewed By: rubennorte
Differential Revision: D94657907
fbshipit-source-id: c4a183ff00c519fd1545992340fd445530abab99
* Add tracing helper functions for RNDT traces in C++ and Kotlin (#55935)
Summary:
Pull Request resolved: #55935
Changelog: [internal]
This diff adds helper functions to the PerformanceTracer class for tracing performance events in React Native Developer Tools traces.
In Kotlin, new `trace` method overloads are added to `PerformanceTracer` that wrap a block of code and automatically measure and report its execution time. These use a try/finally pattern to ensure timing is captured correctly.
In C++, a new `PerformanceTracerSection` RAII class is added that automatically reports timing when the section goes out of scope. It supports optional track, track group, and color parameters, as well as variadic key-value properties for additional metadata.
Reviewed By: sammy-SC
Differential Revision: D92061513
fbshipit-source-id: 92c745426c6a9e3a2eee1e85e2a2d7fd12d88ef6
* Introduce fuseboxFrameRecordingEnabled flag, gate existing code (#55941)
Summary:
Pull Request resolved: #55941
Replaces the previous `globalThis.enableTimelineFrames` setup with backend gating.
Enables us to:
- Iterate more safely by gating Android/iOS/C++ code
- Have a per-app rollout at Meta
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D95405444
fbshipit-source-id: 0c41f10059b28ed940a12a44707946baa310bdfb
* Implement Performance frames and screenshots on iOS (#56015)
Summary:
Pull Request resolved: #56015
Implements CDP support for the Chrome DevTools Frames track on iOS during a performance trace, including screenshot capture.
This initial version matches the corresponding implementation for Android:
- Captures the key window.
- Always emits an initial frame.
- Resizes screenshots at 0.75 scale factor (normalized for device screen DPI) and 80% JPEG compression.
- Uses a background thread queue for image resizing.
**To dos**
- [ ] Emit frames only when there is a visual update.
- [ ] Dynamic frame sampling on slower devices (planned for Android).
**Limitations**
- Not a true screen recording, uses `UIGraphicsImageRenderer`.
- Requires no permission prompt ✅
- This can mean empty data (a black screen) is sent during states such as system alert dialogs being presented.
- Like Android, if the background queue builds (on slower hardware), screenshot data can be lost when the recording is ended.
This feature is gated behind the `fuseboxFrameRecordingEnabled` flag.
Changelog: [Internal]
Reviewed By: sbuggay
Differential Revision: D95566220
fbshipit-source-id: c87f1b6d8334b45e2eb67334a5f0f924d20901ec
* Add pixel diffing to RCTFrameTimingsObserver (#56043)
Summary:
Pull Request resolved: #56043
Use pixel hash comparison to avoid encoding duplicate screenshots on iOS, reducing overhead when frames don't change. Matches Android behaviour.
- Samples every 64th pixel with a fast FNV-1a hash (~0.1ms on main thread).
- Skips JPEG encoding and CDP transport entirely for unchanged frames — the dominant per-frame cost.
**Why this approach**
Attempted `CATransaction` completion blocks, however these fire on commits that produce no visual change. No other public API on iOS.
Changelog: [Internal]
Reviewed By: sbuggay
Differential Revision: D95981881
fbshipit-source-id: 76f492f0ceb6b3efea3fce822036ed6cb6067b83
* Add dynamic sampling to frame screenshots (#56048)
Summary:
Pull Request resolved: #56048
Update Android frame screenshot processing to skip screenshot capture when encoding is already in progress — now limited to a single background thread — while always emitting frame timing events.
**Motivation**
1. Prevents truncated trace data on slower devices (e.g. missing screenshots for the last 1/3 of the trace), with the tradeoff of some intermediate frame screenshot loss.
2. Reduces total recording overhead by freeing up device threads - prevents excessive encoding work from blocking or slowing down the UI and other app threads.
**Algorithm**
Uses `encodingInProgress` atomic flag with single encoding thread and `lastFrameBuffer` storage for tail-capture of the last frame before idling (to capture settled animation states):
- **Not encoding:** Frame passes directly to encoder → emits with screenshot when done
- **Encoding busy:** Frame stored in `lastFrameBuffer` for tail-capture → any replaced frame emits without screenshot
- **Encoding done:** Clears flag early, then opportunistically encodes tail frame without blocking new frames
- **Failed captures:** Emit without screenshot immediately
Result: Every frame emitted exactly once. Encoding adapts to device speed. Settled animation state guaranteed captured.
**Remaining work**
- 1 parent 5e3a3ba commit 691b232
62 files changed
Lines changed: 1394 additions & 152 deletions
File tree
- packages/react-native
- ReactAndroid/src/main
- java/com/facebook/react
- devsupport
- inspector
- internal
- featureflags
- tracing
- runtime
- jni/react
- devsupport
- featureflags
- runtime/jni
- ReactCommon
- jsinspector-modern
- tests
- utils
- tracing
- react
- featureflags
- nativemodule/featureflags
- performance/timeline
- runtime/platform/ios/ReactCommon
- utils
- React/DevSupport
- scripts
- cocoapods
- featureflags
- src/private/featureflags
- specs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 298 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
0 commit comments