Skip to content

Commit b217ecd

Browse files
potomakmeta-codesync[bot]
authored andcommitted
Initialize Perfetto with the in-process backend on iOS (#59415)
Summary: Pull Request resolved: #59415 `initializePerfetto()` registers Perfetto's system backend on every platform. iOS and the other Apple device platforms have no system tracing service, so the system producer never connects and keeps retrying in the background for the app's lifetime, and a tracer in the app that starts a session without naming a backend gets the system one and records nothing. On those platforms, register the in-process backend instead. Other platforms, including macOS, are unchanged. React Native's own `ReactCxxPlatform/react/profiling/perfetto.cpp` already registers the in-process backend on every platform but Android; this change is narrower and keeps the system backend on macOS and other desktop platforms, where `traced` can run. Changelog: [Internal] Reviewed By: christophpurrer, javache Differential Revision: D126071088 fbshipit-source-id: c1d9ccfa60ef66dbc4178635602bbd1a2dd79279
1 parent 8c2ce77 commit b217ecd

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfetto.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include <perfetto.h>
1313
#include <unordered_map>
1414

15+
#ifdef __APPLE__
16+
#include <TargetConditionals.h>
17+
#endif
18+
1519
#include "FuseboxPerfettoDataSource.h"
1620
#include "HermesPerfettoDataSource.h"
1721
#include "ReactPerfettoCategories.h"
@@ -26,7 +30,13 @@ void initializePerfetto() {
2630
// is only used in tracing build, large buffers are okay
2731
// for now.
2832
args.shmem_size_hint_kb = 20 * 1024;
33+
#if defined(__APPLE__) && TARGET_OS_IPHONE
34+
// iOS and the other Apple device platforms have no system tracing
35+
// service.
36+
args.backends |= perfetto::kInProcessBackend;
37+
#else
2938
args.backends |= perfetto::kSystemBackend;
39+
#endif
3040
args.use_monotonic_clock = true;
3141
perfetto::Tracing::Initialize(args);
3242
TrackEvent::Register();

0 commit comments

Comments
 (0)